Esempio n. 1
0
        public ETSubscriber AddSubscriberToLists(string email, int[] lists)
        {
            var addSubscriber = new ETSubscriber
            {
                AuthStub      = SFClient,
                SubscriberKey = email,
                EmailAddress  = email,
                Lists         = GenerateSubscriberList(lists).ToArray(),
                Attributes    = new[] { new ETProfileAttribute {
                                            Name = "Source", Value = "API"
                                        } }
            };
            var response = addSubscriber.Post();

            if (response.Status && response.Results.Length > 0)
            {
                return((ETSubscriber)response.Results[0].Object);
            }

            if (response.Results.Length > 0 && response.Results[0].ErrorCode == 12014)
            {
                UpdateSubscriber(addSubscriber);
            }

            return(null);
        }
Esempio n. 2
0
        public bool DeleteSubscriber(string email, int[] lists = null)
        {
            var deleteUser = new ETSubscriber
            {
                AuthStub      = SFClient,
                SubscriberKey = email,
                Lists         = GenerateSubscriberList(lists)
            };
            var response = deleteUser.Delete();

            return(response.Status);
        }
 public void TearDown()
 {
     if (subscriber != null)
     {
         var subsObj = new ETSubscriber
         {
             AuthStub     = client,
             EmailAddress = subsEmail,
         };
         var response = subsObj.Delete();
     }
 }
        public void SubscriberDelete()
        {
            var subsObj = new ETSubscriber
            {
                AuthStub      = client,
                SubscriberKey = subsKey
            };
            var response = subsObj.Delete();

            Assert.AreEqual(response.Code, 200);
            Assert.AreEqual(response.Status, true);
            Assert.AreEqual(response.Results[0].StatusMessage, "Subscriber deleted");
            subscriber = null;
        }
Esempio n. 5
0
        public ETSubscriber UpdateSubscriber(ETSubscriber subscriber)
        {
            if (String.IsNullOrEmpty(subscriber.SubscriberKey))
            {
                return(null);
            }

            subscriber.AuthStub = SFClient;
            var response = subscriber.Patch();

            if (response.Status && response.Results.Length > 0)
            {
                return((ETSubscriber)response.Results[0].Object);
            }

            return(null);
        }
        public void SubscriberUpdate()
        {
            var subsObj = new ETSubscriber
            {
                AuthStub      = client,
                EmailAddress  = subsEmail,
                SubscriberKey = subsKey,
                Attributes    = new[] { new ETProfileAttribute {
                                            Name = "FullName", Value = "Updated FullName"
                                        } }
            };
            var response = subsObj.Patch();

            Assert.AreEqual(response.Code, 200);
            Assert.AreEqual(response.Status, true);
            Assert.AreEqual(response.Results[0].StatusMessage, "Updated Subscriber.");
        }
        public void SubscriberGet()
        {
            var subsObj = new ETSubscriber
            {
                AuthStub     = client,
                Props        = new[] { "EmailAddress", "ID" },
                SearchFilter = new SimpleFilterPart {
                    Property = "ID", Value = new[] { subscriber.ID.ToString() }, SimpleOperator = SimpleOperators.equals
                }
            };
            var response = subsObj.Get();

            Assert.AreEqual(response.Code, 200);
            Assert.AreEqual(response.Status, true);
            var subs = (ETSubscriber)response.Results[0];

            Assert.AreEqual(subs.EmailAddress, subsEmail);
        }
Esempio n. 8
0
        public bool Resubscribe(string email, int[] lists = null)
        {
            var patchUser = new ETSubscriber
            {
                AuthStub      = SFClient,
                SubscriberKey = email,
                Lists         = GenerateSubscriberList(lists)
            };

            //Resubscribe to everything if no lists specified
            if (lists == null)
            {
                patchUser.Status = SubscriberStatus.Active;
            }

            var response = patchUser.Patch();

            return(response.Status);
        }
Esempio n. 9
0
        public ETSubscriber GetSubscriber(string email)
        {
            var getUser = new ETSubscriber
            {
                AuthStub     = SFClient,
                SearchFilter = new SimpleFilterPart
                {
                    Property       = "SubscriberKey",
                    SimpleOperator = SimpleOperators.equals,
                    Value          = new[] { email }
                }
            };
            var response = getUser.Get();

            if (response.Status && response.Results.Length > 0)
            {
                return((ETSubscriber)response.Results[0]);
            }

            return(null);
        }
Esempio n. 10
0
        public void ListSubscriberAdd()
        {
            //list is already created in the setup
            for (int i = 0; i < 10; i++)
            {
                var subsObj = new ETSubscriber
                {
                    AuthStub = client,
                    Lists    = new[] { new ETSubscriberList {
                                           ID = list.ID
                                       } },
                    EmailAddress  = string.Format("{0}@gmail.com", System.Guid.NewGuid().ToString()),
                    SubscriberKey = System.Guid.NewGuid().ToString(),
                    Status        = SubscriberStatus.Active,
                    Attributes    = new[] { new ETProfileAttribute {
                                                Name = "FullName", Value = "Test Subscriber_" + i.ToString()
                                            } }
                };

                var response = subsObj.Post();
            }

            var listsubs = new ETListSubscriber
            {
                AuthStub     = client,
                Props        = new string[] { "ObjectID", "SubscriberKey", "CreatedDate", "Client.ID", "Client.PartnerClientKey", "ListID", "Status" },
                SearchFilter = new SimpleFilterPart {
                    Property = "ListID", SimpleOperator = SimpleOperators.equals, Value = new[] { this.list.ID.ToString() }
                }
            };

            var getresponse = listsubs.Get();

            Assert.AreEqual(getresponse.Code, 200);
            Assert.AreEqual(getresponse.Status, true);
            var getlist = (ETListSubscriber)getresponse.Results[0];

            Assert.AreEqual(getresponse.Results.Length, 10);
        }
Esempio n. 11
0
        public void Setup()
        {
            subsEmail = "*****@*****.**";
            subsKey   = System.Guid.NewGuid().ToString();

            var subsObj = new ETSubscriber
            {
                AuthStub      = client,
                EmailAddress  = subsEmail,
                SubscriberKey = subsKey,
                Status        = SubscriberStatus.Active,
                Attributes    = new[] { new ETProfileAttribute {
                                            Name = "FullName", Value = "Test Subscriber"
                                        } }
            };

            var response = subsObj.Post();

            Assert.AreEqual(response.Code, 200);
            Assert.AreEqual(response.Status, true);
            subscriber = (ETSubscriber)response.Results[0].Object;
        }