コード例 #1
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);
        }
コード例 #2
0
        public List <ETListSubscriber> GetSubscriberLists(string email)
        {
            var getLists = new ETListSubscriber
            {
                AuthStub     = SFClient,
                SearchFilter = new SimpleFilterPart
                {
                    Property       = "SubscriberKey",
                    SimpleOperator = SimpleOperators.equals,
                    Value          = new[] { email }
                }
            };

            var response = getLists.Get();

            if (response.Status && response.Results.Length > 0)
            {
                Array conversionArray = Array.CreateInstance(typeof(ETListSubscriber), response.Results.Length);
                Array.Copy(response.Results, conversionArray, response.Results.Length);
                return(new List <ETListSubscriber>((ETListSubscriber[])conversionArray));
            }
            return(null);
        }