summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrandonmwest <brawest@gmail.com>2013-07-27 08:56:03 -0700
committerbrandonmwest <brawest@gmail.com>2013-07-27 08:56:03 -0700
commit4b69e64d1a0a9027fe9b74a026b1135e002907ab (patch)
treee995017f249dff18c212508deec0c2ac005acb6c
parentae8b266ad04e58112325a8d4ba320c38a3b5375b (diff)
parentb2b2092d940e5c5b62d8c347c50a9167fb6e2f0f (diff)
downloadsendgrid-csharp-4b69e64d1a0a9027fe9b74a026b1135e002907ab.zip
sendgrid-csharp-4b69e64d1a0a9027fe9b74a026b1135e002907ab.tar.gz
sendgrid-csharp-4b69e64d1a0a9027fe9b74a026b1135e002907ab.tar.bz2
Merge pull request #31 from bobmclaren/master
Added support for multiple categories.
-rwxr-xr-xSendGrid/SendGridMail/Header.cs7
-rwxr-xr-xSendGrid/SendGridMail/IHeader.cs7
-rwxr-xr-xSendGrid/SendGridMail/ISendGrid.cs7
-rwxr-xr-xSendGrid/SendGridMail/SendGrid.cs5
-rwxr-xr-xSendGrid/Tests/TestHeader.cs9
5 files changed, 35 insertions, 0 deletions
diff --git a/SendGrid/SendGridMail/Header.cs b/SendGrid/SendGridMail/Header.cs
index be4ebeb..f8c9be8 100755
--- a/SendGrid/SendGridMail/Header.cs
+++ b/SendGrid/SendGridMail/Header.cs
@@ -50,6 +50,13 @@ namespace SendGridMail
_settings.AddSetting(keys, category);
}
+ public void SetCategories(IEnumerable<string> categories)
+ {
+ if (categories == null) return;
+ var keys = new List<String> { "category" };
+ _settings.AddArray(keys, categories);
+ }
+
public void Enable(string filter)
{
AddFilterSetting(filter, new List<string>(){ "enable" }, "1");
diff --git a/SendGrid/SendGridMail/IHeader.cs b/SendGrid/SendGridMail/IHeader.cs
index 3ec7911..cb1cc12 100755
--- a/SendGrid/SendGridMail/IHeader.cs
+++ b/SendGrid/SendGridMail/IHeader.cs
@@ -46,6 +46,13 @@ namespace SendGridMail
void SetCategory(String category);
/// <summary>
+ /// This sets the categories for this email. Statistics are stored on a per category
+ /// basis, so this can be useful for tracking on a per group basis.
+ /// </summary>
+ /// <param name="categories">categories applied to the message</param>
+ void SetCategories(IEnumerable<string> categories);
+
+ /// <summary>
/// Shortcut method for enabling a filter.
/// </summary>
/// <param name="filter">The name of the filter to enable</param>
diff --git a/SendGrid/SendGridMail/ISendGrid.cs b/SendGrid/SendGridMail/ISendGrid.cs
index a96e93c..9725be0 100755
--- a/SendGrid/SendGridMail/ISendGrid.cs
+++ b/SendGrid/SendGridMail/ISendGrid.cs
@@ -116,6 +116,13 @@ namespace SendGridMail
void SetCategory(String category);
/// <summary>
+ /// This sets the categories for this email. Statistics are stored on a per category
+ /// basis, so this can be useful for tracking on a per group basis.
+ /// </summary>
+ /// <param name="categories">categories applied to the message</param>
+ void SetCategories(IEnumerable<String> categories);
+
+ /// <summary>
/// Add an attachment to the message.
/// </summary>
/// <param name="filePath">a fully qualified file path as a string</param>
diff --git a/SendGrid/SendGridMail/SendGrid.cs b/SendGrid/SendGridMail/SendGrid.cs
index 0ee7079..f7901c1 100755
--- a/SendGrid/SendGridMail/SendGrid.cs
+++ b/SendGrid/SendGridMail/SendGrid.cs
@@ -305,6 +305,11 @@ namespace SendGridMail
{
Header.SetCategory(category);
}
+
+ public void SetCategories(IEnumerable<string> categories)
+ {
+ Header.SetCategories(categories);
+ }
public void AddAttachment(Stream stream, String name)
{
diff --git a/SendGrid/Tests/TestHeader.cs b/SendGrid/Tests/TestHeader.cs
index 8a130e9..617d70e 100755
--- a/SendGrid/Tests/TestHeader.cs
+++ b/SendGrid/Tests/TestHeader.cs
@@ -40,6 +40,15 @@ namespace Tests
}
[Test]
+ public void TestSetCategories()
+ {
+ var test = new Header();
+ test.SetCategories(new List<string>{"dogs","animals","pets","mammals"});
+ var result = test.AsJson();
+ Assert.AreEqual("{\"category\" : [\"dogs\", \"animals\", \"pets\", \"mammals\"]}", result);
+ }
+
+ [Test]
public void TestEnable()
{
var test = new Header();