public void TestPutSetEmailProperty() { EmailApi target = new EmailApi(APIKEY, APPSID, BASEPATH); StorageApi storageApi = new StorageApi(APIKEY, APPSID, BASEPATH); string name = "email_test.eml"; string propertyName = "Body"; string storage = null; string folder = null; EmailProperty body = new EmailProperty(); body.Name = "Subject"; body.Value = "This is the subject"; storageApi.PutCreate(name, null, null, System.IO.File.ReadAllBytes("\\temp\\email\\resources\\" + name)); EmailPropertyResponse actual; actual = target.PutSetEmailProperty(name, propertyName, storage, folder, body); Assert.AreEqual("200", actual.Code); Assert.IsInstanceOfType(new EmailPropertyResponse(), actual.GetType()); }
/// <summary> /// Set document property. Set document property. /// </summary> /// <param name="name"></param> /// <param name="propertyName"></param> /// <param name="storage"></param> /// <param name="folder"></param> /// <param name="body"></param> /// <returns></returns> public EmailPropertyResponse PutSetEmailProperty (string name, string propertyName, string storage, string folder, EmailProperty body) { // create path and map variables var ResourcePath = "/email/{name}/properties/{propertyName}/?appSid={appSid}&storage={storage}&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 || propertyName == 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 (propertyName == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])propertyName=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "propertyName" + "}", apiInvoker.ToPathValue(propertyName)); } if (storage == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])storage=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "storage" + "}", apiInvoker.ToPathValue(storage)); } if (folder == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])folder=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "folder" + "}", apiInvoker.ToPathValue(folder)); } try { if (typeof(EmailPropertyResponse) == typeof(ResponseMessage)) { var response = apiInvoker.invokeBinaryAPI(basePath, ResourcePath, "PUT", queryParams, null, headerParams, formParams); return (EmailPropertyResponse) ApiInvoker.deserialize(response, typeof(EmailPropertyResponse)); } else { var response = apiInvoker.invokeAPI(basePath, ResourcePath, "PUT", queryParams, body, headerParams, formParams); if(response != null){ return (EmailPropertyResponse) ApiInvoker.deserialize(response, typeof(EmailPropertyResponse)); } else { return null; } } } catch (ApiException ex) { if(ex.ErrorCode == 404) { return null; } else { throw ex; } } }
public void TestPutCreateNewEmail() { EmailApi target = new EmailApi(APIKEY, APPSID, BASEPATH); StorageApi storageApi = new StorageApi(APIKEY, APPSID, BASEPATH); string name = "email_test.eml"; string storage = null; string folder = null; EmailDocument body = new EmailDocument(); EmailProperties emailProperties = new EmailProperties(); System.Collections.Generic.List<Link> links = new System.Collections.Generic.List<Link> { }; System.Collections.Generic.List<EmailProperty> empProps = new System.Collections.Generic.List<EmailProperty> { }; Link link = new Link(); link.Href = "http://api.aspose.com/v1.1/pdf/"; link.Rel = "self"; link.Title = "NewField"; link.Type = "link"; links.Add(link); EmailProperty emailBody = new EmailProperty(); EmailProperty emailTo = new EmailProperty(); EmailProperty emailFrom = new EmailProperty(); emailBody.Name = "Body"; emailBody.Value = "This is the Body"; emailBody.Link = link; empProps.Add(emailBody); emailTo.Name = "To"; emailTo.Value = "*****@*****.**"; emailTo.Link = link; empProps.Add(emailTo); emailFrom.Name = "From"; emailFrom.Value = "*****@*****.**"; emailFrom.Link = link; empProps.Add(emailFrom); emailProperties.List = empProps; emailProperties.Link = link; body.DocumentProperties = emailProperties; body.Links = links; storageApi.PutCreate(name, null, null, System.IO.File.ReadAllBytes("\\temp\\email\\resources\\" + name)); EmailDocumentResponse actual; actual = target.PutCreateNewEmail(name, storage, folder, body); Assert.AreEqual("200", actual.Code); Assert.IsInstanceOfType(new EmailDocumentResponse(), actual.GetType()); }