summaryrefslogtreecommitdiffstats
path: root/examples/mail/mail.cs
diff options
context:
space:
mode:
authorElmer Thomas <elmer@ThinkingSerious.com>2016-11-30 14:42:04 -0800
committerGitHub <noreply@github.com>2016-11-30 14:42:04 -0800
commit3131327a73273df4485a26de5ad4ec645918f8b3 (patch)
treedaac1edeadeb95ea51aa40d78896f5bc02890e62 /examples/mail/mail.cs
parent9a5dbe23a2ccd57316cb8f8d57c7c51d67cc7ca3 (diff)
parent89f5252c13026a4ae8ab1da62be6b743a01bf665 (diff)
downloadsendgrid-csharp-3131327a73273df4485a26de5ad4ec645918f8b3.zip
sendgrid-csharp-3131327a73273df4485a26de5ad4ec645918f8b3.tar.gz
sendgrid-csharp-3131327a73273df4485a26de5ad4ec645918f8b3.tar.bz2
Merge pull request #356 from sendgrid/remove-dynamic
Initial removal of dynamic with some Client refactoring
Diffstat (limited to 'examples/mail/mail.cs')
-rw-r--r--examples/mail/mail.cs11
1 files changed, 6 insertions, 5 deletions
diff --git a/examples/mail/mail.cs b/examples/mail/mail.cs
index cad9aa3..3a3eb68 100644
--- a/examples/mail/mail.cs
+++ b/examples/mail/mail.cs
@@ -1,15 +1,16 @@
using System;
+using SendGrid;
using SendGrid.Helpers.Mail; // If you are using the Mail Helper
using Newtonsoft.Json; // You can generate your JSON string yourelf or with another library if you prefer
-string _apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY", EnvironmentVariableTarget.User);
-dynamic sg = new SendGrid.SendGridAPIClient(_apiKey);
+string apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY", EnvironmentVariableTarget.User);
+Client client = new Client(apiKey);
////////////////////////////////////////////////////////
// Create a batch ID
// POST /mail/batch
-dynamic response = await sg.client.mail.batch.post();
+Response response = await client.RequestAsync(method: Client.Methods.POST, urlPath: "mail/batch");
Console.WriteLine(response.StatusCode);
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
Console.WriteLine(response.Headers.ToString());
@@ -20,7 +21,7 @@ Console.ReadLine();
// GET /mail/batch/{batch_id}
var batch_id = "test_url_param";
-dynamic response = await sg.client.mail.batch._(batch_id).get();
+Response response = await client.RequestAsync(method: Client.Methods.GET, urlPath: "mail/batch/" + batch_id);
Console.WriteLine(response.StatusCode);
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
Console.WriteLine(response.Headers.ToString());
@@ -171,7 +172,7 @@ string data = @"{
}";
Object json = JsonConvert.DeserializeObject<Object>(data);
data = json.ToString();
-dynamic response = await sg.client.mail.send.post(requestBody: data);
+Response response = await client.RequestAsync(method: Client.Methods.POST, urlPath: "mail/send", requestBody: data);
Console.WriteLine(response.StatusCode);
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
Console.WriteLine(response.Headers.ToString());