summaryrefslogtreecommitdiffstats
path: root/src/Example/Program.cs
diff options
context:
space:
mode:
authorElmer Thomas <elmer@thinkingserious.com>2016-12-09 22:22:14 -0800
committerElmer Thomas <elmer@thinkingserious.com>2016-12-09 22:22:14 -0800
commitff603f56e723d3e49c453cfdfe8dcf05617b6b50 (patch)
tree4c9acd0b0ffc176a747ed1e012490cd372117f0d /src/Example/Program.cs
parentc8cb64deec10ac760e99f97969c7ccefda846e57 (diff)
downloadsendgrid-csharp-ff603f56e723d3e49c453cfdfe8dcf05617b6b50.zip
sendgrid-csharp-ff603f56e723d3e49c453cfdfe8dcf05617b6b50.tar.gz
sendgrid-csharp-ff603f56e723d3e49c453cfdfe8dcf05617b6b50.tar.bz2
Update .NET Core Example for new SendSingleEmailAsync demo
Diffstat (limited to 'src/Example/Program.cs')
-rw-r--r--src/Example/Program.cs33
1 files changed, 9 insertions, 24 deletions
diff --git a/src/Example/Program.cs b/src/Example/Program.cs
index 67a5709..ab7b4ec 100644
--- a/src/Example/Program.cs
+++ b/src/Example/Program.cs
@@ -19,19 +19,6 @@ namespace Example
string apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY");
Client client = new Client(apiKey);
- /* Send a Email using the Mail Helper
- var msg = new SendGridMessage();
- var from = new MailAddress("dx@sendgrid");
- var subject = "Hello World from the SendGrid CSharp Library Helper!";
- var to = new MailAddress("elmer@sendgrid.com");
- var content = new Content("text/plain", "Hello, Email from the helper!");
- Response response = await client.SendEmailAsync(msg);
- Console.WriteLine(response.StatusCode);
- Console.WriteLine(response.Body.ReadAsStringAsync().Result);
- Console.WriteLine(response.Headers);
- Console.ReadLine();
- */
-
// Send a Single Email using the Mail Helper
var from = new MailAddress("dx@sendgrid", "DX Team");
var subject = "Hello World from the SendGrid CSharp Library Helper!";
@@ -41,7 +28,6 @@ namespace Example
Response response = await client.Mail.SendSingleEmailAsync(from, to, subject , contentText, contentHTML);
Console.WriteLine(response.StatusCode);
- Console.WriteLine(response.Body.ReadAsStringAsync().Result);
Console.WriteLine(response.Headers);
Console.ReadLine();
@@ -68,11 +54,10 @@ namespace Example
]
}";
Object json = JsonConvert.DeserializeObject<Object>(data);
- response = await client.RequestAsync(Client.Methods.POST,
+ response = await client.RequestAsync(Client.Method.POST,
json.ToString(),
urlPath: "mail/send");
Console.WriteLine(response.StatusCode);
- Console.WriteLine(response.Body.ReadAsStringAsync().Result);
Console.WriteLine(response.Headers);
Console.ReadLine();
@@ -80,12 +65,12 @@ namespace Example
string queryParams = @"{
'limit': 100
}";
- response = await client.RequestAsync(method: Client.Methods.GET,
+ response = await client.RequestAsync(method: Client.Method.GET,
urlPath: "asm/groups",
queryParams: queryParams);
Console.WriteLine(response.StatusCode);
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
- Console.WriteLine(response.Headers.ToString());
+ Console.WriteLine(response.Headers);
Console.WriteLine("\n\nPress any key to continue to POST.");
Console.ReadLine();
@@ -96,23 +81,23 @@ namespace Example
'name': 'Magic Products'
}";
json = JsonConvert.DeserializeObject<object>(requestBody);
- response = await client.RequestAsync(method: Client.Methods.POST,
+ response = await client.RequestAsync(method: Client.Method.POST,
urlPath: "asm/groups",
requestBody: json.ToString());
var ds_response = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(response.Body.ReadAsStringAsync().Result);
string group_id = ds_response["id"].ToString();
Console.WriteLine(response.StatusCode);
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
- Console.WriteLine(response.Headers.ToString());
+ Console.WriteLine(response.Headers);
Console.WriteLine("\n\nPress any key to continue to GET single.");
Console.ReadLine();
// GET Single
- response = await client.RequestAsync(method: Client.Methods.GET,
+ response = await client.RequestAsync(method: Client.Method.GET,
urlPath: string.Format("asm/groups/{0}", group_id));
Console.WriteLine(response.StatusCode);
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
- Console.WriteLine(response.Headers.ToString());
+ Console.WriteLine(response.Headers);
Console.WriteLine("\n\nPress any key to continue to PATCH.");
Console.ReadLine();
@@ -122,7 +107,7 @@ namespace Example
}";
json = JsonConvert.DeserializeObject<object>(requestBody);
- response = await client.RequestAsync(method: Client.Methods.PATCH,
+ response = await client.RequestAsync(method: Client.Method.PATCH,
urlPath: string.Format("asm/groups/{0}", group_id),
requestBody: json.ToString());
Console.WriteLine(response.StatusCode);
@@ -133,7 +118,7 @@ namespace Example
Console.ReadLine();
// DELETE
- response = await client.RequestAsync(method: Client.Methods.DELETE,
+ response = await client.RequestAsync(method: Client.Method.DELETE,
urlPath: string.Format("asm/groups/{0}", group_id));
Console.WriteLine(response.StatusCode);
Console.WriteLine(response.Headers.ToString());