public CampaignAddResult AddCampaign(CampaignAddRequest campaignToAdd) { campaignToAdd.ApiKey = this._apiKey; var url = $"{this._baseUrl}/campaigns/addCampaign/"; var xml = this._parser.Serialize <CampaignAddRequest>(campaignToAdd); var httpResponse = this._httpClient.Request(url, xml); if (httpResponse.Status != HttpStatus.Successful) { return(new CampaignAddResult { Status = Status.Error, Message = "Http error" }); } var result = this._parser.Deserialize <CampaignAddResult>(httpResponse.Result); return(result); }
public void SerializeAddCampaignRequest() { IXmlParser xmlParser = new DefaultXmlParser(); var request = new CampaignAddRequest { ApiKey = "44-121312131223", GroupId = 432, NewsletterId = 313, CampaignName = "Sample Campaign", SenderName = "My Name", SenderEmail = "*****@*****.**", Subject = "Welcome to my newsletter", StartDate = new DateTime(2014, 6, 1, 12, 0, 0) }; var requestXml = xmlParser.Serialize(request); var xml = File.ReadAllText("AddCampaignRequest.xml"); Assert.AreEqual(xml, requestXml); }