Skip to content

Commit 6b5e837

Browse files
Update dependency for async fix
1 parent 4c8297a commit 6b5e837

File tree

31 files changed

+1341
-1318
lines changed

31 files changed

+1341
-1318
lines changed

README.md

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,21 @@ namespace Example
6464
{
6565
private static void Main()
6666
{
67-
String apiKey = Environment.GetEnvironmentVariable("NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY", EnvironmentVariableTarget.User);
67+
Execute.Wait();
68+
}
69+
70+
static async Task Execute()
71+
{
72+
string apiKey = Environment.GetEnvironmentVariable("NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY", EnvironmentVariableTarget.User);
6873
dynamic sg = new SendGridAPIClient(apiKey);
6974

7075
Email from = new Email("[email protected]");
71-
String subject = "Hello World from the SendGrid CSharp Library!";
76+
string subject = "Hello World from the SendGrid CSharp Library!";
7277
Email to = new Email("[email protected]");
7378
Content content = new Content("text/plain", "Hello, Email!");
7479
Mail mail = new Mail(from, subject, to, content);
7580

76-
dynamic response = sg.client.mail.send.post(requestBody: mail.Get());
81+
dynamic response = await sg.client.mail.send.post(requestBody: mail.Get());
7782
}
7883
}
7984
}
@@ -95,6 +100,11 @@ namespace Example
95100
internal class Example
96101
{
97102
private static void Main()
103+
{
104+
Execute.Wait();
105+
}
106+
107+
static async Task Execute()
98108
{
99109
String apiKey = Environment.GetEnvironmentVariable("NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY", EnvironmentVariableTarget.User);
100110
dynamic sg = new SendGridAPIClient(apiKey);
@@ -121,7 +131,7 @@ namespace Example
121131
]
122132
}";
123133
Object json = JsonConvert.DeserializeObject<Object>(data);
124-
dynamic response = sg.client.mail.send.post(requestBody: json.ToString());
134+
dynamic response = await sg.client.mail.send.post(requestBody: json.ToString());
125135
}
126136
}
127137
}
@@ -138,11 +148,16 @@ namespace Example
138148
internal class Example
139149
{
140150
private static void Main()
151+
{
152+
Execute.Wait();
153+
}
154+
155+
static async Task Execute()
141156
{
142157
string apiKey = Environment.GetEnvironmentVariable("NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY", EnvironmentVariableTarget.User);
143158
dynamic sg = new SendGrid.SendGridAPIClient(apiKey);
144-
dynamic response = sg.client.suppression.bounces.get();
145-
}
159+
dynamic response = await sg.client.suppression.bounces.get();
160+
}
146161
}
147162
}
148163
```
@@ -159,10 +174,15 @@ namespace Example
159174
{
160175
private static void Main()
161176
{
177+
Execute.Wait();
178+
}
179+
180+
static async Task Execute()
181+
{
162182
string apiKey = Environment.GetEnvironmentVariable("NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY", EnvironmentVariableTarget.User);
163183
dynamic sg = new SendGrid.SendGridAPIClient(apiKey);
164-
dynamic response = sg.client._("suppression/bounces").get();
165-
}
184+
dynamic response = await sg.client._("suppression/bounces").get();
185+
}
166186
}
167187
}
168188
```

SendGrid/Example/Example.cs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Web.Script.Serialization;
44
using SendGrid.Helpers.Mail;
55
using Newtonsoft.Json;
6+
using System.Threading.Tasks;
67

78
namespace Example
89
{
@@ -11,15 +12,15 @@ internal class Example
1112
private static void Main()
1213
{
1314
// v3 Mail Helper
14-
HelloEmail(); // this will actually send an email
15-
KitchenSink(); // this will only send an email if you set SandBox Mode to false
15+
HelloEmail().Wait(); // this will actually send an email
16+
KitchenSink().Wait(); // this will only send an email if you set SandBox Mode to false
1617

1718
// v3 Web API
18-
ApiKeys();
19+
ApiKeys().Wait();
1920

2021
}
2122

22-
private static void HelloEmail()
23+
private static async Task HelloEmail()
2324
{
2425
String apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY", EnvironmentVariableTarget.User);
2526
dynamic sg = new SendGrid.SendGridAPIClient(apiKey, "https://api.sendgrid.com");
@@ -32,7 +33,7 @@ private static void HelloEmail()
3233
Email email = new Email("[email protected]");
3334
mail.Personalization[0].AddTo(email);
3435

35-
dynamic response = sg.client.mail.send.post(requestBody: mail.Get());
36+
dynamic response = await sg.client.mail.send.post(requestBody: mail.Get());
3637
Console.WriteLine(response.StatusCode);
3738
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
3839
Console.WriteLine(response.Headers.ToString());
@@ -42,7 +43,7 @@ private static void HelloEmail()
4243

4344
}
4445

45-
private static void KitchenSink()
46+
private static async Task KitchenSink()
4647
{
4748
String apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY", EnvironmentVariableTarget.User);
4849
dynamic sg = new SendGrid.SendGridAPIClient(apiKey, "https://api.sendgrid.com");
@@ -229,7 +230,7 @@ private static void KitchenSink()
229230
email.Address = "[email protected]";
230231
mail.ReplyTo = email;
231232

232-
dynamic response = sg.client.mail.send.post(requestBody: mail.Get());
233+
dynamic response = await sg.client.mail.send.post(requestBody: mail.Get());
233234
Console.WriteLine(response.StatusCode);
234235
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
235236
Console.WriteLine(response.Headers.ToString());
@@ -238,15 +239,15 @@ private static void KitchenSink()
238239
Console.ReadLine();
239240
}
240241

241-
private static void ApiKeys()
242+
private static async Task ApiKeys()
242243
{
243244
String apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY", EnvironmentVariableTarget.User);
244245
dynamic sg = new SendGrid.SendGridAPIClient(apiKey, "https://api.sendgrid.com");
245246

246247
string queryParams = @"{
247248
'limit': 100
248249
}";
249-
dynamic response = sg.client.api_keys.get(queryParams: queryParams);
250+
dynamic response = await sg.client.api_keys.get(queryParams: queryParams);
250251
Console.WriteLine(response.StatusCode);
251252
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
252253
Console.WriteLine(response.Headers.ToString());
@@ -264,7 +265,7 @@ private static void ApiKeys()
264265
]
265266
}";
266267
Object json = JsonConvert.DeserializeObject<Object>(requestBody);
267-
response = sg.client.api_keys.post(requestBody: json.ToString());
268+
response = await sg.client.api_keys.post(requestBody: json.ToString());
268269
Console.WriteLine(response.StatusCode);
269270
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
270271
Console.WriteLine(response.Headers.ToString());
@@ -276,7 +277,7 @@ private static void ApiKeys()
276277
Console.ReadLine();
277278

278279
// GET Single
279-
response = sg.client.api_keys._(api_key_id).get();
280+
response = await sg.client.api_keys._(api_key_id).get();
280281
Console.WriteLine(response.StatusCode);
281282
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
282283
Console.WriteLine(response.Headers.ToString());
@@ -289,7 +290,7 @@ private static void ApiKeys()
289290
'name': 'A New Hope'
290291
}";
291292
json = JsonConvert.DeserializeObject<Object>(requestBody);
292-
response = sg.client.api_keys._(api_key_id).patch(requestBody: json.ToString());
293+
response = await sg.client.api_keys._(api_key_id).patch(requestBody: json.ToString());
293294
Console.WriteLine(response.StatusCode);
294295
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
295296
Console.WriteLine(response.Headers.ToString());
@@ -306,7 +307,7 @@ private static void ApiKeys()
306307
]
307308
}";
308309
json = JsonConvert.DeserializeObject<Object>(requestBody);
309-
response = sg.client.api_keys._(api_key_id).put(requestBody: json.ToString());
310+
response = await sg.client.api_keys._(api_key_id).put(requestBody: json.ToString());
310311
Console.WriteLine(response.StatusCode);
311312
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
312313
Console.WriteLine(response.Headers.ToString());
@@ -315,7 +316,7 @@ private static void ApiKeys()
315316
Console.ReadLine();
316317

317318
// DELETE
318-
response = sg.client.api_keys._(api_key_id).delete();
319+
response = await sg.client.api_keys._(api_key_id).delete();
319320
Console.WriteLine(response.StatusCode);
320321
Console.WriteLine(response.Headers.ToString());
321322

SendGrid/SendGrid/SendGrid.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
4848
<Private>True</Private>
4949
</Reference>
50-
<Reference Include="SendGrid.CSharp.HTTP.Client, Version=2.0.7.0, Culture=neutral, PublicKeyToken=79219bf4e5ecaaca, processorArchitecture=MSIL">
51-
<HintPath>..\packages\SendGrid.CSharp.HTTP.Client.2.0.7\lib\SendGrid.CSharp.HTTP.Client.dll</HintPath>
50+
<Reference Include="SendGrid.CSharp.HTTP.Client, Version=3.0.0.0, Culture=neutral, PublicKeyToken=79219bf4e5ecaaca, processorArchitecture=MSIL">
51+
<HintPath>..\packages\SendGrid.CSharp.HTTP.Client.3.0.0\lib\SendGrid.CSharp.HTTP.Client.dll</HintPath>
5252
<Private>True</Private>
5353
</Reference>
5454
<Reference Include="System" />

SendGrid/SendGrid/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
<packages>
33
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net45" />
44
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
5-
<package id="SendGrid.CSharp.HTTP.Client" version="2.0.7" targetFramework="net452" />
5+
<package id="SendGrid.CSharp.HTTP.Client" version="3.0.0" targetFramework="net452" />
66
</packages>

0 commit comments

Comments
 (0)