Example #1
0
        public void CanCreateUpdateAndRetrieveSubscriber()
        {
            var expected = subscriberFactoryFixture.CreateComplexUniqueModifyDripSubscriber();

            var result = dripClientFixture.Client.CreateOrUpdateSubscriber(expected);

            DripAssert.Success(result, HttpStatusCode.OK);

            result = dripClientFixture.Client.GetSubscriber(expected.Email);
            DripAssert.Success(result, HttpStatusCode.OK);
            Assert.Equal(1, result.Subscribers.Count);

            var actual = result.Subscribers.First();

            DripAssert.Equal(expected.CustomFields, actual.CustomFields);
            DripAssert.ContainsSameItems(expected.Tags, actual.Tags);

            var oldEmail = expected.Email;

            expected.NewEmail = subscriberFactoryFixture.GetRandomEmailAddress();
            result            = dripClientFixture.Client.CreateOrUpdateSubscriber(expected);
            Assert.True(result.HasSuccessStatusCode());
            Assert.False(result.HasErrors());

            result = dripClientFixture.Client.GetSubscriber(expected.NewEmail);
            DripAssert.Success(result, HttpStatusCode.OK);
            Assert.Equal(1, result.Subscribers.Count);

            actual = result.Subscribers.First();
            Assert.Equal(expected.NewEmail, actual.Email);
            DripAssert.Equal(expected.CustomFields, actual.CustomFields);
            DripAssert.ContainsSameItems(expected.Tags, actual.Tags);
        }
Example #2
0
        public void CanApplyAndRemoveTags()
        {
            var originalSubscriber = subscriberFactoryFixture.CreateComplexUniqueModifyDripSubscriber();

            dripClientFixture.Client.CreateOrUpdateSubscriber(originalSubscriber);

            var newTag = Guid.NewGuid().ToString("n");

            var result = dripClientFixture.Client.ApplyTagToSubscriber(originalSubscriber.Email, newTag);

            DripAssert.Success(result, HttpStatusCode.Created);

            var oldTag = originalSubscriber.Tags[0];

            result = dripClientFixture.Client.RemoveTagFromSubscriber(originalSubscriber.Email, oldTag);
            DripAssert.Success(result, HttpStatusCode.NoContent);

            var subscriberResult = dripClientFixture.Client.GetSubscriber(originalSubscriber.Email);

            DripAssert.Success(subscriberResult);

            var newSubscriber = subscriberResult.Subscribers.First();

            Assert.True(newSubscriber.Tags.Contains(newTag));
            Assert.False(newSubscriber.Tags.Contains(oldTag));
        }
Example #3
0
        public void CanTrackEvent()
        {
            var subscriber       = subscriberFactoryFixture.CreateComplexUniqueModifyDripSubscriber();
            var subscriberResult = dripClientFixture.Client.CreateOrUpdateSubscriber(subscriber);

            DripAssert.Success(subscriberResult);

            //simple event
            var result = dripClientFixture.Client.TrackEvent(new DripEvent {
                Action = "hello", Email = subscriber.Email
            });

            DripAssert.Success(result, HttpStatusCode.NoContent);

            //more complex event
            result = dripClientFixture.Client.TrackEvent(
                new DripEvent {
                Action        = "hello2",
                Email         = subscriber.Email,
                PotentialLead = true,
                Properties    = new Dictionary <string, string> {
                    { "value", "100" }
                }
            });
            DripAssert.Success(result, HttpStatusCode.NoContent);

            //There is no API for reading events so we can't verify the contents from here. Look in your Dashboard.
        }
        public void CanSubscribeExistingSubscriberToCampaignAndThenUnsubscribe()
        {
            var subscriber       = subscriberFactoryFixture.CreateComplexUniqueModifyDripSubscriber();
            var subscriberResult = dripClientFixture.Client.CreateOrUpdateSubscriber(subscriber);

            DripAssert.Success(subscriberResult);

            var campaignRequest = new ModifyDripCampaignSubscriberRequest {
                Email = subscriber.Email
            };
            var result = dripClientFixture.Client.SubscribeToCampaign(TestCampaignId, campaignRequest);

            DripAssert.Success(result, HttpStatusCode.Created);

            subscriberResult = dripClientFixture.Client.UnsubscribeFromCampaign(subscriber.Email, TestCampaignId);
            //TODO: this is a mismatch with the docs. Docs say it will be "200 OK"
            DripAssert.Success(result, HttpStatusCode.Created);
        }