Skip to content

Commit

Permalink
Merge pull request #95 from Jericho/release/v0.13.0
Browse files Browse the repository at this point in the history
Release/v0.13.0
  • Loading branch information
Jericho authored Nov 29, 2016
2 parents 9c9a6bf + 59586e7 commit 4ea8eb0
Show file tree
Hide file tree
Showing 118 changed files with 4,871 additions and 771 deletions.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,8 @@ using StrongGrid;

StrongGrid supports the following .NET frameworks:

- 4.5.2
- 4.6
- 4.6.1
- 4.6.2
- .Net Standard 1.3
- .Net Standard 1.6
- 4.5.2 (and more recent versions as well)
- .Net Core


## Usage
Expand Down
62 changes: 49 additions & 13 deletions Source/StrongGrid.IntegrationTests/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using StrongGrid.Model;
using System;
using System.Collections.Generic;
using System.Linq;

namespace StrongGrid.IntegrationTests
Expand Down Expand Up @@ -47,11 +48,11 @@ public static void Main()
}
catch (Exception e)
{
Console.WriteLine("\n\n*************************");
Console.WriteLine("*************************");
Console.WriteLine("\n\n**************************************************");
Console.WriteLine("**************************************************");
Console.WriteLine($"AN EXCEPTION OCCURED: {e.Message}");
Console.WriteLine("*************************");
Console.WriteLine("*************************");
Console.WriteLine("**************************************************");
Console.WriteLine("**************************************************");
}
finally
{
Expand All @@ -73,20 +74,36 @@ private static void Mail(IClient client, bool pauseAfterTests)
var from = new MailAddress("[email protected]", "John Smith");
var to1 = new MailAddress("[email protected]", "Recipient1");
var to2 = new MailAddress("[email protected]", "Recipient2");
var subject = "Hello World!";
var subject = "Dear {{customer_type}}";
var textContent = new MailContent("text/plain", "Hello world!");
var htmlContent = new MailContent("text/html", "<html><body>Hello <b><i>world!</i></b><br/><a href=\"http://microsoft.com\">Microsoft's web site</a></body></html>");
var htmlContent = new MailContent("text/html", "<html><body>Hello <b><i>{{first_name}}!</i></b><br/></body></html>");
var personalizations = new[]
{
new MailPersonalization
{
To = new[] { to1 },
Subject = "Dear friend"
Substitutions = new KeyValuePair<string, string>[]
{
new KeyValuePair<string, string>("{{customer_type}}", "friend"),
new KeyValuePair<string, string>("{{first_name}}", "Bob")
},
CustomArguments = new KeyValuePair<string, string>[]
{
new KeyValuePair<string, string>("some_value_specific_to_this_person", "ABC_123")
}
},
new MailPersonalization
{
To = new[] { to2 },
Subject = "Dear customer"
Substitutions = new KeyValuePair<string, string>[]
{
new KeyValuePair<string, string>("{{customer_type}}", "customer"),
new KeyValuePair<string, string>("{{first_name}}", "John")
},
CustomArguments = new KeyValuePair<string, string>[]
{
new KeyValuePair<string, string>("some_value_specific_to_this_person", "ZZZ_999")
}
}
};
var mailSettings = new MailSettings
Expand All @@ -113,7 +130,7 @@ private static void Mail(IClient client, bool pauseAfterTests)
Footer = new FooterSettings
{
Enabled = true,
HtmlContent = "<p>This email was sent with the help of the <b>StrongGrid</b> library</p>",
HtmlContent = "<p>This email was sent with the help of the <b><a href=\"https://www.nuget.org/packages/StrongGrid/\">StrongGrid</a></b> library</p>",
TextContent = "This email was sent with the help of the StrongGrid library"
}
};
Expand All @@ -128,7 +145,19 @@ private static void Mail(IClient client, bool pauseAfterTests)
GoogleAnalytics = new GoogleAnalyticsSettings { Enabled = false },
SubscriptionTracking = new SubscriptionTrackingSettings { Enabled = false }
};
var headers = new KeyValuePair<string, string>[]
{
new KeyValuePair<string, string>("customerId", "1234"),
};
var customArgs = new KeyValuePair<string, string>[]
{
new KeyValuePair<string, string>("sent_on", DateTime.UtcNow.ToString("yyyy-MM-dd HH-mm-ss")),
new KeyValuePair<string, string>("some_other_value", "QWERTY")
};

client.Mail.SendAsync(personalizations, subject, new[] { textContent, htmlContent }, from,
headers: headers,
customArgs: customArgs,
mailSettings: mailSettings,
trackingSettings: trackingSettings
).Wait();
Expand Down Expand Up @@ -172,10 +201,17 @@ private static void ApiKeys(IClient client, bool pauseAfterTests)
client.ApiKeys.DeleteAsync(newApiKey.KeyId).Wait();
Console.WriteLine("Api Key {0} deleted", newApiKey.KeyId);

// CREATE AND DELETE A BILING API KEY
var billingKey = client.ApiKeys.CreateWithBillingPermissionsAsync("Integration testing billing Key").Result;
client.ApiKeys.DeleteAsync(billingKey.KeyId).Wait();
Console.WriteLine("Created and deleted the billing key");
// GET THE CURRENT USER'S PERMISSIONS
var permissions = client.User.GetPermissionsAsync().Result;
Console.WriteLine("Current user has been granted {0} permissions", permissions.Length);

// CREATE AND DELETE A BILLING API KEY (if authorized)
if (permissions.Any(p => p.StartsWith("billing.", StringComparison.OrdinalIgnoreCase)))
{
var billingKey = client.ApiKeys.CreateWithBillingPermissionsAsync("Integration testing billing Key").Result;
client.ApiKeys.DeleteAsync(billingKey.KeyId).Wait();
Console.WriteLine("Created and deleted the billing key");
}

// CREATE AND DELETE AN API KEY WITH ALL PERMISSIONS
var superKey = client.ApiKeys.CreateWithAllPermissionsAsync("Integration testing Super Key").Result;
Expand Down
2 changes: 1 addition & 1 deletion Source/StrongGrid.UnitTests/Resources/MailTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void Send()
var mail = new Mail(mockClient.Object, ENDPOINT);

// Act
mail.SendAsync(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, CancellationToken.None).Wait();
mail.SendAsync(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, CancellationToken.None).Wait();

// Assert
}
Expand Down
2 changes: 2 additions & 0 deletions Source/StrongGrid.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
<Rule Id="SA1200" Action="None" />
<Rule Id="SA1201" Action="None" />
<Rule Id="SA1309" Action="None" />
<Rule Id="SA1310" Action="None" />
<Rule Id="SA1402" Action="None" />
<Rule Id="SA1502" Action="None" />
<Rule Id="SA1501" Action="None" />
<Rule Id="SA1503" Action="None" />
Expand Down
Loading

0 comments on commit 4ea8eb0

Please sign in to comment.