Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user_id to CreateOrUpdateSubscriber #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions DripDotNet/Resources/DripSubscriber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public class DripSubscriber
/// </summary>
public string Email { get; set; }

/// <summary>
/// The subscriber's user id (a unique identifier for the user, such as a primary key).
/// </summary>
public string UserId { get; set; }

/// <summary>
/// The subscriber's time zone (in Olsen format). Defaults to Etc/UTC
/// </summary>
Expand Down Expand Up @@ -108,6 +113,11 @@ public class ModifyDripSubscriberRequest
/// </summary>
public string Email { get; set; }

/// <summary>
/// The subscriber's user id (a unique identifier for the user, such as a primary key).
/// </summary>
public string UserId { get; set; }

/// <summary>
/// The subscriber's time zone (in Olsen format). Defaults to Etc/UTC
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion DripDotNetTests/CampaignTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace DripDotNetTests
public class CampaignTests: IClassFixture<DripClientFixture>, IClassFixture<SubscriberFactoryFixture>
{
//TODO: put this in a configuration file
const string TestCampaignId = "3057996"; //This is a test campaign in my test account
const string TestCampaignId = "3057996"; //This is a test campaign in my test account. Replace this with a Campaign Id from your account before running tests.

DripClientFixture dripClientFixture;
SubscriberFactoryFixture subscriberFactoryFixture;
Expand Down
20 changes: 20 additions & 0 deletions DripDotNetTests/SubscriberFactoryFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public ModifyDripSubscriberRequest CreateComplexUniqueModifyDripSubscriber()
var result = new ModifyDripSubscriberRequest
{
Email = GetRandomEmailAddress(),
UserId = IntUtil.Random(1001,9999).ToString(),
CustomFields = new Dictionary<string, string>
{
{"id", Guid.NewGuid().ToString("n")},
Expand All @@ -70,4 +71,23 @@ public void Dispose()
{
}
}

/*
This support class is used to generate a random integer for the UserId field.
*/
public static class IntUtil
{
private static Random random;

private static void Init()
{
if (random == null) random = new Random();
}

public static int Random(int min, int max)
{
Init();
return random.Next(min, max);
}
}
}
2 changes: 2 additions & 0 deletions DripDotNetTests/SubscriberTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void CanCreateUpdateAndRetrieveSubscriber()
Assert.Equal(1, result.Subscribers.Count);

var actual = result.Subscribers.First();
Assert.Equal(expected.UserId, actual.UserId);
DripAssert.Equal(expected.CustomFields, actual.CustomFields);
DripAssert.ContainsSameItems(expected.Tags, actual.Tags);

Expand Down Expand Up @@ -90,6 +91,7 @@ public async Task CanCreateUpdateAndRetrieveSubscriberAsync()

var actual = result.Subscribers.First();
Assert.Equal(expected.Email, actual.Email);
Assert.Equal(expected.UserId, actual.UserId);
DripAssert.Equal(expected.CustomFields, actual.CustomFields);
DripAssert.ContainsSameItems(expected.Tags, actual.Tags);

Expand Down