diff options
Diffstat (limited to 'examples/ips/ips.cs')
-rw-r--r-- | examples/ips/ips.cs | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/examples/ips/ips.cs b/examples/ips/ips.cs index 6b67116..4094453 100644 --- a/examples/ips/ips.cs +++ b/examples/ips/ips.cs @@ -1,9 +1,10 @@ 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); //////////////////////////////////////////////////////// // Retrieve all IP addresses @@ -16,7 +17,7 @@ string queryParams = @"{ 'offset': 1, 'subuser': 'test_string' }"; -dynamic response = await sg.client.ips.get(queryParams: queryParams); +Response response = await client.RequestAsync(method: Client.Methods.GET, urlPath: "ips", queryParams: queryParams); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); @@ -26,7 +27,7 @@ Console.ReadLine(); // Retrieve all assigned IPs // GET /ips/assigned -dynamic response = await sg.client.ips.assigned.get(); +Response response = await client.RequestAsync(method: Client.Methods.GET, urlPath: "ips/assigned"); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); @@ -41,7 +42,7 @@ string data = @"{ }"; Object json = JsonConvert.DeserializeObject<Object>(data); data = json.ToString(); -dynamic response = await sg.client.ips.pools.post(requestBody: data); +Response response = await client.RequestAsync(method: Client.Methods.POST, urlPath: "ips/pools", requestBody: data); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); @@ -51,7 +52,7 @@ Console.ReadLine(); // Retrieve all IP pools. // GET /ips/pools -dynamic response = await sg.client.ips.pools.get(); +Response response = await client.RequestAsync(method: Client.Methods.GET, urlPath: "ips/pools"); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); @@ -67,7 +68,7 @@ string data = @"{ Object json = JsonConvert.DeserializeObject<Object>(data); data = json.ToString(); var pool_name = "test_url_param"; -dynamic response = await sg.client.ips.pools._(pool_name).put(requestBody: data); +Response response = await client.RequestAsync(method: Client.Methods.PUT, urlPath: "ips/pools/" + pool_name, requestBody: data); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); @@ -78,7 +79,7 @@ Console.ReadLine(); // GET /ips/pools/{pool_name} var pool_name = "test_url_param"; -dynamic response = await sg.client.ips.pools._(pool_name).get(); +Response response = await client.RequestAsync(method: Client.Methods.GET, urlPath: "ips/pools/" + pool_name); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); @@ -89,7 +90,7 @@ Console.ReadLine(); // DELETE /ips/pools/{pool_name} var pool_name = "test_url_param"; -dynamic response = await sg.client.ips.pools._(pool_name).delete(); +Response response = await client.RequestAsync(method: Client.Methods.DELETE, urlPath: "ips/pools/" + pool_name); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); @@ -105,7 +106,7 @@ string data = @"{ Object json = JsonConvert.DeserializeObject<Object>(data); data = json.ToString(); var pool_name = "test_url_param"; -dynamic response = await sg.client.ips.pools._(pool_name).ips.post(requestBody: data); +Response response = await client.RequestAsync(method: Client.Methods.POST, urlPath: "ips/pools/" + pool_name + "/ips", requestBody: data); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); @@ -117,7 +118,7 @@ Console.ReadLine(); var pool_name = "test_url_param"; var ip = "test_url_param"; -dynamic response = await sg.client.ips.pools._(pool_name).ips._(ip).delete(); +Response response = await client.RequestAsync(method: Client.Methods.DELETE, urlPath: "ips/pools/" + pool_name + "/ips/" + ip); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); @@ -132,7 +133,7 @@ string data = @"{ }"; Object json = JsonConvert.DeserializeObject<Object>(data); data = json.ToString(); -dynamic response = await sg.client.ips.warmup.post(requestBody: data); +Response response = await client.RequestAsync(method: Client.Methods.POST, urlPath: "ips/warmup", requestBody: data); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); @@ -142,7 +143,7 @@ Console.ReadLine(); // Retrieve all IPs currently in warmup // GET /ips/warmup -dynamic response = await sg.client.ips.warmup.get(); +Response response = await client.RequestAsync(method: Client.Methods.GET, urlPath: "ips/warmup"); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); @@ -153,7 +154,7 @@ Console.ReadLine(); // GET /ips/warmup/{ip_address} var ip_address = "test_url_param"; -dynamic response = await sg.client.ips.warmup._(ip_address).get(); +Response response = await client.RequestAsync(method: Client.Methods.GET, urlPath: "ips/warmup/" + ip_address); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); @@ -164,7 +165,7 @@ Console.ReadLine(); // DELETE /ips/warmup/{ip_address} var ip_address = "test_url_param"; -dynamic response = await sg.client.ips.warmup._(ip_address).delete(); +Response response = await client.RequestAsync(method: Client.Methods.DELETE, urlPath: "ips/warmup/" + ip_address); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); @@ -175,7 +176,7 @@ Console.ReadLine(); // GET /ips/{ip_address} var ip_address = "test_url_param"; -dynamic response = await sg.client.ips._(ip_address).get(); +Response response = await client.RequestAsync(method: Client.Methods.GET, urlPath: "ips/" + ip_address); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); |