summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElmer Thomas <elmer@thinkingserious.com>2016-10-27 16:20:01 -0700
committerElmer Thomas <elmer@thinkingserious.com>2016-10-27 16:20:01 -0700
commit68f8bafd8c903c25a5fd89001900401e1960fa17 (patch)
tree5fedb9ed7119700212c2e66d0de94f48ba316b8f
parent6fed49241404926dd28bdbe091f27c866a6ee348 (diff)
downloadsendgrid-csharp-68f8bafd8c903c25a5fd89001900401e1960fa17.zip
sendgrid-csharp-68f8bafd8c903c25a5fd89001900401e1960fa17.tar.gz
sendgrid-csharp-68f8bafd8c903c25a5fd89001900401e1960fa17.tar.bz2
Update README with dynamic removed
-rw-r--r--README.md58
1 files changed, 19 insertions, 39 deletions
diff --git a/README.md b/README.md
index dad1ca3..dbf4696 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,7 @@ We appreciate your continued support, thank you!
## Prerequisites
-- .NET version 4.5.2
+- .NET version 4.5 and above
- The SendGrid service, starting at the [free level](https://sendgrid.com/free?source=sendgrid-csharp)
## Setup Environment Variables
@@ -82,13 +82,13 @@ namespace Example
{
private static void Main()
{
- Execute().Wait();
+ Execute().Wait();
}
static async Task Execute()
{
string apiKey = Environment.GetEnvironmentVariable("NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY", EnvironmentVariableTarget.User);
- dynamic sg = new SendGridAPIClient(apiKey);
+ Client client = new Client(apiKey);
Email from = new Email("test@example.com");
string subject = "Hello World from the SendGrid CSharp Library!";
@@ -96,7 +96,9 @@ namespace Example
Content content = new Content("text/plain", "Hello, Email!");
Mail mail = new Mail(from, subject, to, content);
- dynamic response = await sg.client.mail.send.post(requestBody: mail.Get());
+ Response response = await client.RequestAsync(method: Client.Methods.POST,
+ requestBody: mail.Get(),
+ urlPath: "mail/send");
}
}
}
@@ -120,13 +122,13 @@ namespace Example
{
private static void Main()
{
- Execute().Wait();
+ Execute().Wait();
}
static async Task Execute()
{
- String apiKey = Environment.GetEnvironmentVariable("NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY", EnvironmentVariableTarget.User);
- dynamic sg = new SendGridAPIClient(apiKey);
+ string apiKey = Environment.GetEnvironmentVariable("NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY", EnvironmentVariableTarget.User);
+ Client client = new Client(apiKey);
string data = @"{
'personalizations': [
@@ -150,39 +152,15 @@ namespace Example
]
}";
Object json = JsonConvert.DeserializeObject<Object>(data);
- dynamic response = await sg.client.mail.send.post(requestBody: json.ToString());
- }
- }
-}
-```
-
-## General v3 Web API Usage (With Fluent Interface)
-
-```csharp
-using System;
-using SendGrid;
-using System.Threading.Tasks;
-
-namespace Example
-{
- internal class Example
- {
- private static void Main()
- {
- Execute().Wait();
+ Response response = await client.RequestAsync(method: Client.Methods.POST,
+ requestBody: json.ToString(),
+ urlPath: "mail/send");
}
-
- static async Task Execute()
- {
- string apiKey = Environment.GetEnvironmentVariable("NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY", EnvironmentVariableTarget.User);
- dynamic sg = new SendGrid.SendGridAPIClient(apiKey);
- dynamic response = await sg.client.suppression.bounces.get();
- }
}
}
```
-## General v3 Web API Usage (Without Fluent Interface)
+## General v3 Web API Usage
```csharp
using System;
@@ -200,10 +178,12 @@ namespace Example
static async Task Execute()
{
- string apiKey = Environment.GetEnvironmentVariable("NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY", EnvironmentVariableTarget.User);
- dynamic sg = new SendGrid.SendGridAPIClient(apiKey);
- dynamic response = await sg.client._("suppression/bounces").get();
- }
+ string apiKey = Environment.GetEnvironmentVariable("NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY", EnvironmentVariableTarget.User);
+ Client client = new Client(apiKey);
+ Response response = await client.RequestAsync(method: Client.Methods.GET,
+ requestBody: json.ToString(),
+ urlPath: "suppression/bounces");
+ }
}
}
```