private static void AttachDocument(ApiCampaign campaign, ApiDocument document) { String url = String.Format("v2/campaigns/{0}/attachments", campaign.Id); HttpResponseMessage response = _client.PostAsJsonAsync(url, document).Result; if (response.StatusCode != HttpStatusCode.NoContent) { throw new ApplicationException("Can't attach document to campaign"); } }
private static ApiCampaign CreateCampaign() { ApiCampaign campaign = new ApiCampaign { Name = "My campaign", Subject = "Subject", FromName = "Friendly name", HtmlContent = "<a href=\"http://$UNSUB$\">Unsubscribe</a>", PlainTextContent = "Unsubscribe $UNSUB$" }; ApiCampaign createdCampaign = _client.CreateCampaign(campaign); Console.WriteLine("Campaign '{0}' has been created", createdCampaign.Name); return createdCampaign; }
private static ApiCampaign CreateCampaign() { ApiCampaign campaign = new ApiCampaign { Name = "My campaign", Subject = "Subject", FromName = "Friendly name", HtmlContent = "<a href=\"http://$UNSUB$\">Unsubscribe</a>", PlainTextContent = "Unsubscribe $UNSUB$" }; HttpResponseMessage response = _client.PostAsJsonAsync("/v2/campaigns", campaign).Result; ApiCampaign createdCampaign = response.Content.ReadAsAsync<ApiCampaign>().Result; Console.WriteLine("Campaign '{0}' has been created", createdCampaign.Name); return createdCampaign; }
private static void AttachDocument(ApiCampaign campaign, ApiDocument document) { _client.AttachDocumentToCampaign(campaign.Id, document); }
private static ApiCampaignSend SendCampaignToAddressBook(ApiCampaign campaign, ApiAddressBook addressBook) { ApiCampaignSend campaignSend = new ApiCampaignSend { CampaignId = campaign.Id, AddressBookIds = new[] { addressBook.Id } }; ApiCampaignSend sendResult = _client.SendCampaign(campaignSend); Console.WriteLine("Campaign '{0}' has been sended to address book '{1}'", campaign.Name, addressBook.Name); return sendResult; }
private static void PrintCampaingSummary(ApiCampaign campaign) { ApiCampaignSummary summary = _client.GetCampaignSummary(campaign.Id); Console.WriteLine("Campaign has been sended {0} times", summary.NumSent); }
private static ApiCampaignSend SendCampaignToAddressBook(ApiCampaign campaign, ApiAddressBook addressBook) { ApiCampaignSend campaignSend = new ApiCampaignSend { CampaignId = campaign.Id, AddressBookIds = new[] { addressBook.Id } }; HttpResponseMessage response = _client.PostAsJsonAsync("/v2/campaigns/send", campaignSend).Result; ApiCampaignSend sendResult = response.Content.ReadAsAsync<ApiCampaignSend>().Result; Console.WriteLine("Campaign '{0}' has been sended to address book '{1}'", campaign.Name, addressBook.Name); return sendResult; }
private static void PrintCampaingSummary(ApiCampaign campaign) { String url = String.Format("v2/campaigns/{0}/summary", campaign.Id); HttpResponseMessage response = _client.GetAsync(url).Result; Dictionary<String, String> summary = response.Content.ReadAsAsync<Dictionary<String, String>>().Result; Console.WriteLine("Campaign has been sended {0} times", summary["numSent"]); }