summaryrefslogtreecommitdiffstats
path: root/SendGrid/Example
diff options
context:
space:
mode:
authorElmer Thomas <elmer@thinkingserious.com>2015-12-10 21:32:45 -0800
committerElmer Thomas <elmer@thinkingserious.com>2015-12-10 21:32:45 -0800
commit7002bfc825ea9904af7811a84740e001fbb34e0c (patch)
tree9279309173a9832fae2623fbc7145ec871834d93 /SendGrid/Example
parent82ed30026efa402952e5977c45398e490e1998f2 (diff)
downloadsendgrid-csharp-7002bfc825ea9904af7811a84740e001fbb34e0c.zip
sendgrid-csharp-7002bfc825ea9904af7811a84740e001fbb34e0c.tar.gz
sendgrid-csharp-7002bfc825ea9904af7811a84740e001fbb34e0c.tar.bz2
Add POST, DELETE
Diffstat (limited to 'SendGrid/Example')
-rw-r--r--SendGrid/Example/Program.cs35
1 files changed, 24 insertions, 11 deletions
diff --git a/SendGrid/Example/Program.cs b/SendGrid/Example/Program.cs
index 096eae3..1d4fbf3 100644
--- a/SendGrid/Example/Program.cs
+++ b/SendGrid/Example/Program.cs
@@ -15,24 +15,18 @@ namespace Example
var to = "example@example.com";
var from = "example@example.com";
var fromName = "Jane Doe";
- // SendEmail(to, from, fromName);
+ SendEmail(to, from, fromName);
// Test viewing, creating, modifying and deleting API keys through our v3 Web API
- // ApiKeys();
+ ApiKeys();
UnsubscribeGroups();
}
- /*
private static void SendAsync(SendGrid.SendGridMessage message)
{
- // Create credentials, specifying your user Name and password.
- var username = Environment.GetEnvironmentVariable("SENDGRID_USERNAME");
- var password = Environment.GetEnvironmentVariable("SENDGRID_PASSWORD");
- //string apikey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY");
- var credentials = new NetworkCredential(username, password);
+ string apikey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY");
// Create a Web transport for sending email.
- var transportWeb = new SendGrid.Web(credentials);
- //var transportWeb2 = new SendGrid.Web(apikey);
+ var transportWeb = new SendGrid.Web(apikey);
// Send the email.
try
@@ -105,7 +99,6 @@ namespace Example
Console.WriteLine("API Key Deleted, press any key to end");
Console.ReadKey();
}
- */
private static void UnsubscribeGroups()
{
@@ -126,6 +119,26 @@ namespace Example
Console.WriteLine(responseGetUnique.Content.ReadAsStringAsync().Result);
Console.WriteLine("These is an Unsubscribe Group with ID: " + unsubscribeGroupID.ToString() + ". Press any key to continue.");
Console.ReadKey();
+
+ // POST UNSUBSCRIBE GROUP
+ HttpResponseMessage responsePost = client.UnsubscribeGroups.Post("C Sharp Unsubscribes", "Testing the C Sharp Library", false).Result;
+ var rawString = responsePost.Content.ReadAsStringAsync().Result;
+ dynamic jsonObject = JObject.Parse(rawString);
+ var unsubscribeGroupId = jsonObject.id.ToString();
+ Console.WriteLine(responsePost.StatusCode);
+ Console.WriteLine(responsePost.Content.ReadAsStringAsync().Result);
+ Console.WriteLine("Unsubscribe Group created. Press any key to continue.");
+ Console.ReadKey();
+
+ // DELETE UNSUBSCRIBE GROUP
+ Console.WriteLine("Deleting Unsubscribe Group, please wait.");
+ HttpResponseMessage responseDelete = client.UnsubscribeGroups.Delete(unsubscribeGroupId).Result;
+ Console.WriteLine(responseDelete.StatusCode);
+ HttpResponseMessage responseFinal = client.UnsubscribeGroups.Get().Result;
+ Console.WriteLine(responseFinal.StatusCode);
+ Console.WriteLine(responseFinal.Content.ReadAsStringAsync().Result);
+ Console.WriteLine("Unsubscribe Group Deleted, press any key to end");
+ Console.ReadKey();
}
}
}