Skip to content

Commit

Permalink
Merge pull request #122 from Jericho/release/0.20.0
Browse files Browse the repository at this point in the history
Release/0.20.0
  • Loading branch information
Jericho committed Feb 17, 2017
2 parents e100357 + 55ed96d commit 45c9c37
Show file tree
Hide file tree
Showing 24 changed files with 104 additions and 64 deletions.
2 changes: 1 addition & 1 deletion GitReleaseManager.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
create:
include-footer: true
footer-heading: Where to get it
footer-content: You can download this release from [nuget.org](https://www.nuget.org/packages/Picton/{milestone})
footer-content: You can download this release from [nuget.org](https://www.nuget.org/packages/StrongGrid/{milestone})
footer-includes-milestone: true
milestone-replace-text: '{milestone}'
export:
Expand Down
9 changes: 5 additions & 4 deletions Source/StrongGrid.IntegrationTests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,20 @@ private static void Mail(IClient client, bool pauseAfterTests)
new KeyValuePair<string, string>("some_other_value", "QWERTY")
};

client.Mail.SendAsync(personalizations, subject, new[] { textContent, htmlContent }, from,
var messageId = client.Mail.SendAsync(personalizations, subject, new[] { textContent, htmlContent }, from,
headers: headers,
customArgs: customArgs,
mailSettings: mailSettings,
trackingSettings: trackingSettings
).Wait();
).Result;
Console.WriteLine("Email has been sent. Message Id: {0}", messageId);

/******
Here's the simplified way to send a single email to a single recipient:
await client.Mail.SendToSingleRecipientAsync(to, from, subject, htmlContent, textContent).ConfigureAwait(false);
var messageId = await client.Mail.SendToSingleRecipientAsync(to, from, subject, htmlContent, textContent).ConfigureAwait(false);
Here's the simplified way to send the same email to multiple recipients:
await client.Mail.SendToMultipleRecipientsAsync(new[] { to1, to2, to3 }, from, subject, htmlContent, textContent).ConfigureAwait(false);
var messageId = await client.Mail.SendToMultipleRecipientsAsync(new[] { to1, to2, to3 }, from, subject, htmlContent, textContent).ConfigureAwait(false);
******/

ConcludeTests(pauseAfterTests);
Expand Down
36 changes: 33 additions & 3 deletions Source/StrongGrid.UnitTests/Resources/MailTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using RichardSzalay.MockHttp;
using Shouldly;
using StrongGrid.Model;
using StrongGrid.UnitTests;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Xunit;

namespace StrongGrid.Resources.UnitTests
Expand All @@ -28,11 +30,37 @@ public void Send()
var mail = new Mail(client);

// Act
mail.SendAsync(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, CancellationToken.None).Wait();
var result = mail.SendAsync(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, CancellationToken.None).Result;

// Assert
mockHttp.VerifyNoOutstandingExpectation();
mockHttp.VerifyNoOutstandingRequest();
result.ShouldBeNull();
}

[Fact]
public void Send_response_with_message_id()
{
// Arrange

var mockHttp = new MockHttpMessageHandler();
mockHttp.Expect(HttpMethod.Post, Utils.GetSendGridApiUri(ENDPOINT, "send")).Respond((HttpRequestMessage request) =>
{
var response = new HttpResponseMessage(HttpStatusCode.OK);
response.Headers.Add("X-Message-Id", "abc123");
return response;
});

var client = Utils.GetFluentClient(mockHttp);
var mail = new Mail(client);

// Act
var result = mail.SendAsync(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, CancellationToken.None).Result;

// Assert
mockHttp.VerifyNoOutstandingExpectation();
mockHttp.VerifyNoOutstandingRequest();
result.ShouldBe("abc123");
}

[Fact]
Expand All @@ -47,11 +75,12 @@ public void SendToSingleRecipient()
var mail = new Mail(client);

// Act
mail.SendToSingleRecipientAsync(null, null, null, null, null).Wait(CancellationToken.None);
var result = mail.SendToSingleRecipientAsync(null, null, null, null, null).Result;

// Assert
mockHttp.VerifyNoOutstandingExpectation();
mockHttp.VerifyNoOutstandingRequest();
result.ShouldBeNull();
}

[Fact]
Expand All @@ -73,11 +102,12 @@ public void SendToMultipleRecipients()
var mail = new Mail(client);

// Act
mail.SendToMultipleRecipientsAsync(recipients, null, null, null, null).Wait(CancellationToken.None);
var result = mail.SendToMultipleRecipientsAsync(recipients, null, null, null, null).Result;

// Assert
mockHttp.VerifyNoOutstandingExpectation();
mockHttp.VerifyNoOutstandingRequest();
result.ShouldBeNull();
}
}
}
2 changes: 1 addition & 1 deletion Source/StrongGrid/Resources/Alerts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public Task DeleteAsync(long alertId, CancellationToken cancellationToken = defa
return _client
.DeleteAsync($"{_endpoint}/{alertId}")
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Source/StrongGrid/Resources/ApiKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public Task DeleteAsync(string keyId, CancellationToken cancellationToken = defa
return _client
.DeleteAsync($"{_endpoint}/{keyId}")
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions Source/StrongGrid/Resources/Batches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public Task Cancel(string batchId, CancellationToken cancellationToken = default
.PostAsync("user/scheduled_sends")
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand All @@ -108,7 +108,7 @@ public Task Pause(string batchId, CancellationToken cancellationToken = default(
.PostAsync("user/scheduled_sends")
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand Down Expand Up @@ -139,7 +139,7 @@ public Task Resume(string batchId, CancellationToken cancellationToken = default
return _client
.DeleteAsync($"{_endpoint}/{batchId}")
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}
}
}
6 changes: 3 additions & 3 deletions Source/StrongGrid/Resources/Blocks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public Task DeleteAllAsync(CancellationToken cancellationToken = default(Cancell
.DeleteAsync(_endpoint)
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand All @@ -107,7 +107,7 @@ public Task DeleteMultipleAsync(IEnumerable<string> emailAddresses, Cancellation
.DeleteAsync(_endpoint)
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand All @@ -123,7 +123,7 @@ public Task DeleteAsync(string emailAddress, CancellationToken cancellationToken
return _client
.DeleteAsync($"{_endpoint}/{emailAddress}")
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}
}
}
6 changes: 3 additions & 3 deletions Source/StrongGrid/Resources/Bounces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public Task DeleteAllAsync(CancellationToken cancellationToken = default(Cancell
.DeleteAsync(_endpoint)
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand All @@ -97,7 +97,7 @@ public Task DeleteAsync(IEnumerable<string> emails, CancellationToken cancellati
.DeleteAsync(_endpoint)
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand All @@ -113,7 +113,7 @@ public Task DeleteAsync(string email, CancellationToken cancellationToken = defa
return _client
.DeleteAsync($"{_endpoint}/{email}")
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}
}
}
12 changes: 6 additions & 6 deletions Source/StrongGrid/Resources/Campaigns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public Task DeleteAsync(long campaignId, CancellationToken cancellationToken = d
return _client
.DeleteAsync($"{_endpoint}/{campaignId}")
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand Down Expand Up @@ -161,7 +161,7 @@ public Task SendNowAsync(long campaignId, CancellationToken cancellationToken =
.PostAsync($"{_endpoint}/{campaignId}/schedules/now")
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand All @@ -183,7 +183,7 @@ public Task ScheduleAsync(long campaignId, DateTime sendOn, CancellationToken ca
.PostAsync($"{_endpoint}/{campaignId}/schedules")
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand All @@ -205,7 +205,7 @@ public Task RescheduleAsync(long campaignId, DateTime sendOn, CancellationToken
.PatchAsync($"{_endpoint}/{campaignId}/schedules")
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand Down Expand Up @@ -242,7 +242,7 @@ public Task UnscheduleAsync(long campaignId, CancellationToken cancellationToken
return _client
.DeleteAsync($"{_endpoint}/{campaignId}/schedules")
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand All @@ -268,7 +268,7 @@ public Task SendTestAsync(long campaignId, IEnumerable<string> emailAddresses, C
.PostAsync($"{_endpoint}/{campaignId}/schedules/test")
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

private static JObject CreateJObjectForCampaign(string title = null, long? senderId = null, string subject = null, string htmlContent = null, string textContent = null, IEnumerable<long> listIds = null, IEnumerable<long> segmentIds = null, IEnumerable<string> categories = null, long? suppressionGroupId = null, string customUnsubscribeUrl = null, string ipPool = null)
Expand Down
2 changes: 1 addition & 1 deletion Source/StrongGrid/Resources/Contacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public Task DeleteAsync(IEnumerable<string> contactId, CancellationToken cancell
.DeleteAsync(_endpoint)
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Source/StrongGrid/Resources/CustomFields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public Task DeleteAsync(int fieldId, CancellationToken cancellationToken = defau
return _client
.DeleteAsync($"{_endpoint}/{fieldId}")
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Source/StrongGrid/Resources/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Task AddAsync(IEnumerable<string> emails, CancellationToken cancellationT
.PostAsync(_endpoint)
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand All @@ -88,7 +88,7 @@ public Task RemoveAsync(string email, CancellationToken cancellationToken = defa
return _client
.DeleteAsync($"{_endpoint}/{email}")
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}
}
}
6 changes: 3 additions & 3 deletions Source/StrongGrid/Resources/InvalidEmails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public Task DeleteAllAsync(CancellationToken cancellationToken = default(Cancell
.DeleteAsync(_endpoint)
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand All @@ -107,7 +107,7 @@ public Task DeleteMultipleAsync(IEnumerable<string> emailAddresses, Cancellation
.DeleteAsync(_endpoint)
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand All @@ -123,7 +123,7 @@ public Task DeleteAsync(string emailAddress, CancellationToken cancellationToken
return _client
.DeleteAsync($"{_endpoint}/{emailAddress}")
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}
}
}
12 changes: 6 additions & 6 deletions Source/StrongGrid/Resources/Lists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public Task DeleteAsync(long listId, CancellationToken cancellationToken = defau
return _client
.DeleteAsync($"{_endpoint}/{listId}")
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand All @@ -100,7 +100,7 @@ public Task DeleteAsync(IEnumerable<long> listIds, CancellationToken cancellatio
.DeleteAsync(_endpoint)
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand Down Expand Up @@ -140,7 +140,7 @@ public Task UpdateAsync(long listId, string name, CancellationToken cancellation
.PatchAsync($"{_endpoint}/{listId}")
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand Down Expand Up @@ -179,7 +179,7 @@ public Task AddRecipientAsync(long listId, string contactId, CancellationToken c
return _client
.PostAsync($"{_endpoint}/{listId}/recipients/{contactId}")
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand All @@ -196,7 +196,7 @@ public Task RemoveRecipientAsync(long listId, string contactId, CancellationToke
return _client
.DeleteAsync($"{_endpoint}/{listId}/recipients/{contactId}")
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}

/// <summary>
Expand All @@ -215,7 +215,7 @@ public Task AddRecipientsAsync(long listId, IEnumerable<string> contactIds, Canc
.PostAsync($"{_endpoint}/{listId}/recipients")
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsResponse();
.AsMessage();
}
}
}
Loading

0 comments on commit 45c9c37

Please sign in to comment.