Exemplo n.º 1
0
        private static void AddContactToAddressBook(ApiAddressBook addressBook)
        {
            ApiContact contact = new ApiContact
            {
                Email = string.Format("email{0}@example.com", Guid.NewGuid()),
            };

            ApiContact addedContact = _client.AddContactToAddressBook(addressBook.Id, contact);
            Console.WriteLine("Contact '{0}' has been added to address book '{1}'", addedContact.Email, addressBook.Name);
        }
Exemplo n.º 2
0
        private static ApiAddressBook CreateAddressBook()
        {
            ApiAddressBook addressBook = new ApiAddressBook
            {
                Name = Guid.NewGuid().ToString()
            };

            ApiAddressBook createdAddressBook = _client.CreateAddressBook(addressBook);
            Console.WriteLine("Address book '{0}' has been created", createdAddressBook.Name);
            return createdAddressBook;
        }
Exemplo n.º 3
0
        private static ApiAddressBook CreateAddressBook()
        {
            ApiAddressBook addressBook = new ApiAddressBook
            {
                Name = Guid.NewGuid().ToString()
            };

            HttpResponseMessage response = _client.PostAsJsonAsync("/v2/address-books", addressBook).Result;
            ApiAddressBook createdAddressBook = response.Content.ReadAsAsync<ApiAddressBook>().Result;
            Console.WriteLine("Address book '{0}' has been created", createdAddressBook.Name);
            return createdAddressBook;
        }
Exemplo n.º 4
0
        private static void AddContactToAddressBook(ApiAddressBook addressBook)
        {
            ApiContact contact = new ApiContact
            {
                Email = string.Format("email{0}@example.com", Guid.NewGuid())
            };

            string url = String.Format("v2/address-books/{0}/contacts", addressBook.Id);
            HttpResponseMessage response = _client.PostAsJsonAsync(url, contact).Result;
            ApiContact addedContact = response.Content.ReadAsAsync<ApiContact>().Result;
            Console.WriteLine("Contact '{0}' has been added to address book '{1}'", addedContact.Email, addressBook.Name);
        }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
0
        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;
        }