/// <summary>
        ///     Upload file
        /// </summary>
        /// <param name="request">Request. <see cref="UploadFileRequest" /></param>
        /// <returns>
        ///     <see cref="FilesUploadResult" />
        /// </returns>
        public FilesUploadResult UploadFile(UploadFileRequest request)
        {
            // verify the required parameter 'path' is set
            if (request.path == null)
            {
                throw new ApiException(400, "Missing required parameter 'path' when calling UploadFile");
            }
            // verify the required parameter '_file' is set
            if (request.File == null)
            {
                throw new ApiException(400, "Missing required parameter '_file' when calling UploadFile");
            }
            // create path and map variables
            string resourcePath = _configuration.GetApiRootUrl() + "/barcode/storage/file/{path}";

            resourcePath = Regex
                           .Replace(resourcePath, "\\*", string.Empty)
                           .Replace("&amp;", "&")
                           .Replace("/?", "?");
            var formParams = new Dictionary <string, object>();

            resourcePath = UrlHelper.AddPathParameter(resourcePath, "path", request.path);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "storageName", request.storageName);



            if (request.File != null)
            {
                formParams.Add("_file", ApiInvoker.ToFileInfo(request.File, "File"));
            }
            string response = _apiInvoker.InvokeApi(
                resourcePath,
                "PUT",
                null,
                null,
                formParams);

            if (response != null)
            {
                return((FilesUploadResult)SerializationHelper.Deserialize(response, typeof(FilesUploadResult)));
            }

            return(null);
        }
Пример #2
0
        public FilesUploadResult UploadFile(UploadFileRequest request)
        {
            // verify the required parameter 'path' is set
            if (request.Path == null)
            {
                throw new ApiException(400, "Missing required parameter 'path' when calling UploadFile");
            }

            // verify the required parameter 'file' is set
            if (request.File == null)
            {
                throw new ApiException(400, "Missing required parameter 'file' when calling UploadFile");
            }

            // create path and map variables
            var resourcePath = _configuration.GetApiRootUrl() + "/storage/file/{path}";

            resourcePath = Regex
                           .Replace(resourcePath, "\\*", string.Empty)
                           .Replace("&amp;", "&")
                           .Replace("/?", "?");
            var formParams = new Dictionary <string, object>();

            resourcePath = UrlHelper.AddPathParameter(resourcePath, "path", request.Path);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "storageName", request.StorageName);

            if (request.File != null)
            {
                formParams.Add("file", _apiInvoker.ToFileInfo(request.File, "File"));
            }

            try
            {
                var response = _apiInvoker.InvokeApi(
                    resourcePath,
                    "PUT",
                    null,
                    null,
                    formParams);
                if (response != null)
                {
                    return((FilesUploadResult)SerializationHelper.Deserialize(response, typeof(FilesUploadResult)));
                }

                var errors = new List <Error> {
                    new Error {
                        Code = "500", Message = "response null"
                    }
                };
                return(new FilesUploadResult {
                    Errors = errors
                });
            }
            catch (ApiException ex)
            {
                var errors = new List <Error> {
                    new Error {
                        Code = ex.ErrorCode.ToString(), Message = ex.Message, Description = ex.StackTrace
                    }
                };
                return(new FilesUploadResult {
                    Errors = errors
                });
            }
        }
        /// <summary>
        ///     Recognize barcode from an url or from request body. Request body can contain raw data bytes of the image or encoded with base64.
        /// </summary>
        /// <param name="request">Request. <see cref="PostBarcodeRecognizeFromUrlOrContentRequest" /></param>
        /// <returns>
        ///     <see cref="BarcodeResponseList" />
        /// </returns>
        public BarcodeResponseList PostBarcodeRecognizeFromUrlOrContent(PostBarcodeRecognizeFromUrlOrContentRequest request)
        {
            // create path and map variables
            string resourcePath = _configuration.GetApiRootUrl() + "/barcode/recognize";

            resourcePath = Regex
                           .Replace(resourcePath, "\\*", string.Empty)
                           .Replace("&amp;", "&")
                           .Replace("/?", "?");
            var formParams = new Dictionary <string, object>();

            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "type", request.Type);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "checksumValidation", request.ChecksumValidation);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "detectEncoding", request.DetectEncoding);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "preset", request.Preset);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "rectX", request.RectX);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "rectY", request.RectY);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "rectWidth", request.RectWidth);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "rectHeight", request.RectHeight);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "stripFNC", request.StripFNC);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "timeout", request.Timeout);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "medianSmoothingWindowSize", request.MedianSmoothingWindowSize);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "allowMedianSmoothing", request.AllowMedianSmoothing);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "allowComplexBackground", request.AllowComplexBackground);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "allowDatamatrixIndustrialBarcodes", request.AllowDatamatrixIndustrialBarcodes);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "allowDecreasedImage", request.AllowDecreasedImage);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "allowDetectScanGap", request.AllowDetectScanGap);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "allowIncorrectBarcodes", request.AllowIncorrectBarcodes);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "allowInvertImage", request.AllowInvertImage);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "allowMicroWhiteSpotsRemoving", request.AllowMicroWhiteSpotsRemoving);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "allowOneDFastBarcodesDetector", request.AllowOneDFastBarcodesDetector);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "allowOneDWipedBarsRestoration", request.AllowOneDWipedBarsRestoration);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "allowQRMicroQrRestoration", request.AllowQRMicroQrRestoration);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "allowRegularImage", request.AllowRegularImage);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "allowSaltAndPepperFiltering", request.AllowSaltAndPepperFiltering);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "allowWhiteSpotsRemoving", request.AllowWhiteSpotsRemoving);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "checkMore1DVariants", request.CheckMore1DVariants);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "fastScanOnly", request.FastScanOnly);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "regionLikelihoodThresholdPercent", request.RegionLikelihoodThresholdPercent);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "scanWindowSizes", request.ScanWindowSizes);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "similarity", request.Similarity);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "skipDiagonalSearch", request.SkipDiagonalSearch);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "readTinyBarcodes", request.ReadTinyBarcodes);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "australianPostEncodingTable", request.AustralianPostEncodingTable);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "ignoreEndingFillingPatternsForCTable", request.IgnoreEndingFillingPatternsForCTable);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "rectangleRegion", request.RectangleRegion);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "url", request.url);



            if (request.image != null)
            {
                formParams.Add("image", ApiInvoker.ToFileInfo(request.image, "image"));
            }
            string response = _apiInvoker.InvokeApi(
                resourcePath,
                "POST",
                null,
                null,
                formParams);

            if (response != null)
            {
                return((BarcodeResponseList)SerializationHelper.Deserialize(response, typeof(BarcodeResponseList)));
            }

            return(null);
        }