Пример #1
0
        /// <summary>
        ///  Gets a product by barcode
        /// </summary>
        /// <exception cref="TomiSoft.ProductCatalog.Client.OpenApiGenerated.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="barcode"></param>
        /// <returns>ApiResponse of ProductInformationDto</returns>
        public TomiSoft.ProductCatalog.Client.OpenApiGenerated.Client.ApiResponse <ProductInformationDto> GetByBarcodeWithHttpInfo(string barcode)
        {
            // verify the required parameter 'barcode' is set
            if (barcode == null)
            {
                throw new TomiSoft.ProductCatalog.Client.OpenApiGenerated.Client.ApiException(400, "Missing required parameter 'barcode' when calling ProductApi->GetByBarcode");
            }

            TomiSoft.ProductCatalog.Client.OpenApiGenerated.Client.RequestOptions localVarRequestOptions = new TomiSoft.ProductCatalog.Client.OpenApiGenerated.Client.RequestOptions();

            String[] _contentTypes = new String[] {
            };

            // to determine the Accept header
            String[] _accepts = new String[] {
                "application/json"
            };

            var localVarContentType = TomiSoft.ProductCatalog.Client.OpenApiGenerated.Client.ClientUtils.SelectHeaderContentType(_contentTypes);

            if (localVarContentType != null)
            {
                localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType);
            }

            var localVarAccept = TomiSoft.ProductCatalog.Client.OpenApiGenerated.Client.ClientUtils.SelectHeaderAccept(_accepts);

            if (localVarAccept != null)
            {
                localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
            }

            if (barcode != null)
            {
                localVarRequestOptions.PathParameters.Add("barcode", TomiSoft.ProductCatalog.Client.OpenApiGenerated.Client.ClientUtils.ParameterToString(barcode)); // path parameter
            }
            // make the HTTP request
            var localVarResponse = this.Client.Get <ProductInformationDto>("/Product/{barcode}", localVarRequestOptions, this.Configuration);

            if (this.ExceptionFactory != null)
            {
                Exception _exception = this.ExceptionFactory("GetByBarcode", localVarResponse);
                if (_exception != null)
                {
                    throw _exception;
                }
            }

            return(localVarResponse);
        }
Пример #2
0
        /// <summary>
        ///  Gets a product by barcode
        /// </summary>
        /// <exception cref="TomiSoft.ProductCatalog.Client.OpenApiGenerated.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="barcode"></param>
        /// <returns>Task of ApiResponse (ProductInformationDto)</returns>
        public async System.Threading.Tasks.Task <TomiSoft.ProductCatalog.Client.OpenApiGenerated.Client.ApiResponse <ProductInformationDto> > GetByBarcodeAsyncWithHttpInfo(string barcode)
        {
            // verify the required parameter 'barcode' is set
            if (barcode == null)
            {
                throw new TomiSoft.ProductCatalog.Client.OpenApiGenerated.Client.ApiException(400, "Missing required parameter 'barcode' when calling ProductApi->GetByBarcode");
            }


            TomiSoft.ProductCatalog.Client.OpenApiGenerated.Client.RequestOptions localVarRequestOptions = new TomiSoft.ProductCatalog.Client.OpenApiGenerated.Client.RequestOptions();

            String[] _contentTypes = new String[] {
            };

            // to determine the Accept header
            String[] _accepts = new String[] {
                "application/json"
            };

            foreach (var _contentType in _contentTypes)
            {
                localVarRequestOptions.HeaderParameters.Add("Content-Type", _contentType);
            }

            foreach (var _accept in _accepts)
            {
                localVarRequestOptions.HeaderParameters.Add("Accept", _accept);
            }

            if (barcode != null)
            {
                localVarRequestOptions.PathParameters.Add("barcode", TomiSoft.ProductCatalog.Client.OpenApiGenerated.Client.ClientUtils.ParameterToString(barcode)); // path parameter
            }
            // make the HTTP request

            var localVarResponse = await this.AsynchronousClient.GetAsync <ProductInformationDto>("/Product/{barcode}", localVarRequestOptions, this.Configuration);

            if (this.ExceptionFactory != null)
            {
                Exception _exception = this.ExceptionFactory("GetByBarcode", localVarResponse);
                if (_exception != null)
                {
                    throw _exception;
                }
            }

            return(localVarResponse);
        }