Exemplo n.º 1
0
        private void frmEmailCampaign_Load(object sender, EventArgs e)
        {
            try
            {
                string state = "ok";
                _accessToken = OAuth.AuthenticateFromWinProgram(ref state);

                if (string.IsNullOrEmpty(_accessToken))
                {
                    Application.Exit();
                }

                //initialize ConstantContact member
                _constantContact = new ConstantContact(_apiKey, _accessToken);
            }
            catch (OAuth2Exception oauthEx)
            {
                MessageBox.Show(string.Format("Authentication failure: {0}", oauthEx.Message), "Warning");
            }

            PopulateCampaignTypeList();
            PopulateListOfCountries();
            PopulateUSAndCanadaListOfStates();

            GetListOfContacts();
            PopulateEmailLists();
        }
Exemplo n.º 2
0
        public void LiveVerifiedEmailAddressTest()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);
            var list = cc.GetVerifiedEmailAddress();

            Assert.IsNotNull(list);
            Assert.AreNotEqual(0, list.Count);
        }
Exemplo n.º 3
0
        public void LiveActivityExportContactsTest()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);
            var lists = new List<string>() { "1" };

            ExportContacts export = new ExportContacts();
            export.Lists = lists;

            Activity activity = cc.AddExportContactsActivity(export);

            Assert.IsNotNull(activity);
            Assert.IsNotNull(activity.Id);
            Assert.AreEqual(activity.Type, "EXPORT_CONTACTS");
        }
Exemplo n.º 4
0
		public void GetLibraryInfoTest()
		{
			var cc = new ConstantContact(ApiKey, AccessToken);

			var result = cc.GetLibraryInfo();
			Assert.IsNotNull(result);
			Assert.IsNotNull(result.UsageSummary);
		}
Exemplo n.º 5
0
        public void LiveActivityClearListTest()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);
            var emailAddresses = new List<string> { String.Format("{0}@example.com", Guid.NewGuid()) };
            var lists = new List<string> { "2" };

            var add = new AddContacts(
                new List<AddContactsImportData>{
                    new AddContactsImportData{
                        EmailAddresses = emailAddresses
                    }
                },
                lists,
                null
                );
            Activity act = cc.CreateAddContactsActivity(add);
            Assert.IsNotNull(act);

            Activity activity = cc.AddClearListsActivity(lists);

            Assert.IsNotNull(activity);
            Assert.AreEqual(activity.Type, "CLEAR_CONTACTS_FROM_LISTS");
        }
Exemplo n.º 6
0
        public void LiveDeleteContactListTest()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);

            var contactList = new ContactList
            {
                Name = string.Format("List {0}", Guid.NewGuid()),
                Status = Status.Active
            };

            var result = cc.AddList(contactList);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Name.Equals(contactList.Name));

            result.Name = string.Format("List - {0}", Guid.NewGuid());

            var deleted = cc.DeleteList(result.Id.ToString(CultureInfo.InvariantCulture));
            Assert.IsTrue(deleted);
        }
Exemplo n.º 7
0
		public void LiveDeleteFolderTest()
		{
			var cc = new ConstantContact(ApiKey, AccessToken);

            var folder = new MyLibraryFolder();
			folder.Id = Guid.NewGuid().ToString();
			folder.Name = Guid.NewGuid().ToString();
			folder.CreatedDate = Extensions.ToISO8601String(DateTime.Now);
            folder.ModifiedDate = Extensions.ToISO8601String(DateTime.Now);

			var newFolder = cc.AddLibraryFolder(folder);
			bool result = cc.DeleteLibraryFolder(newFolder.Id);
			Assert.IsTrue(result);
		}
Exemplo n.º 8
0
        public void LiveGetContactByEmail()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);

            var contact = new Contact();
            contact.EmailAddresses.Add(new EmailAddress { EmailAddr = String.Format("{0}@email.com", Guid.NewGuid()), ConfirmStatus = ConfirmStatus.NoConfirmationRequired, Status = Status.Active });
            contact.Lists.Add(new ContactList { Id = "1", Status = Status.Active });

            Contact nc = cc.AddContact(contact, false);
            Assert.IsNotNull(nc);
            Assert.IsNotNull(nc.Id);

            var result = cc.GetContacts(nc.EmailAddresses[0].EmailAddr, 1, DateTime.Now.AddMonths(-1));
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Results);
            Assert.AreEqual(1, result.Results.Count);
        }
Exemplo n.º 9
0
        public void LiveGetContactFromListTest()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);

            IList<ContactList> lists = cc.GetLists(DateTime.Now.AddMonths(-1));
            Assert.IsNotNull(lists);
            Assert.AreNotEqual(0, lists.Count);

            ResultSet<Contact> contacts = cc.GetContactsFromList(lists[0].Id, DateTime.Now.AddMonths(-1));
            Assert.IsNotNull(contacts);
            Assert.IsNotNull(contacts.Results);

            contacts = cc.GetContactsFromList(lists[0].Id, 3, DateTime.Now.AddMonths(-1));
            Assert.IsNotNull(contacts);
            Assert.IsNotNull(contacts.Meta);
            Assert.IsNotNull(contacts.Meta.Pagination);
            Assert.IsNotNull(contacts.Meta.Pagination.Next);
            Assert.IsNotNull(contacts.Results);
            Assert.AreEqual(3, contacts.Results.Count);

            contacts = cc.GetContactsFromList(DateTime.Now.AddMonths(-1), contacts.Meta.Pagination);
            Assert.IsNotNull(contacts);
            Assert.IsNotNull(contacts.Meta);
            Assert.IsNotNull(contacts.Meta.Pagination);
            Assert.IsNotNull(contacts.Meta.Pagination.Next);
            Assert.IsNotNull(contacts.Results);
            Assert.AreEqual(3, contacts.Results.Count);
        }
Exemplo n.º 10
0
        public void LiveEmailCampaignTestSendTest()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);

            var camp = new EmailCampaign
            {
                EmailContent = "<html><body>EMAIL CONTENT.</body></html>",
                Subject = "campaign subject",
                FromName = "my company",
                FromEmail = CustomerEmail,
                ReplyToEmail = CustomerEmail,
                Name = "campaign_" + DateTime.Now.ToString("yyMMddHHmmss"),
                TextContent = "email campaign text content",
                GreetingString = "Dear ",
                //TemplateType = TemplateType.CUSTOM,
                Status = CampaignStatus.DRAFT,
                EmailContentFormat = CampaignEmailFormat.HTML,
                StyleSheet = "",
                MessageFooter = new MessageFooter
                {
                    OrganizationName = "my organization",
                    AddressLine1 = "123 Mapple Street",
                    AddressLine2 = "Suite 1",
                    AddressLine3 = "",
                    City = "Boston",
                    State = "MA",
                    PostalCode = "02101",
                    Country = "US",
                    IncludeForwardEmail = true,
                    ForwardEmailLinkText = "forward link",
                    IncludeSubscribeLink = true,
                    SubscribeLinkText = "subscribe link"
                }
                ,
                Lists = new List<SentContactList> { new SentContactList { Id = "1" } }
            };
            camp = cc.AddCampaign(camp);
            Assert.IsNotNull(camp);
            Assert.IsNotNull(camp.Id);

            var test = new TestSend { 
                Format = EmailFormat.HTML_AND_TEXT.ToString(),
                PersonalMessage = "This is a test send of the email campaign message.",
                EmailAddresses = new List<string> { CustomerEmail }
            };

            var testSend = cc.SendTest(camp.Id, test);

            Assert.IsNotNull(testSend);
            Assert.AreEqual(test.Format, testSend.Format);
        }
Exemplo n.º 11
0
        public void LiveUpdateContactTest()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);

            var contact = new Contact();
            contact.EmailAddresses.Add(new EmailAddress { EmailAddr = String.Format("{0}@email.com", Guid.NewGuid()), ConfirmStatus = ConfirmStatus.NoConfirmationRequired, Status = Status.Active });
            contact.Lists.Add(new ContactList { Id = "1", Status = Status.Active });

            var nc = cc.AddContact(contact, false);
            Assert.IsNotNull(nc);
            Assert.IsNotNull(nc.Id);

            nc.CompanyName = "some company";

            var retrievedContact = cc.UpdateContact(nc, false);

            Assert.IsNotNull(retrievedContact);
            Assert.AreEqual(retrievedContact.Id, nc.Id);
            Assert.AreEqual(retrievedContact.CompanyName, nc.CompanyName);
        }
Exemplo n.º 12
0
        public void LiveCampaignTrackingGetClicksTest()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);

            var camp = CreateTestCampaign(cc);

            ResultSet<ClickActivity> result = cc.GetCampaignTrackingClicks(camp.Id, "1", null, DateTime.Now.AddMonths(-1));

            Assert.IsNotNull(result);
        }
Exemplo n.º 13
0
        private EmailCampaign CreateTestCampaign(ConstantContact cc)
        {
            var camp = new EmailCampaign
            {
                EmailContent = "<html><body>EMAIL CONTENT.</body></html>",
                Subject = "campaign subject",
                FromName = "my company",
                FromEmail = CustomerEmail,
                ReplyToEmail = CustomerEmail,
                Name = "campaign_" + DateTime.Now.ToString("yyMMddHHmmss"),
                TextContent = "email campaign text content",
                GreetingString = "Dear ",
                Status = CampaignStatus.DRAFT,
                EmailContentFormat = CampaignEmailFormat.HTML,
                StyleSheet = "",
                MessageFooter = new MessageFooter
                {
                    OrganizationName = "my organization",
                    AddressLine1 = "123 Mapple Street",
                    AddressLine2 = "Suite 1",
                    AddressLine3 = "",
                    City = "Boston",
                    State = "MA",
                    PostalCode = "02101",
                    Country = "US",
                    IncludeForwardEmail = true,
                    ForwardEmailLinkText = "forward link",
                    IncludeSubscribeLink = true,
                    SubscribeLinkText = "subscribe link"
                }
                ,
                Lists = new List<SentContactList> { new SentContactList { Id = "1" } }
            };
            camp = cc.AddCampaign(camp);
            Assert.IsNotNull(camp);
            Assert.IsNotNull(camp.Id);

            DateTime schDate = DateTime.Now.AddDays(1);
            Schedule schedule = cc.AddSchedule(camp.Id, new Schedule { ScheduledDate = schDate });
            Assert.IsNotNull(schedule);
            Assert.AreNotEqual(0, schedule.Id);
            Assert.IsNotNull(schedule.ScheduledDate);

            return camp;
        }
Exemplo n.º 14
0
		public void LiveGetFilesByFolderTest()
		{
			var cc = new ConstantContact(ApiKey, AccessToken);

            var folders = cc.GetLibraryFolders();
            Assert.IsNotNull(folders);
            Assert.IsNotNull(folders.Results);
            Assert.AreNotEqual(0, folders.Results.Count);

			var files = cc.GetLibraryFilesByFolder(folders.Results[0].Id);
			Assert.IsNotNull(files);
            Assert.IsNotNull(files.Results);
		}
Exemplo n.º 15
0
		public void LiveDeleteTrashFilesTest()
		{
			var cc = new ConstantContact(ApiKey, AccessToken);

			var result = cc.DeleteLibraryTrashFiles();
			Assert.IsTrue(result);
		}
Exemplo n.º 16
0
		public void LiveGetTrashTest()
		{
			var cc = new ConstantContact(ApiKey, AccessToken);

			var files = cc.GetLibraryTrashFiles();
			Assert.IsNotNull(files);
			Assert.IsNotNull(files.Results);
            //Assert.AreNotEqual(0, files.Results.Count);
		}
Exemplo n.º 17
0
        public void LiveActivityGetSummaryReportTest()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);
            var add = new AddContacts(
                new List<AddContactsImportData>{
                    new AddContactsImportData{
                        EmailAddresses = new List<string>{ String.Format("{0}@example.com", Guid.NewGuid()) }
                    }
                },
                new List<string> { "1" },
                null
                );
            Activity act = cc.CreateAddContactsActivity(add);
            Assert.IsNotNull(act);

            IList<Activity> list = cc.GetActivities();
            foreach (Activity activity in list)
            {
                Activity a = cc.GetActivity(activity.Id);
                Assert.IsNotNull(a);
            }
        }
Exemplo n.º 18
0
        public void LiveContactTrackingSummaryTest()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);

            ResultSet<Contact> contacts = cc.GetContacts(DateTime.Now.AddMonths(-1));
            Assert.IsNotNull(contacts);
            Assert.IsNotNull(contacts.Results);
            Assert.IsTrue(contacts.Results.Count > 0);

            TrackingSummary summary = cc.GetContactTrackingSummary(contacts.Results[0].Id);
            Assert.IsNotNull(summary);
            //Assert.AreNotEqual(0, summary.Forwards);
            //Assert.AreNotEqual(0, summary.Opens);
            //Assert.AreNotEqual(0, summary.Sends);

            IList<EmailCampaign> camps = cc.GetCampaigns(DateTime.Now.AddMonths(-1));
            summary = cc.GetCampaignTrackingSummary(camps[1].Id);
            //Assert.AreNotEqual(0, summary.Forwards);
            //Assert.AreNotEqual(0, summary.Opens);
            //Assert.AreNotEqual(0, summary.Sends);
            //Assert.AreNotEqual(0, summary.Bounces);
        }
Exemplo n.º 19
0
        public void LiveGetAllContacts()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);

            var result = cc.GetContacts(DateTime.Now.AddMonths(-1));
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Results);
            Assert.AreNotEqual(0, result.Results.Count);
        }
Exemplo n.º 20
0
        public void LiveContactTrackingForwardsTest()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);

            ResultSet<Contact> contacts = cc.GetContacts(DateTime.Now.AddMonths(-1));
            Assert.IsNotNull(contacts);
            Assert.IsNotNull(contacts.Results);
            Assert.IsTrue(contacts.Results.Count > 0);

            ResultSet<ForwardActivity> fa = cc.GetContactTrackingForwards(contacts.Results[0].Id, DateTime.Now.AddMonths(-1));
            Assert.IsNotNull(fa);
        }
Exemplo n.º 21
0
        public void LiveAddContactListTest()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);

            ContactList contactList = new ContactList { 
                Name = string.Format("List {0}", Guid.NewGuid()),
                Status = Status.Active
            };

            var result = cc.AddList(contactList);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Name.Equals(contactList.Name));
        }
Exemplo n.º 22
0
        public void LiveCampaignTrackingGetSummaryTest()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);

            var camp = new EmailCampaign
            {
                EmailContent = "<html><body>EMAIL CONTENT.</body></html>",
                Subject = "campaign subject",
                FromName = "my company",
                FromEmail = CustomerEmail,
                ReplyToEmail = CustomerEmail,
                Name = "campaign_" + DateTime.Now.ToString("yyMMddHHmmss"),
                TextContent = "email campaign text content",
                GreetingString = "Dear ",
                //TemplateType = TemplateType.CUSTOM,
                Status = CampaignStatus.DRAFT,
                EmailContentFormat = CampaignEmailFormat.HTML,
                StyleSheet = "",
                MessageFooter = new MessageFooter
                {
                    OrganizationName = "my organization",
                    AddressLine1 = "123 Mapple Street",
                    AddressLine2 = "Suite 1",
                    AddressLine3 = "",
                    City = "Boston",
                    State = "MA",
                    PostalCode = "02101",
                    Country = "US",
                    IncludeForwardEmail = true,
                    ForwardEmailLinkText = "forward link",
                    IncludeSubscribeLink = true,
                    SubscribeLinkText = "subscribe link"
                }
                ,
                Lists = new List<SentContactList> { new SentContactList { Id = "1" } }
            };
            camp = cc.AddCampaign(camp);
            Assert.IsNotNull(camp);
            Assert.IsNotNull(camp.Id);

            TrackingSummary summary = cc.GetCampaignTrackingSummary(camp.Id);

            Assert.IsNotNull(summary);
        }
Exemplo n.º 23
0
        public void LiveUpdateContactListTest()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);

            var contactList = new ContactList
                {
                Name = string.Format("List {0}", Guid.NewGuid()),
                Status = Status.Active
            };

            var result = cc.AddList(contactList);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Name.Equals(contactList.Name));

            result.Name = string.Format("List - {0}", Guid.NewGuid());

            var updatedList = cc.UpdateList(result);
            Assert.IsNotNull(updatedList);
            Assert.AreEqual(result.Id, updatedList.Id);
            Assert.AreEqual(result.Name, updatedList.Name);
        }
Exemplo n.º 24
0
        public void LiveCampaignTrackingGetOpensTest()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);

           var camp = new EmailCampaign
            {
                EmailContent = "<html><body>EMAIL CONTENT.</body></html>",
                Subject = "campaign subject",
                FromName = "my company",
                FromEmail = CustomerEmail,
                ReplyToEmail = CustomerEmail,
                Name = "campaign_" + DateTime.Now.ToString("yyMMddHHmmss"),
                TextContent = "email campaign text content",
                GreetingString = "Dear ",
                Status = CampaignStatus.DRAFT,
                EmailContentFormat = CampaignEmailFormat.HTML,
                StyleSheet = "",
                MessageFooter = new MessageFooter
                {
                    OrganizationName = "my organization",
                    AddressLine1 = "123 Mapple Street",
                    AddressLine2 = "Suite 1",
                    AddressLine3 = "",
                    City = "Boston",
                    State = "MA",
                    PostalCode = "02101",
                    Country = "US",
                    IncludeForwardEmail = true,
                    ForwardEmailLinkText = "forward link",
                    IncludeSubscribeLink = true,
                    SubscribeLinkText = "subscribe link"
                }
                ,
                Lists = new List<SentContactList> { new SentContactList { Id = "1" } }
            };
            camp = cc.AddCampaign(camp);
            Assert.IsNotNull(camp);
            Assert.IsNotNull(camp.Id);

            DateTime schDate = DateTime.Now;
            Schedule schedule = cc.AddSchedule(camp.Id, new Schedule { ScheduledDate = schDate });
            Assert.IsNotNull(schedule);
            Assert.AreNotEqual(0, schedule.Id);
            Assert.IsNotNull(schedule.ScheduledDate);

            ResultSet<OpenActivity> result = cc.GetCampaignTrackingOpens(camp.Id, null, DateTime.Now.AddMonths(-1));

            Assert.IsNotNull(result);
        }
Exemplo n.º 25
0
        public void LiveContactTrackingUnsubscribesTest()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);

            ResultSet<Contact> contacts = cc.GetContacts(DateTime.Now.AddMonths(-1));
            Assert.IsNotNull(contacts);
            Assert.IsNotNull(contacts.Results);
            Assert.IsTrue(contacts.Results.Count > 0);

            ResultSet<OptOutActivity> a = cc.GetContactTrackingOptOuts(contacts.Results[0].Id, DateTime.Now.AddMonths(-1));
            Assert.IsNotNull(a);
        } 
Exemplo n.º 26
0
		public void LiveGetFolderTest()
		{
			var cc = new ConstantContact(ApiKey, AccessToken);

            var folder = new MyLibraryFolder();
			folder.Id = Guid.NewGuid().ToString();
			folder.Name = Guid.NewGuid().ToString();
			folder.CreatedDate = Extensions.ToISO8601String(DateTime.Now);
            folder.ModifiedDate = Extensions.ToISO8601String(DateTime.Now);

			var newFolder = cc.AddLibraryFolder(folder);
			var getFolder = cc.GetLibraryFolder(newFolder.Id);

            Assert.IsNotNull(getFolder);
			Assert.AreEqual(getFolder.Id, newFolder.Id);
			Assert.AreEqual(getFolder.Name, newFolder.Name);
		}
Exemplo n.º 27
0
        public void LiveAddContactTest()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);

            var contact = new Contact();
            contact.EmailAddresses.Add(new EmailAddress { EmailAddr = String.Format("{0}@email.com", Guid.NewGuid()), ConfirmStatus = ConfirmStatus.NoConfirmationRequired, Status = Status.Active });
            contact.Lists.Add(new ContactList { Id = "1", Status = Status.Active });

            var nc = cc.AddContact(contact, false);
            Assert.IsNotNull(nc);
            Assert.IsNotNull(nc.Id);
        }
Exemplo n.º 28
0
 public void LiveActivityAddContactTest()
 {
     var cc = new ConstantContact(ApiKey, AccessToken);
     var add = new AddContacts(
         new List<AddContactsImportData>{
             new AddContactsImportData{
                 EmailAddresses = new List<string>{ String.Format("{0}@example.com", Guid.NewGuid()) }
             }
         },
         new List<string> { "1" },
         null
         );
     var act = cc.CreateAddContactsActivity(add);
     Assert.IsNotNull(act);
 }
Exemplo n.º 29
0
        public void LiveActivityRemoveContactTest()
        {
            var cc = new ConstantContact(ApiKey, AccessToken);
            var emailAddresses = new List<string>{ String.Format("{0}@example.com", Guid.NewGuid()) };
            var lists = new List<string> { "2" };

            var add = new AddContacts(
                new List<AddContactsImportData>{
                    new AddContactsImportData{
                        EmailAddresses = emailAddresses
                    }
                },
                lists,
                null
                );
            Activity act = cc.CreateAddContactsActivity(add);
            Assert.IsNotNull(act);

            Activity activity = cc.AddRemoveContactsFromListsActivity(emailAddresses, lists);

            Assert.IsNotNull(activity);
            Assert.AreEqual(activity.ContactCount, emailAddresses.Count);
        }
Exemplo n.º 30
0
		public void LiveActivityRemoveContactsMultipartTest()
		{
			var cc = new ConstantContact(ApiKey, AccessToken);

			var filename = "remove_contacts.csv";
			var fileContent = String.Format("{0}@example.com", Guid.NewGuid());
			var content = Encoding.UTF8.GetBytes(fileContent);
			var lists = new List<string>() { "1" };

			 var add = new AddContacts(
                new List<AddContactsImportData>{
                    new AddContactsImportData{
                        EmailAddresses = new List<string> { fileContent }
                    }
                },
                lists,
                null
                );

            Activity act = cc.CreateAddContactsActivity(add);
			Activity activity = cc.RemoveContactsMultipartActivity(filename, content, lists);

			Assert.IsNotNull(activity);
			Assert.IsNotNull(activity.Id);
			Assert.AreEqual(activity.ContactCount, 1);
			Assert.AreEqual(activity.Type, "REMOVE_CONTACTS_FROM_LISTS");		
		}