예제 #1
0
        public void UpdateMember_Successful()
        {
            //  Arrange
            MailChimpManager mc    = new MailChimpManager(TestGlobal.Test_APIKey);
            ListResult       lists = mc.GetLists();
            EmailParameter   email = new EmailParameter()
            {
                Email = "*****@*****.**"
            };
            var            listId              = lists.Data[0].Id;
            MyMergeVar     mergeVar            = new MyMergeVar();
            EmailParameter subscriptionResults = mc.Subscribe(listId, email, mergeVar, "html", false, true);

            //  Act
            mergeVar.FirstName = "some name";
            mc.UpdateMember(listId, subscriptionResults, mergeVar);

            // load
            List <EmailParameter> emails = new List <EmailParameter>();

            emails.Add(email);
            MemberInfoResult memberInfos = mc.GetMemberInfo(listId, emails);

            //  Assert
            Assert.IsTrue(memberInfos.Data[0].MemberMergeInfo.ContainsKey("FNAME"));
            Assert.AreEqual("some name", memberInfos.Data[0].MemberMergeInfo["FNAME"]);
        }
예제 #2
0
        public void SubscribeWithGroupSelection_Successful()
        {
            //  Arrange
            MailChimpManager mc    = new MailChimpManager(TestGlobal.Test_APIKey);
            ListResult       lists = mc.GetLists();
            EmailParameter   email = new EmailParameter()
            {
                Email = "*****@*****.**"
            };

            // find a list with interest groups...
            string strListID    = null;
            int    nGroupingID  = 0;
            string strGroupName = null;

            foreach (ListInfo li in lists.Data)
            {
                List <InterestGrouping> interests = mc.GetListInterestGroupings(li.Id);
                if (interests != null)
                {
                    if (interests.Count > 0)
                    {
                        if (interests[0].GroupNames.Count > 0)
                        {
                            strListID    = li.Id;
                            nGroupingID  = interests[0].Id;
                            strGroupName = interests[0].GroupNames[0].Name;
                            break;
                        }
                    }
                }
            }
            Assert.IsNotNull(strListID, "no lists found in this account with groupings / group names");
            Assert.AreNotEqual(0, nGroupingID);
            Assert.IsNotNull(strGroupName);

            MyMergeVar mvso = new MyMergeVar();

            mvso.Groupings = new List <Grouping>();
            mvso.Groupings.Add(new Grouping());
            mvso.Groupings[0].Id         = nGroupingID;
            mvso.Groupings[0].GroupNames = new List <string>();
            mvso.Groupings[0].GroupNames.Add(strGroupName);
            mvso.FirstName = "Testy";
            mvso.LastName  = "Testerson";

            //  Act
            EmailParameter results = mc.Subscribe(strListID, email, mvso);

            //  Assert
            Assert.IsNotNull(results);
            Assert.IsTrue(!string.IsNullOrEmpty(results.LEId));
        }
        // POST api/mailchimp
        public string Post(Subscriber subscriber)
        {
            MailChimpManager mc = new MailChimpManager(_mailchimpKey);
            MyMergeVar myMergeVars = new MyMergeVar();
            myMergeVars.FirstName = subscriber.FirstName;
            myMergeVars.LastName = subscriber.LastName;           //  Create the email parameter
            EmailParameter email = new EmailParameter()
            {
                Email = subscriber.EmailAddress
            };

            EmailParameter results = mc.Subscribe(_mailchimpGroupId, email, myMergeVars);
            return results.LEId;
        }
예제 #4
0
        public void SubscribeWithGroupSelection_Successful()
        {
            //  Arrange
            MailChimpManager mc = new MailChimpManager(TestGlobal.Test_APIKey);
            ListResult lists = mc.GetLists();
            EmailParameter email = new EmailParameter()
            {
                Email = "*****@*****.**"
            };

            // find a list with interest groups...
            string strListID = null;
            int nGroupingID = 0;
            string strGroupName = null;
            foreach (ListInfo li in lists.Data) {
                List<InterestGrouping> interests = mc.GetListInterestGroupings(li.Id);
                if (interests != null) {
                    if (interests.Count > 0) {
                        if (interests[0].GroupNames.Count > 0) {
                            strListID = li.Id;
                            nGroupingID = interests[0].Id;
                            strGroupName = interests[0].GroupNames[0].Name;
                            break;
                        }
                    }
                }
            }
            Assert.IsNotNull(strListID,"no lists found in this account with groupings / group names");
            Assert.AreNotEqual(0,nGroupingID);
            Assert.IsNotNull(strGroupName);

            MyMergeVar mvso = new MyMergeVar();
            mvso.Groupings = new List<Grouping>();
            mvso.Groupings.Add(new Grouping());
            mvso.Groupings[0].Id = nGroupingID;
            mvso.Groupings[0].GroupNames = new List<string>();
            mvso.Groupings[0].GroupNames.Add(strGroupName);
            mvso.FirstName = "Testy";
            mvso.LastName = "Testerson";

            //  Act
            EmailParameter results = mc.Subscribe(strListID, email, mvso);

            //  Assert
            Assert.IsNotNull(results);
            Assert.IsTrue(!string.IsNullOrEmpty(results.LEId));
        }
예제 #5
0
        public void UpdateMember_Successful()
        {
            //  Arrange
            MailChimpManager mc = new MailChimpManager(TestGlobal.Test_APIKey);
            ListResult lists = mc.GetLists();
            EmailParameter email = new EmailParameter()
            {
                Email = "*****@*****.**"
            };
            var listId = lists.Data[0].Id;
            MyMergeVar mergeVar = new MyMergeVar();
            EmailParameter subscriptionResults = mc.Subscribe(listId, email, mergeVar, "html", false, true);

            //  Act
            mergeVar.FirstName = "some name";
            mc.UpdateMember(listId, subscriptionResults, mergeVar);

            // load
            List<EmailParameter> emails = new List<EmailParameter>();
            emails.Add(email);
            MemberInfoResult memberInfos = mc.GetMemberInfo(listId, emails);

            //  Assert
            Assert.IsTrue(memberInfos.Data[0].MemberMergeInfo.ContainsKey("FNAME"));
            Assert.AreEqual("some name", memberInfos.Data[0].MemberMergeInfo["FNAME"]);
        }
예제 #6
0
        public void SubscribeWithGroupSelection_Successful()
        {
            //  Arrange
            MailChimpManager mc = new MailChimpManager(TestGlobal.Test_APIKey);
            ListResult lists = mc.GetLists();
            EmailParameter email = new EmailParameter()
            {
                Email = "*****@*****.**"
            };

            // find a list with interest groups...
            string strListID = null;
            int nGroupingID = 0;
            string strGroupName = null;
            foreach (ListInfo li in lists.Data) {
                List<InterestGrouping> interests = mc.GetListInterestGroupings(li.Id);
                if (interests != null) {
                    if (interests.Count > 0) {
                        if (interests[0].GroupNames.Count > 0) {
                            strListID = li.Id;
                            nGroupingID = interests[0].Id;
                            strGroupName = interests[0].GroupNames[0].Name;
                            break;
                        }
                    }
                }
            }
            Assert.IsNotNull(strListID,"no lists found in this account with groupings / group names");
            Assert.AreNotEqual(0,nGroupingID);
            Assert.IsNotNull(strGroupName);

            MyMergeVar mvso = new MyMergeVar();
            mvso.Groupings = new List<Grouping>();
            mvso.Groupings.Add(new Grouping());
            mvso.Groupings[0].Id = nGroupingID;
            mvso.Groupings[0].GroupNames = new List<string>();
            mvso.Groupings[0].GroupNames.Add(strGroupName);
            mvso.FirstName = "Testy" + DateTime.Now;
						mvso.LastName = "Testerson" + DateTime.Now;

            //  Act
            EmailParameter results = mc.Subscribe(strListID, email, mvso, doubleOptIn:false);

            //  Assert
            Assert.IsNotNull(results);
            Assert.IsTrue(!string.IsNullOrEmpty(results.LEId));

						// load
						List<EmailParameter> emails = new List<EmailParameter>();
						emails.Add(results);
						MemberInfoResult memberInfos = mc.GetMemberInfo(strListID, emails);

						// Assert
						Assert.AreEqual(1, memberInfos.SuccessCount);
						Assert.IsTrue(memberInfos.Data[0].MemberMergeInfo.Count > 0);
						Assert.IsTrue(memberInfos.Data[0].MemberMergeInfo.ContainsKey("FNAME"));
						Assert.IsTrue(memberInfos.Data[0].MemberMergeInfo.ContainsKey("LNAME"));
						Assert.AreEqual(mvso.FirstName, memberInfos.Data[0].MemberMergeInfo["FNAME"]);
						Assert.AreEqual(mvso.LastName, memberInfos.Data[0].MemberMergeInfo["LNAME"]);
        }