public void TestPutGenerateMultiple() { BarcodeApi target = new BarcodeApi(APIKEY, APPSID, BASEPATH); string name = "barcodePng.png"; string format = ""; string folder = ""; BarcodeBuilders body = new BarcodeBuilders(); BarcodeBuilder barcodeBuilder1 = new BarcodeBuilder(); barcodeBuilder1.TypeOfBarcode = "qr"; barcodeBuilder1.Text = "The Latest barcode"; BarcodeBuilder barcodeBuilder2 = new BarcodeBuilder(); barcodeBuilder2.TypeOfBarcode = "qr"; barcodeBuilder2.Text = "The Latest barcode"; body.BarcodeBuilderList = new System.Collections.Generic.List<BarcodeBuilder> { barcodeBuilder1, barcodeBuilder2 }; SaaSposeResponse actual; actual = target.PutGenerateMultiple(name, format, folder, body); Assert.AreEqual("200", actual.Code); Assert.IsInstanceOfType(new SaaSposeResponse(), actual.GetType()); }
/// <summary> /// Generate image with multiple barcodes and put new file on server Generate image with multiple barcodes and put new file on server /// </summary> /// <param name="name"></param> /// <param name="format"></param> /// <param name="folder"></param> /// <param name="file"></param> /// <returns></returns> public SaaSposeResponse PutGenerateMultiple (string name, string format, string folder, BarcodeBuilders body) { // create path and map variables var ResourcePath = "/barcode/{name}/generateMultiple/?appSid={appSid}&toFormat={toFormat}&folder={folder}".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 (name == null || body == null ) { throw new ApiException(400, "missing required params"); } if (name == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])name=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "name" + "}", apiInvoker.ToPathValue(name)); } if (format == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])format=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "format" + "}", apiInvoker.ToPathValue(format)); } if (folder == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])folder=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "folder" + "}", apiInvoker.ToPathValue(folder)); } //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(SaaSposeResponse) == typeof(ResponseMessage)) { var response = apiInvoker.invokeBinaryAPI(basePath, ResourcePath, "PUT", queryParams, null, headerParams, formParams); return (SaaSposeResponse) ApiInvoker.deserialize(response, typeof(SaaSposeResponse)); } else { var response = apiInvoker.invokeAPI(basePath, ResourcePath, "PUT", queryParams, body, headerParams, formParams); if(response != null){ return (SaaSposeResponse) ApiInvoker.deserialize(response, typeof(SaaSposeResponse)); } else { return null; } } } catch (ApiException ex) { if(ex.ErrorCode == 404) { return null; } else { throw ex; } } }
public void TestPostGenerateMultiple() { BarcodeApi target = new BarcodeApi(APIKEY, APPSID, BASEPATH); string format = "png"; BarcodeBuilders body = new BarcodeBuilders(); BarcodeBuilder barcodeBuilder1 = new BarcodeBuilder(); barcodeBuilder1.TypeOfBarcode = "qr"; barcodeBuilder1.Text = "The Latest barcode"; BarcodeBuilder barcodeBuilder2 = new BarcodeBuilder(); barcodeBuilder2.TypeOfBarcode = "qr"; barcodeBuilder2.Text = "The Latest barcode"; body.BarcodeBuilderList = new System.Collections.Generic.List<BarcodeBuilder> { barcodeBuilder1, barcodeBuilder2 }; ResponseMessage actual; actual = target.PostGenerateMultiple(format, body); Assert.AreEqual(200, actual.Code); Assert.IsInstanceOfType(new ResponseMessage(), actual.GetType()); }