public JsonResult Get() { var filename = "testbarcode.png"; var version = GetType().Assembly.GetName().Version; var barcodeConfig = new Aspose.BarCode.Cloud.Sdk.Api.Configuration() { AppKey = _configuration.GetValue <string>("Settings:AsposeCloudAppKey"), AppSid = _configuration.GetValue <string>("Settings:AsposeCloudAppSid") }; barcodeConfig.DefaultHeaders.Add(AsposeClientHeaderName, "test proxy app"); barcodeConfig.DefaultHeaders.Add(AsposeClientVersionHeaderName, $"{version.Major}.{version.Minor}"); IBarcodeApi barcodeApi = new Aspose.BarCode.Cloud.Sdk.Api.BarcodeApi(barcodeConfig); var groupdocsConfig = new GroupDocs.Conversion.Cloud.Sdk.Client.Configuration( _configuration.GetValue <string>("Settings:GroupdocsCloudAppSid"), _configuration.GetValue <string>("Settings:GroupdocsCloudAppKey")); var infoApi = new InfoApi(groupdocsConfig); var barcodeResponse = barcodeApi.PutBarcodeGenerateFile(new Aspose.BarCode.Cloud.Sdk.Model.Requests.PutBarcodeGenerateFileRequest( text: "TEST", type: "qr", format: "PNG", textLocation: "None", name: filename, storage: null, folder: null)); var supportedFileFormatsResponse = infoApi.GetSupportedConversionTypes(new GetSupportedConversionTypesRequest(format: System.IO.Path.GetExtension(filename)?.Trim('.'))); return(new JsonResult(new { filename = filename, width = barcodeResponse.ImageWidth, height = barcodeResponse.ImageHeight, canBeConvertedTo = supportedFileFormatsResponse != null && supportedFileFormatsResponse.Any() ? supportedFileFormatsResponse[0].TargetFormats : null })); }
public void GetSupportedConversionTypesTest() { var response = InfoApi.GetSupportedConversionTypes(new GetSupportedConversionTypesRequest()); Assert.IsTrue(response.Count > 0); foreach (var entry in response) { Assert.IsNotEmpty(entry.SourceFormat); Assert.IsTrue(entry.TargetFormats.Count > 0); } }
public void AuthErrorWhenAppSidNotFoundTest() { var appSid = "test"; var appKey = "test"; var conversionConfig = new Configuration(appSid, appKey) { ApiBaseUrl = Config.ApiBaseUrl }; var infoApi = new InfoApi(conversionConfig); var ex = Assert.Throws <ApiException>(() => { infoApi.GetSupportedConversionTypes(new GetSupportedConversionTypesRequest()); }); Assert.AreEqual("invalid_client", ex.Message); }
public static void Run() { var apiInstance = new InfoApi(Constants.GetConfig()); try { // Get supported conversion types var response = apiInstance.GetSupportedConversionTypes(new GetSupportedConversionTypesRequest()); foreach (var entry in response.Take(2)) { Console.WriteLine($"{entry.SourceFormat}: {string.Join(",", entry.TargetFormats)}"); } Console.WriteLine($"..."); } catch (Exception e) { Console.WriteLine("Exception while calling InfoApi: " + e.Message); } }
public static void Run() { var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey); var apiInstance = new InfoApi(configuration); try { // Get supported file formats var response = apiInstance.GetSupportedConversionTypes(new GetSupportedConversionTypesRequest()); foreach (var entry in response) { foreach (var formats in entry.TargetFormats) { Console.WriteLine(string.Format("{0} TO {1}", entry.SourceFormat, string.Join(",", formats))); } } } catch (Exception e) { Console.WriteLine("Exception while calling InfoApi: " + e.Message); } }