/// <summary> /// Update parameters of jpg image. Update parameters of jpg image. /// </summary> /// <param name="quality"></param> /// <param name="compressionType"></param> /// <param name="fromScratch"></param> /// <param name="outPath"></param> /// <param name="file"></param> /// <returns></returns> public ResponseMessage PostImageJpg (int? quality, string compressionType, bool? fromScratch, string outPath, byte[] file) { // create path and map variables var ResourcePath = "/imaging/jpg/?appSid={appSid}&quality={quality}&compressionType={compressionType}&fromScratch={fromScratch}&outPath={outPath}".Replace("{format}","json"); ResourcePath = Regex.Replace(ResourcePath, "\\*", "").Replace("&", "&").Replace("/?", "?").Replace("toFormat={toFormat}", "format={format}"); // query params var queryParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, object>(); // verify required params are set if (file == null ) { throw new ApiException(400, "missing required params"); } if (quality == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])quality=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "quality" + "}", apiInvoker.ToPathValue(quality)); } if (compressionType == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])compressionType=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "compressionType" + "}", apiInvoker.ToPathValue(compressionType)); } if (fromScratch == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])fromScratch=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "fromScratch" + "}", apiInvoker.ToPathValue(fromScratch)); } if (outPath == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])outPath=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "outPath" + "}", apiInvoker.ToPathValue(outPath)); } if (file != null){ if(file is byte[]) { var docFile = new FileInfo(); docFile.file = file; docFile.MimeType = "application/octet-stream"; formParams.Add("file", docFile); } else { //string paramStr = (file is DateTime) ? ((DateTime)(object)file).ToString("u") : Convert.ToString(file); string paramStr = Convert.ToString(file); formParams.Add("file", paramStr); } } try { if (typeof(ResponseMessage) == typeof(ResponseMessage)) { var response = apiInvoker.invokeBinaryAPI(basePath, ResourcePath, "POST", queryParams, null, headerParams, formParams); return (ResponseMessage) ApiInvoker.deserialize(response, typeof(ResponseMessage)); } else { var response = apiInvoker.invokeAPI(basePath, ResourcePath, "POST", queryParams, null, headerParams, formParams); if(response != null){ return (ResponseMessage) ApiInvoker.deserialize(response, typeof(ResponseMessage)); } else { return null; } } } catch (ApiException ex) { if(ex.ErrorCode == 404) { return null; } else { throw ex; } } }
/// <summary> /// Crop image from body Crop image from body /// </summary> /// <param name="format"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="outPath"></param> /// <param name="file"></param> /// <returns></returns> public ResponseMessage PostCropImage (string format, int? x, int? y, int? width, int? height, string outPath, byte[] file) { // create path and map variables var ResourcePath = "/imaging/crop/?appSid={appSid}&toFormat={toFormat}&x={x}&y={y}&width={width}&height={height}&outPath={outPath}".Replace("{format}","json"); ResourcePath = Regex.Replace(ResourcePath, "\\*", "").Replace("&", "&").Replace("/?", "?").Replace("toFormat={toFormat}", "format={format}"); // query params var queryParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, object>(); // verify required params are set if (format == null || x == null || y == null || width == null || height == null || file == null ) { throw new ApiException(400, "missing required params"); } if (format == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])format=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "format" + "}", apiInvoker.ToPathValue(format)); } if (x == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])x=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "x" + "}", apiInvoker.ToPathValue(x)); } if (y == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])y=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "y" + "}", apiInvoker.ToPathValue(y)); } if (width == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])width=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "width" + "}", apiInvoker.ToPathValue(width)); } if (height == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])height=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "height" + "}", apiInvoker.ToPathValue(height)); } if (outPath == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])outPath=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "outPath" + "}", apiInvoker.ToPathValue(outPath)); } if (file != null){ if(file is byte[]) { var docFile = new FileInfo(); docFile.file = file; docFile.MimeType = "application/octet-stream"; formParams.Add("file", docFile); } else { //string paramStr = (file is DateTime) ? ((DateTime)(object)file).ToString("u") : Convert.ToString(file); string paramStr = Convert.ToString(file); formParams.Add("file", paramStr); } } try { if (typeof(ResponseMessage) == typeof(ResponseMessage)) { var response = apiInvoker.invokeBinaryAPI(basePath, ResourcePath, "POST", queryParams, null, headerParams, formParams); return (ResponseMessage) ApiInvoker.deserialize(response, typeof(ResponseMessage)); } else { var response = apiInvoker.invokeAPI(basePath, ResourcePath, "POST", queryParams, null, headerParams, formParams); if(response != null){ return (ResponseMessage) ApiInvoker.deserialize(response, typeof(ResponseMessage)); } else { return null; } } } catch (ApiException ex) { if(ex.ErrorCode == 404) { return null; } else { throw ex; } } }
/// <summary> /// Update parameters of gif image. Update parameters of gif image. /// </summary> /// <param name="backgroundColorIndex"></param> /// <param name="colorResolution"></param> /// <param name="hasTrailer"></param> /// <param name="interlaced"></param> /// <param name="isPaletteSorted"></param> /// <param name="pixelAspectRatio"></param> /// <param name="fromScratch"></param> /// <param name="outPath"></param> /// <param name="file"></param> /// <returns></returns> public ResponseMessage PostImageGif(int? backgroundColorIndex, int? colorResolution, bool? hasTrailer, bool? interlaced, bool? isPaletteSorted, int? pixelAspectRatio, bool? fromScratch, string outPath, byte[] file) { // create path and map variables var ResourcePath = "/imaging/gif/?appSid={appSid}&backgroundColorIndex={backgroundColorIndex}&colorResolution={colorResolution}&hasTrailer={hasTrailer}&interlaced={interlaced}&isPaletteSorted={isPaletteSorted}&pixelAspectRatio={pixelAspectRatio}&fromScratch={fromScratch}&outPath={outPath}".Replace("{format}","json"); ResourcePath = Regex.Replace(ResourcePath, "\\*", "").Replace("&", "&").Replace("/?", "?").Replace("toFormat={toFormat}", "format={format}"); // query params var queryParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, object>(); // verify required params are set if (file == null ) { throw new ApiException(400, "missing required params"); } if (backgroundColorIndex == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])backgroundColorIndex=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "backgroundColorIndex" + "}", apiInvoker.ToPathValue(backgroundColorIndex)); } if (colorResolution == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])colorResolution=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "colorResolution" + "}", apiInvoker.ToPathValue(colorResolution)); } if (hasTrailer == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])hasTrailer=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "hasTrailer" + "}", apiInvoker.ToPathValue(hasTrailer)); } if (interlaced == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])interlaced=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "interlaced" + "}", apiInvoker.ToPathValue(interlaced)); } if (isPaletteSorted == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])isPaletteSorted=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "isPaletteSorted" + "}", apiInvoker.ToPathValue(isPaletteSorted)); } if (pixelAspectRatio == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])pixelAspectRatio=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "pixelAspectRatio" + "}", apiInvoker.ToPathValue(pixelAspectRatio)); } if (fromScratch == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])fromScratch=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "fromScratch" + "}", apiInvoker.ToPathValue(fromScratch)); } if (outPath == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])outPath=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "outPath" + "}", apiInvoker.ToPathValue(outPath)); } if (file != null){ if(file is byte[]) { var docFile = new FileInfo(); docFile.file = file; docFile.MimeType = "application/octet-stream"; formParams.Add("file", docFile); } else { //string paramStr = (file is DateTime) ? ((DateTime)(object)file).ToString("u") : Convert.ToString(file); string paramStr = Convert.ToString(file); formParams.Add("file", paramStr); } } try { if (typeof(ResponseMessage) == typeof(ResponseMessage)) { var response = apiInvoker.invokeBinaryAPI(basePath, ResourcePath, "POST", queryParams, null, headerParams, formParams); return (ResponseMessage) ApiInvoker.deserialize(response, typeof(ResponseMessage)); } else { var response = apiInvoker.invokeAPI(basePath, ResourcePath, "POST", queryParams, null, headerParams, formParams); if(response != null){ return (ResponseMessage) ApiInvoker.deserialize(response, typeof(ResponseMessage)); } else { return null; } } } catch (ApiException ex) { if(ex.ErrorCode == 404) { return null; } else { throw ex; } } }
/// <summary> /// Update parameters of bmp image. Update parameters of bmp image. /// </summary> /// <param name="bitsPerPixel"></param> /// <param name="horizontalResolution"></param> /// <param name="verticalResolution"></param> /// <param name="fromScratch"></param> /// <param name="outPath"></param> /// <param name="file"></param> /// <returns></returns> public ResponseMessage PostImageBmp (int? bitsPerPixel, int? horizontalResolution, int? verticalResolution, bool? fromScratch, string outPath, byte[] file) { // create path and map variables var ResourcePath = "/imaging/bmp/?appSid={appSid}&bitsPerPixel={bitsPerPixel}&horizontalResolution={horizontalResolution}&verticalResolution={verticalResolution}&fromScratch={fromScratch}&outPath={outPath}".Replace("{format}","json"); ResourcePath = Regex.Replace(ResourcePath, "\\*", "").Replace("&", "&").Replace("/?", "?").Replace("toFormat={toFormat}", "format={format}"); // query params var queryParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, object>(); // verify required params are set if (bitsPerPixel == null || horizontalResolution == null || verticalResolution == null || file == null ) { throw new ApiException(400, "missing required params"); } if (bitsPerPixel == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])bitsPerPixel=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "bitsPerPixel" + "}", apiInvoker.ToPathValue(bitsPerPixel)); } if (horizontalResolution == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])horizontalResolution=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "horizontalResolution" + "}", apiInvoker.ToPathValue(horizontalResolution)); } if (verticalResolution == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])verticalResolution=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "verticalResolution" + "}", apiInvoker.ToPathValue(verticalResolution)); } if (fromScratch == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])fromScratch=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "fromScratch" + "}", apiInvoker.ToPathValue(fromScratch)); } if (outPath == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])outPath=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "outPath" + "}", apiInvoker.ToPathValue(outPath)); } if (file != null){ if(file is byte[]) { var docFile = new FileInfo(); docFile.file = file; docFile.MimeType = "application/octet-stream"; formParams.Add("file", docFile); } else { //string paramStr = (file is DateTime) ? ((DateTime)(object)file).ToString("u") : Convert.ToString(file); string paramStr = Convert.ToString(file); formParams.Add("file", paramStr); } } try { if (typeof(ResponseMessage) == typeof(ResponseMessage)) { var response = apiInvoker.invokeBinaryAPI(basePath, ResourcePath, "POST", queryParams, null, headerParams, formParams); return (ResponseMessage) ApiInvoker.deserialize(response, typeof(ResponseMessage)); } else { var response = apiInvoker.invokeAPI(basePath, ResourcePath, "POST", queryParams, null, headerParams, formParams); if(response != null){ return (ResponseMessage) ApiInvoker.deserialize(response, typeof(ResponseMessage)); } else { return null; } } } catch (ApiException ex) { if(ex.ErrorCode == 404) { return null; } else { throw ex; } } }