diff options
author | Elmer Thomas <elmer@thinkingserious.com> | 2016-07-05 13:26:49 -0700 |
---|---|---|
committer | Elmer Thomas <elmer@thinkingserious.com> | 2016-07-05 13:26:49 -0700 |
commit | 666738924462651e1bec97263cd7ae23eda1f276 (patch) | |
tree | 50d64bf4537885c0f336981bb9caf8a12e6b2b31 | |
parent | 69adfeebe0d0468956bb3803687a8aa7bf2dda72 (diff) | |
download | sendgrid-csharp-666738924462651e1bec97263cd7ae23eda1f276.zip sendgrid-csharp-666738924462651e1bec97263cd7ae23eda1f276.tar.gz sendgrid-csharp-666738924462651e1bec97263cd7ae23eda1f276.tar.bz2 |
swagger/oai updates + accept header fix
-rw-r--r-- | SendGrid/SendGrid/Client.cs | 1 | ||||
-rw-r--r-- | SendGrid/UnitTest/UnitTest.cs | 268 | ||||
-rw-r--r-- | USAGE.md | 297 | ||||
-rw-r--r-- | examples/alerts/alerts.cs | 67 | ||||
-rw-r--r-- | examples/apikeys/apikeys.cs | 6 | ||||
-rw-r--r-- | examples/asm/asm.cs | 18 | ||||
-rw-r--r-- | examples/campaigns/campaigns.cs | 4 | ||||
-rw-r--r-- | examples/contactdb/contactdb.cs | 13 | ||||
-rw-r--r-- | examples/mail/mail.cs | 141 | ||||
-rw-r--r-- | examples/subusers/subusers.cs | 6 | ||||
-rw-r--r-- | examples/suppression/suppression.cs | 4 | ||||
-rw-r--r-- | examples/user/user.cs | 106 | ||||
-rw-r--r-- | examples/whitelabel/whitelabel.cs | 42 |
13 files changed, 775 insertions, 198 deletions
diff --git a/SendGrid/SendGrid/Client.cs b/SendGrid/SendGrid/Client.cs index 388cc3f..be986cb 100644 --- a/SendGrid/SendGrid/Client.cs +++ b/SendGrid/SendGrid/Client.cs @@ -30,6 +30,7 @@ namespace SendGrid requestHeaders.Add("Authorization", "Bearer " + apiKey); requestHeaders.Add("Content-Type", "application/json"); requestHeaders.Add("User-Agent", "sendgrid/" + Version + " csharp"); + requestHeaders.Add("Accept", "application/json"); client = new Client(host: baseUri, requestHeaders: requestHeaders, version: version); } } diff --git a/SendGrid/UnitTest/UnitTest.cs b/SendGrid/UnitTest/UnitTest.cs index b4f00da..1fd8c6d 100644 --- a/SendGrid/UnitTest/UnitTest.cs +++ b/SendGrid/UnitTest/UnitTest.cs @@ -3,7 +3,6 @@ using NUnit.Framework; using SendGrid.Helpers.Mail; using System.Collections.Generic; using System.Net; -using Newtonsoft.Json; namespace UnitTest { @@ -42,10 +41,7 @@ namespace UnitTest mail.AddContent(content); String ret = mail.Get(); - String final = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(ret), - Formatting.None, - new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Ignore }); - Assert.AreEqual(final, "{\"from\":{\"email\":\"test@example.com\"},\"subject\":\"Hello World from the SendGrid CSharp Library\",\"personalizations\":[{\"to\":[{\"email\":\"test@example.com\"}]}],\"content\":[{\"type\":\"text/plain\",\"value\":\"Textual content\"},{\"type\":\"text/html\",\"value\":\"<html><body>HTML content</body></html>\"}]}"); + Assert.AreEqual(ret, "{\"from\":{\"email\":\"test@example.com\"},\"subject\":\"Hello World from the SendGrid CSharp Library\",\"personalizations\":[{\"to\":[{\"email\":\"test@example.com\"}]}],\"content\":[{\"type\":\"text/plain\",\"value\":\"Textual content\"},{\"type\":\"text/html\",\"value\":\"<html><body>HTML content</body></html>\"}]}"); } // All paramaters available for sending an email @@ -235,12 +231,7 @@ namespace UnitTest mail.ReplyTo = email; String ret = mail.Get(); - - String final = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(ret), - Formatting.None, - new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Ignore }); - - Assert.AreEqual(final, "{\"from\":{\"name\":\"Example User\",\"email\":\"test@example.com\"},\"subject\":\"Hello World from the SendGrid CSharp Library\",\"personalizations\":[{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Thank you for signing up, %name%\",\"headers\":{\"X-Test\":\"True\",\"X-Mock\":\"True\"},\"substitutions\":{\"%name%\":\"Example User\",\"%city%\":\"Denver\"},\"custom_args\":{\"marketing\":\"false\",\"transactional\":\"true\"},\"send_at\":1461775051},{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Thank you for signing up, %name%\",\"headers\":{\"X-Test\":\"True\",\"X-Mock\":\"True\"},\"substitutions\":{\"%name%\":\"Example User\",\"%city%\":\"Denver\"},\"custom_args\":{\"marketing\":\"false\",\"transactional\":\"true\"},\"send_at\":1461775051}],\"content\":[{\"type\":\"text/plain\",\"value\":\"Textual content\"},{\"type\":\"text/html\",\"value\":\"<html><body>HTML content</body></html>\"},{\"type\":\"text/calendar\",\"value\":\"Party Time!!\"}],\"attachments\":[{\"content\":\"TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12\",\"type\":\"application/pdf\",\"filename\":\"balance_001.pdf\",\"disposition\":\"attachment\",\"content_id\":\"Balance Sheet\"},{\"content\":\"BwdW\",\"type\":\"image/png\",\"filename\":\"banner.png\",\"disposition\":\"inline\",\"content_id\":\"Banner\"}],\"template_id\":\"13b8f94f-bcae-4ec6-b752-70d6cb59f932\",\"headers\":{\"X-Day\":\"Monday\",\"X-Month\":\"January\"},\"sections\":{\"%section1\":\"Substitution for Section 1 Tag\",\"%section2\":\"Substitution for Section 2 Tag\"},\"categories\":[\"customer\",\"vip\"],\"custom_args\":{\"campaign\":\"welcome\",\"sequence\":\"2\"},\"send_at\":1461775051,\"asm\":{\"group_id\":3,\"groups_to_display\":[1,4,5]},\"ip_pool_name\":\"23\",\"mail_settings\":{\"bcc\":{\"enable\":true,\"email\":\"test@example.com\"},\"bypass_list_management\":{\"enable\":true},\"footer\":{\"enable\":true,\"text\":\"Some Footer Text\",\"html\":\"<bold>Some HTML Here</bold>\"},\"sandbox_mode\":{\"enable\":true},\"spam_check\":{\"enable\":true,\"threshold\":1,\"post_to_url\":\"https://gotchya.example.com\"}},\"tracking_settings\":{\"click_tracking\":{\"enable\":true},\"open_tracking\":{\"enable\":true,\"substitution_tag\":\"Optional tag to replace with the open image in the body of the message\"},\"subscription_tracking\":{\"enable\":true,\"text\":\"text to insert into the text/plain portion of the message\",\"html\":\"<bold>HTML to insert into the text/html portion of the message</bold>\",\"substitution_tag\":\"text to insert into the text/plain portion of the message\"},\"ganalytics\":{\"enable\":true,\"utm_source\":\"some source\",\"utm_medium\":\"some medium\",\"utm_term\":\"some term\",\"utm_content\":\"some content\",\"utm_campaign\":\"some campaign\"}},\"reply_to\":{\"email\":\"test@example.com\"}}"); + Assert.AreEqual(ret, "{\"from\":{\"name\":\"Example User\",\"email\":\"test@example.com\"},\"subject\":\"Hello World from the SendGrid CSharp Library\",\"personalizations\":[{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Thank you for signing up, %name%\",\"headers\":{\"X-Test\":\"True\",\"X-Mock\":\"True\"},\"substitutions\":{\"%name%\":\"Example User\",\"%city%\":\"Denver\"},\"custom_args\":{\"marketing\":\"false\",\"transactional\":\"true\"},\"send_at\":1461775051},{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Thank you for signing up, %name%\",\"headers\":{\"X-Test\":\"True\",\"X-Mock\":\"True\"},\"substitutions\":{\"%name%\":\"Example User\",\"%city%\":\"Denver\"},\"custom_args\":{\"marketing\":\"false\",\"transactional\":\"true\"},\"send_at\":1461775051}],\"content\":[{\"type\":\"text/plain\",\"value\":\"Textual content\"},{\"type\":\"text/html\",\"value\":\"<html><body>HTML content</body></html>\"},{\"type\":\"text/calendar\",\"value\":\"Party Time!!\"}],\"attachments\":[{\"content\":\"TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12\",\"type\":\"application/pdf\",\"filename\":\"balance_001.pdf\",\"disposition\":\"attachment\",\"content_id\":\"Balance Sheet\"},{\"content\":\"BwdW\",\"type\":\"image/png\",\"filename\":\"banner.png\",\"disposition\":\"inline\",\"content_id\":\"Banner\"}],\"template_id\":\"13b8f94f-bcae-4ec6-b752-70d6cb59f932\",\"headers\":{\"X-Day\":\"Monday\",\"X-Month\":\"January\"},\"sections\":{\"%section1\":\"Substitution for Section 1 Tag\",\"%section2\":\"Substitution for Section 2 Tag\"},\"categories\":[\"customer\",\"vip\"],\"custom_args\":{\"campaign\":\"welcome\",\"sequence\":\"2\"},\"send_at\":1461775051,\"asm\":{\"group_id\":3,\"groups_to_display\":[1,4,5]},\"ip_pool_name\":\"23\",\"mail_settings\":{\"bcc\":{\"enable\":true,\"email\":\"test@example.com\"},\"bypass_list_management\":{\"enable\":true},\"footer\":{\"enable\":true,\"text\":\"Some Footer Text\",\"html\":\"<bold>Some HTML Here</bold>\"},\"sandbox_mode\":{\"enable\":true},\"spam_check\":{\"enable\":true,\"threshold\":1,\"post_to_url\":\"https://gotchya.example.com\"}},\"tracking_settings\":{\"click_tracking\":{\"enable\":true},\"open_tracking\":{\"enable\":true,\"substitution_tag\":\"Optional tag to replace with the open image in the body of the message\"},\"subscription_tracking\":{\"enable\":true,\"text\":\"text to insert into the text/plain portion of the message\",\"html\":\"<bold>HTML to insert into the text/html portion of the message</bold>\",\"substitution_tag\":\"text to insert into the text/plain portion of the message\"},\"ganalytics\":{\"enable\":true,\"utm_source\":\"some source\",\"utm_medium\":\"some medium\",\"utm_term\":\"some term\",\"utm_content\":\"some content\",\"utm_campaign\":\"some campaign\"}},\"reply_to\":{\"email\":\"test@example.com\"}}"); } } @@ -382,6 +373,107 @@ namespace UnitTest } [Test] + public void test_alerts_post() + { + string _apiKey = "SendGrid API Key"; + string host = ""; + if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) { + host = Environment.GetEnvironmentVariable("MOCK_HOST"); + } else { + host = "http://localhost:4010"; + } + dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); + string data = @"{ + 'email_to': 'example@example.com', + 'frequency': 'daily', + 'type': 'stats_notification' +}"; + Dictionary<String, String> headers = new Dictionary<String, String>(); + headers.Clear(); + headers.Add("X-Mock", "201"); + dynamic response = sg.client.alerts.post(requestBody: data, requestHeaders: headers); + Assert.AreEqual(response.StatusCode, HttpStatusCode.Created); + } + + [Test] + public void test_alerts_get() + { + string _apiKey = "SendGrid API Key"; + string host = ""; + if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) { + host = Environment.GetEnvironmentVariable("MOCK_HOST"); + } else { + host = "http://localhost:4010"; + } + dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); + Dictionary<String, String> headers = new Dictionary<String, String>(); + headers.Clear(); + headers.Add("X-Mock", "200"); + dynamic response = sg.client.alerts.get(requestHeaders: headers); + Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); + } + + [Test] + public void test_alerts__alert_id__patch() + { + string _apiKey = "SendGrid API Key"; + string host = ""; + if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) { + host = Environment.GetEnvironmentVariable("MOCK_HOST"); + } else { + host = "http://localhost:4010"; + } + dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); + string data = @"{ + 'email_to': 'example@example.com' +}"; + var alert_id = "test_url_param"; + Dictionary<String, String> headers = new Dictionary<String, String>(); + headers.Clear(); + headers.Add("X-Mock", "200"); + dynamic response = sg.client.alerts._(alert_id).patch(requestBody: data, requestHeaders: headers); + Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); + } + + [Test] + public void test_alerts__alert_id__get() + { + string _apiKey = "SendGrid API Key"; + string host = ""; + if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) { + host = Environment.GetEnvironmentVariable("MOCK_HOST"); + } else { + host = "http://localhost:4010"; + } + dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); + var alert_id = "test_url_param"; + Dictionary<String, String> headers = new Dictionary<String, String>(); + headers.Clear(); + headers.Add("X-Mock", "200"); + dynamic response = sg.client.alerts._(alert_id).get(requestHeaders: headers); + Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); + } + + [Test] + public void test_alerts__alert_id__delete() + { + string _apiKey = "SendGrid API Key"; + string host = ""; + if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) { + host = Environment.GetEnvironmentVariable("MOCK_HOST"); + } else { + host = "http://localhost:4010"; + } + dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); + var alert_id = "test_url_param"; + Dictionary<String, String> headers = new Dictionary<String, String>(); + headers.Clear(); + headers.Add("X-Mock", "204"); + dynamic response = sg.client.alerts._(alert_id).delete(requestHeaders: headers); + Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent); + } + + [Test] public void test_api_keys_post() { string _apiKey = "SendGrid API Key"; @@ -394,6 +486,7 @@ namespace UnitTest dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); string data = @"{ 'name': 'My API Key', + 'sample': 'data', 'scopes': [ 'mail.send', 'alerts.create', @@ -418,10 +511,13 @@ namespace UnitTest host = "http://localhost:4010"; } dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); + string queryParams = @"{ + 'limit': 1 +}"; Dictionary<String, String> headers = new Dictionary<String, String>(); headers.Clear(); headers.Add("X-Mock", "200"); - dynamic response = sg.client.api_keys.get(requestHeaders: headers); + dynamic response = sg.client.api_keys.get(queryParams: queryParams, requestHeaders: headers); Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); } @@ -662,6 +758,32 @@ namespace UnitTest } [Test] + public void test_asm_groups__group_id__suppressions_search_post() + { + string _apiKey = "SendGrid API Key"; + string host = ""; + if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) { + host = Environment.GetEnvironmentVariable("MOCK_HOST"); + } else { + host = "http://localhost:4010"; + } + dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); + string data = @"{ + 'recipient_emails': [ + 'exists1@example.com', + 'exists2@example.com', + 'doesnotexists@example.com' + ] +}"; + var group_id = "test_url_param"; + Dictionary<String, String> headers = new Dictionary<String, String>(); + headers.Clear(); + headers.Add("X-Mock", "200"); + dynamic response = sg.client.asm.groups._(group_id).suppressions.search.post(requestBody: data, requestHeaders: headers); + Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); + } + + [Test] public void test_asm_groups__group_id__suppressions__email__delete() { string _apiKey = "SendGrid API Key"; @@ -856,8 +978,8 @@ namespace UnitTest } dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); string queryParams = @"{ - 'limit': 0, - 'offset': 0 + 'limit': 1, + 'offset': 1 }"; Dictionary<String, String> headers = new Dictionary<String, String>(); headers.Clear(); @@ -1334,7 +1456,7 @@ namespace UnitTest 'name': 'newlistname' }"; string queryParams = @"{ - 'list_id': 0 + 'list_id': 1 }"; var list_id = "test_url_param"; Dictionary<String, String> headers = new Dictionary<String, String>(); @@ -1356,7 +1478,7 @@ namespace UnitTest } dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); string queryParams = @"{ - 'list_id': 0 + 'list_id': 1 }"; var list_id = "test_url_param"; Dictionary<String, String> headers = new Dictionary<String, String>(); @@ -1423,7 +1545,7 @@ namespace UnitTest } dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); string queryParams = @"{ - 'list_id': 0, + 'list_id': 1, 'page': 1, 'page_size': 1 }"; @@ -1467,8 +1589,8 @@ namespace UnitTest } dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); string queryParams = @"{ - 'list_id': 0, - 'recipient_id': 0 + 'list_id': 1, + 'recipient_id': 1 }"; var list_id = "test_url_param"; var recipient_id = "test_url_param"; @@ -1628,6 +1750,7 @@ namespace UnitTest } dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); string queryParams = @"{ + '%7Bfield_name%7D': 'test_string', '{field_name}': 'test_string' }"; Dictionary<String, String> headers = new Dictionary<String, String>(); @@ -1818,7 +1941,7 @@ namespace UnitTest } dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); string queryParams = @"{ - 'segment_id': 0 + 'segment_id': 1 }"; var segment_id = "test_url_param"; Dictionary<String, String> headers = new Dictionary<String, String>(); @@ -2341,13 +2464,8 @@ namespace UnitTest 'send_at': 1409348513, 'subject': 'Hello, World!', 'substitutions': { - 'sub': { - '%name%': [ - 'John', - 'Jane', - 'Sam' - ] - } + 'id': 'substitutions', + 'type': 'object' }, 'to': [ { @@ -2960,8 +3078,8 @@ namespace UnitTest } dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); string queryParams = @"{ - 'limit': 0, - 'offset': 0, + 'limit': 1, + 'offset': 1, 'username': 'test_string' }"; Dictionary<String, String> headers = new Dictionary<String, String>(); @@ -3231,7 +3349,7 @@ namespace UnitTest dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); string queryParams = @"{ 'date': 'test_string', - 'limit': 0, + 'limit': 1, 'offset': 1, 'sort_by_direction': 'asc', 'sort_by_metric': 'test_string' @@ -3343,8 +3461,8 @@ namespace UnitTest } dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); string queryParams = @"{ - 'end_time': 0, - 'start_time': 0 + 'end_time': 1, + 'start_time': 1 }"; Dictionary<String, String> headers = new Dictionary<String, String>(); headers.Clear(); @@ -4408,6 +4526,30 @@ namespace UnitTest } [Test] + public void test_user_webhooks_parse_settings_post() + { + string _apiKey = "SendGrid API Key"; + string host = ""; + if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) { + host = Environment.GetEnvironmentVariable("MOCK_HOST"); + } else { + host = "http://localhost:4010"; + } + dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); + string data = @"{ + 'hostname': 'myhostname.com', + 'send_raw': false, + 'spam_check': true, + 'url': 'http://email.myhosthame.com' +}"; + Dictionary<String, String> headers = new Dictionary<String, String>(); + headers.Clear(); + headers.Add("X-Mock", "201"); + dynamic response = sg.client.user.webhooks.parse.settings.post(requestBody: data, requestHeaders: headers); + Assert.AreEqual(response.StatusCode, HttpStatusCode.Created); + } + + [Test] public void test_user_webhooks_parse_settings_get() { string _apiKey = "SendGrid API Key"; @@ -4426,6 +4568,68 @@ namespace UnitTest } [Test] + public void test_user_webhooks_parse_settings__hostname__patch() + { + string _apiKey = "SendGrid API Key"; + string host = ""; + if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) { + host = Environment.GetEnvironmentVariable("MOCK_HOST"); + } else { + host = "http://localhost:4010"; + } + dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); + string data = @"{ + 'send_raw': true, + 'spam_check': false, + 'url': 'http://newdomain.com/parse' +}"; + var hostname = "test_url_param"; + Dictionary<String, String> headers = new Dictionary<String, String>(); + headers.Clear(); + headers.Add("X-Mock", "200"); + dynamic response = sg.client.user.webhooks.parse.settings._(hostname).patch(requestBody: data, requestHeaders: headers); + Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); + } + + [Test] + public void test_user_webhooks_parse_settings__hostname__get() + { + string _apiKey = "SendGrid API Key"; + string host = ""; + if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) { + host = Environment.GetEnvironmentVariable("MOCK_HOST"); + } else { + host = "http://localhost:4010"; + } + dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); + var hostname = "test_url_param"; + Dictionary<String, String> headers = new Dictionary<String, String>(); + headers.Clear(); + headers.Add("X-Mock", "200"); + dynamic response = sg.client.user.webhooks.parse.settings._(hostname).get(requestHeaders: headers); + Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); + } + + [Test] + public void test_user_webhooks_parse_settings__hostname__delete() + { + string _apiKey = "SendGrid API Key"; + string host = ""; + if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) { + host = Environment.GetEnvironmentVariable("MOCK_HOST"); + } else { + host = "http://localhost:4010"; + } + dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host); + var hostname = "test_url_param"; + Dictionary<String, String> headers = new Dictionary<String, String>(); + headers.Clear(); + headers.Add("X-Mock", "204"); + dynamic response = sg.client.user.webhooks.parse.settings._(hostname).delete(requestHeaders: headers); + Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent); + } + + [Test] public void test_user_webhooks_parse_stats_get() { string _apiKey = "SendGrid API Key"; @@ -13,6 +13,7 @@ dynamic sg = new SendGrid.SendGridAPIClient(_apiKey); # Table of Contents * [ACCESS SETTINGS](#access_settings) +* [ALERTS](#alerts) * [API KEYS](#api_keys) * [ASM](#asm) * [BROWSERS](#browsers) @@ -187,6 +188,125 @@ Console.WriteLine(response.Headers.ToString()); Console.ReadLine(); ``` +<a name="alerts"></a> +# ALERTS + +## Create a new Alert + +**This endpoint allows you to create a new alert.** + +Alerts allow you to specify an email address to receive notifications regarding your email usage or statistics. +* Usage alerts allow you to set the threshold at which an alert will be sent. +* Stats notifications allow you to set how frequently you would like to receive email statistics reports. For example, "daily", "weekly", or "monthly". + +For more information about alerts, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/alerts.html). + +### POST /alerts + + +```csharp +string data = @"{ + 'email_to': 'example@example.com', + 'frequency': 'daily', + 'type': 'stats_notification' +}"; +dynamic response = sg.client.alerts.post(requestBody: data); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); +``` + +## Retrieve all alerts + +**This endpoint allows you to retieve all of your alerts.** + +Alerts allow you to specify an email address to receive notifications regarding your email usage or statistics. +* Usage alerts allow you to set the threshold at which an alert will be sent. +* Stats notifications allow you to set how frequently you would like to receive email statistics reports. For example, "daily", "weekly", or "monthly". + +For more information about alerts, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/alerts.html). + +### GET /alerts + + +```csharp +dynamic response = sg.client.alerts.get(); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); +``` + +## Update an alert + +**This endpoint allows you to update an alert.** + +Alerts allow you to specify an email address to receive notifications regarding your email usage or statistics. +* Usage alerts allow you to set the threshold at which an alert will be sent. +* Stats notifications allow you to set how frequently you would like to receive email statistics reports. For example, "daily", "weekly", or "monthly". + +For more information about alerts, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/alerts.html). + +### PATCH /alerts/{alert_id} + + +```csharp +string data = @"{ + 'email_to': 'example@example.com' +}"; +var alert_id = "test_url_param"; +dynamic response = sg.client.alerts._(alert_id).patch(requestBody: data); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); +``` + +## Retrieve a specific alert + +**This endpoint allows you to retrieve a specific alert.** + +Alerts allow you to specify an email address to receive notifications regarding your email usage or statistics. +* Usage alerts allow you to set the threshold at which an alert will be sent. +* Stats notifications allow you to set how frequently you would like to receive email statistics reports. For example, "daily", "weekly", or "monthly". + +For more information about alerts, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/alerts.html). + +### GET /alerts/{alert_id} + + +```csharp +var alert_id = "test_url_param"; +dynamic response = sg.client.alerts._(alert_id).get(); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); +``` + +## Delete an alert + +**This endpoint allows you to delete an alert.** + +Alerts allow you to specify an email address to receive notifications regarding your email usage or statistics. +* Usage alerts allow you to set the threshold at which an alert will be sent. +* Stats notifications allow you to set how frequently you would like to receive email statistics reports. For example, "daily", "weekly", or "monthly". + +For more information about alerts, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/alerts.html). + +### DELETE /alerts/{alert_id} + + +```csharp +var alert_id = "test_url_param"; +dynamic response = sg.client.alerts._(alert_id).delete(); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); +``` + <a name="api_keys"></a> # API KEYS @@ -208,6 +328,7 @@ See the [API Key Permissions List](https://sendgrid.com/docs/API_Reference/Web_A ```csharp string data = @"{ 'name': 'My API Key', + 'sample': 'data', 'scopes': [ 'mail.send', 'alerts.create', @@ -231,7 +352,10 @@ The API Keys feature allows customers to be able to generate an API Key credenti ```csharp -dynamic response = sg.client.api_keys.get(); +string queryParams = @"{ + 'limit': 1 +}"; +dynamic response = sg.client.api_keys.get(queryParams: queryParams); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); @@ -375,6 +499,10 @@ Console.ReadLine(); This endpoint will return information for each group ID that you include in your request. To add a group ID to your request, simply append `&id=` followed by the group ID. +Suppressions are a list of email addresses that will not receive content sent under a given [group](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). + +Suppression groups, or [unsubscribe groups](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html), allow you to label a category of content that you regularly send. This gives your recipients the ability to opt out of a specific set of your email. For example, you might define a group for your transactional email, and one for your marketing email so that your users can continue recieving your transactional email witout having to receive your marketing content. + ### GET /asm/groups @@ -506,6 +634,33 @@ Console.WriteLine(response.Headers.ToString()); Console.ReadLine(); ``` +## Search for suppressions within a group + +**This endpoint allows you to search a suppression group for multiple suppressions.** + +When given a list of email addresses and a group ID, this endpoint will return only the email addresses that have been unsubscribed from the given group. + +Suppressions are a list of email addresses that will not receive content sent under a given [group](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). + +### POST /asm/groups/{group_id}/suppressions/search + + +```csharp +string data = @"{ + 'recipient_emails': [ + 'exists1@example.com', + 'exists2@example.com', + 'doesnotexists@example.com' + ] +}"; +var group_id = "test_url_param"; +dynamic response = sg.client.asm.groups._(group_id).suppressions.search.post(requestBody: data); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); +``` + ## Delete a suppression from a suppression group **This endpoint allows you to remove a suppressed email address from the given suppression group.** @@ -529,7 +684,7 @@ Console.ReadLine(); **This endpoint allows you to retrieve a list of all suppressions.** -Suppressions are email addresses that can be added to [groups](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html) to prevent certain types of emails from being delivered to those addresses. +Suppressions are a list of email addresses that will not receive content sent under a given [group](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). ### GET /asm/suppressions @@ -605,9 +760,9 @@ Console.ReadLine(); ## Retrieve all suppression groups for an email address -**This endpoint will return a list of all suppression groups, indicating if the given email address is suppressed for each group.** +**This endpoint returns the list of all groups that the given email address has been unsubscribed from.** -Suppressions are email addresses that can be added to [groups](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html) to prevent certain types of emails from being delivered to those addresses. +Suppressions are a list of email addresses that will not receive content sent under a given [group](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). ### GET /asm/suppressions/{email} @@ -714,8 +869,8 @@ For more information: ```csharp string queryParams = @"{ - 'limit': 0, - 'offset': 0 + 'limit': 1, + 'offset': 1 }"; dynamic response = sg.client.campaigns.get(queryParams: queryParams); Console.WriteLine(response.StatusCode); @@ -1223,7 +1378,7 @@ string data = @"{ 'name': 'newlistname' }"; string queryParams = @"{ - 'list_id': 0 + 'list_id': 1 }"; var list_id = "test_url_param"; dynamic response = sg.client.contactdb.lists._(list_id).patch(requestBody: data, queryParams: queryParams); @@ -1244,7 +1399,7 @@ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.co ```csharp string queryParams = @"{ - 'list_id': 0 + 'list_id': 1 }"; var list_id = "test_url_param"; dynamic response = sg.client.contactdb.lists._(list_id).get(queryParams: queryParams); @@ -1310,7 +1465,7 @@ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.co ```csharp string queryParams = @"{ - 'list_id': 0, + 'list_id': 1, 'page': 1, 'page_size': 1 }"; @@ -1352,8 +1507,8 @@ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.co ```csharp string queryParams = @"{ - 'list_id': 0, - 'recipient_id': 0 + 'list_id': 1, + 'recipient_id': 1 }"; var list_id = "test_url_param"; var recipient_id = "test_url_param"; @@ -1528,6 +1683,7 @@ The contactdb is a database of your contacts for [SendGrid Marketing Campaigns]( ```csharp string queryParams = @"{ + '%7Bfield_name%7D': 'test_string', '{field_name}': 'test_string' }"; dynamic response = sg.client.contactdb.recipients.search.get(queryParams: queryParams); @@ -1738,7 +1894,7 @@ For more information about segments in Marketing Campaigns, please see our [User ```csharp string queryParams = @"{ - 'segment_id': 0 + 'segment_id': 1 }"; var segment_id = "test_url_param"; dynamic response = sg.client.contactdb.segments._(segment_id).get(queryParams: queryParams); @@ -2323,13 +2479,8 @@ string data = @"{ 'send_at': 1409348513, 'subject': 'Hello, World!', 'substitutions': { - 'sub': { - '%name%': [ - 'John', - 'Jane', - 'Sam' - ] - } + 'id': 'substitutions', + 'type': 'object' }, 'to': [ { @@ -2985,8 +3136,8 @@ For more information about Subusers: ```csharp string queryParams = @"{ - 'limit': 0, - 'offset': 0, + 'limit': 1, + 'offset': 1, 'username': 'test_string' }"; dynamic response = sg.client.subusers.get(queryParams: queryParams); @@ -3262,7 +3413,7 @@ For more information, see our [User Guide](https://sendgrid.com/docs/User_Guide/ ```csharp string queryParams = @"{ 'date': 'test_string', - 'limit': 0, + 'limit': 1, 'offset': 1, 'sort_by_direction': 'asc', 'sort_by_metric': 'test_string' @@ -3390,8 +3541,8 @@ For more information see: ```csharp string queryParams = @"{ - 'end_time': 0, - 'start_time': 0 + 'end_time': 1, + 'start_time': 1 }"; dynamic response = sg.client.suppression.bounces.get(queryParams: queryParams); Console.WriteLine(response.StatusCode); @@ -4551,7 +4702,7 @@ string data = @"{ 'unsubscribe': true, 'url': 'url' }"; -dynamic response = sg.client.user.webhooks._("event").settings.patch(requestBody: data); +dynamic response = sg.client.user.webhooks._("_("event")").settings.patch(requestBody: data); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); @@ -4572,7 +4723,7 @@ Common uses of this data are to remove unsubscribes, react to spam reports, dete ```csharp -dynamic response = sg.client.user.webhooks._("event").settings.get(); +dynamic response = sg.client.user.webhooks._("_("event")").settings.get(); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); @@ -4594,18 +4745,41 @@ Common uses of this data are to remove unsubscribes, react to spam reports, dete string data = @"{ 'url': 'url' }"; -dynamic response = sg.client.user.webhooks._("event").test.post(requestBody: data); +dynamic response = sg.client.user.webhooks._("_("event")").test.post(requestBody: data); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); +``` + +## Create a parse setting + +**This endpoint allows you to create a new inbound parse setting.** + +The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the content, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html). + +### POST /user/webhooks/parse/settings + + +```csharp +string data = @"{ + 'hostname': 'myhostname.com', + 'send_raw': false, + 'spam_check': true, + 'url': 'http://email.myhosthame.com' +}"; +dynamic response = sg.client.user.webhooks.parse.settings.post(requestBody: data); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); Console.ReadLine(); ``` -## Retrieve Parse Webhook settings +## Retrieve all parse settings -**This endpoint allows you to retrieve your current inbound parse webhook settings.** +**This endpoint allows you to retrieve all of your current inbound parse settings.** -SendGrid can parse the attachments and contents of incoming emails. The Parse API will POST the parsed email to a URL that you specify. For more information, see our Inbound [Parse Webhook documentation](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html). +The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the contnet, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html). ### GET /user/webhooks/parse/settings @@ -4618,6 +4792,65 @@ Console.WriteLine(response.Headers.ToString()); Console.ReadLine(); ``` +## Update a parse setting + +**This endpoint allows you to update a specific inbound parse setting.** + +The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the contnet, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html). + +### PATCH /user/webhooks/parse/settings/{hostname} + + +```csharp +string data = @"{ + 'send_raw': true, + 'spam_check': false, + 'url': 'http://newdomain.com/parse' +}"; +var hostname = "test_url_param"; +dynamic response = sg.client.user.webhooks.parse.settings._(hostname).patch(requestBody: data); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); +``` + +## Retrieve a specific parse setting + +**This endpoint allows you to retrieve a specific inbound parse setting.** + +The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the contnet, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html). + +### GET /user/webhooks/parse/settings/{hostname} + + +```csharp +var hostname = "test_url_param"; +dynamic response = sg.client.user.webhooks.parse.settings._(hostname).get(); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); +``` + +## Delete a parse setting + +**This endpoint allows you to delete a specific inbound parse setting.** + +The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the contnet, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html). + +### DELETE /user/webhooks/parse/settings/{hostname} + + +```csharp +var hostname = "test_url_param"; +dynamic response = sg.client.user.webhooks.parse.settings._(hostname).delete(); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); +``` + ## Retrieves Inbound Parse Webhook statistics. **This endpoint allows you to retrieve the statistics for your Parse Webhook useage.** @@ -4726,7 +4959,7 @@ For more information on whitelabeling, please see our [User Guide](https://sendg ```csharp -dynamic response = sg.client.whitelabel.domains._("default").get(); +dynamic response = sg.client.whitelabel.domains._("_("default")").get(); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); @@ -5144,7 +5377,7 @@ For more information, please see our [User Guide](https://sendgrid.com/docs/API_ string queryParams = @"{ 'domain': 'test_string' }"; -dynamic response = sg.client.whitelabel.links._("default").get(queryParams: queryParams); +dynamic response = sg.client.whitelabel.links._("_("default")").get(queryParams: queryParams); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); diff --git a/examples/alerts/alerts.cs b/examples/alerts/alerts.cs new file mode 100644 index 0000000..26bd8f2 --- /dev/null +++ b/examples/alerts/alerts.cs @@ -0,0 +1,67 @@ +using System; +using SendGrid.Helpers.Mail; // If you are using the Mail Helper + +string _apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY", EnvironmentVariableTarget.User); +dynamic sg = new SendGrid.SendGridAPIClient(_apiKey); + +//////////////////////////////////////////////////////// +// Create a new Alert +// POST /alerts + +string data = @"{ + 'email_to': 'example@example.com', + 'frequency': 'daily', + 'type': 'stats_notification' +}"; +dynamic response = sg.client.alerts.post(requestBody: data); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); + +//////////////////////////////////////////////////////// +// Retrieve all alerts +// GET /alerts + +dynamic response = sg.client.alerts.get(); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); + +//////////////////////////////////////////////////////// +// Update an alert +// PATCH /alerts/{alert_id} + +string data = @"{ + 'email_to': 'example@example.com' +}"; +var alert_id = "test_url_param"; +dynamic response = sg.client.alerts._(alert_id).patch(requestBody: data); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); + +//////////////////////////////////////////////////////// +// Retrieve a specific alert +// GET /alerts/{alert_id} + +var alert_id = "test_url_param"; +dynamic response = sg.client.alerts._(alert_id).get(); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); + +//////////////////////////////////////////////////////// +// Delete an alert +// DELETE /alerts/{alert_id} + +var alert_id = "test_url_param"; +dynamic response = sg.client.alerts._(alert_id).delete(); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); + diff --git a/examples/apikeys/apikeys.cs b/examples/apikeys/apikeys.cs index 97a3add..67dce33 100644 --- a/examples/apikeys/apikeys.cs +++ b/examples/apikeys/apikeys.cs @@ -10,6 +10,7 @@ dynamic sg = new SendGrid.SendGridAPIClient(_apiKey); string data = @"{ 'name': 'My API Key', + 'sample': 'data', 'scopes': [ 'mail.send', 'alerts.create', @@ -26,7 +27,10 @@ Console.ReadLine(); // Retrieve all API Keys belonging to the authenticated user // GET /api_keys -dynamic response = sg.client.api_keys.get(); +string queryParams = @"{ + 'limit': 1 +}"; +dynamic response = sg.client.api_keys.get(queryParams: queryParams); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); diff --git a/examples/asm/asm.cs b/examples/asm/asm.cs index 00758ef..fb2a5c6 100644 --- a/examples/asm/asm.cs +++ b/examples/asm/asm.cs @@ -99,6 +99,24 @@ Console.WriteLine(response.Headers.ToString()); Console.ReadLine(); //////////////////////////////////////////////////////// +// Search for suppressions within a group +// POST /asm/groups/{group_id}/suppressions/search + +string data = @"{ + 'recipient_emails': [ + 'exists1@example.com', + 'exists2@example.com', + 'doesnotexists@example.com' + ] +}"; +var group_id = "test_url_param"; +dynamic response = sg.client.asm.groups._(group_id).suppressions.search.post(requestBody: data); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); + +//////////////////////////////////////////////////////// // Delete a suppression from a suppression group // DELETE /asm/groups/{group_id}/suppressions/{email} diff --git a/examples/campaigns/campaigns.cs b/examples/campaigns/campaigns.cs index 999566b..c16baa5 100644 --- a/examples/campaigns/campaigns.cs +++ b/examples/campaigns/campaigns.cs @@ -39,8 +39,8 @@ Console.ReadLine(); // GET /campaigns string queryParams = @"{ - 'limit': 0, - 'offset': 0 + 'limit': 1, + 'offset': 1 }"; dynamic response = sg.client.campaigns.get(queryParams: queryParams); Console.WriteLine(response.StatusCode); diff --git a/examples/contactdb/contactdb.cs b/examples/contactdb/contactdb.cs index a149413..9afbd9b 100644 --- a/examples/contactdb/contactdb.cs +++ b/examples/contactdb/contactdb.cs @@ -97,7 +97,7 @@ string data = @"{ 'name': 'newlistname' }"; string queryParams = @"{ - 'list_id': 0 + 'list_id': 1 }"; var list_id = "test_url_param"; dynamic response = sg.client.contactdb.lists._(list_id).patch(requestBody: data, queryParams: queryParams); @@ -111,7 +111,7 @@ Console.ReadLine(); // GET /contactdb/lists/{list_id} string queryParams = @"{ - 'list_id': 0 + 'list_id': 1 }"; var list_id = "test_url_param"; dynamic response = sg.client.contactdb.lists._(list_id).get(queryParams: queryParams); @@ -154,7 +154,7 @@ Console.ReadLine(); // GET /contactdb/lists/{list_id}/recipients string queryParams = @"{ - 'list_id': 0, + 'list_id': 1, 'page': 1, 'page_size': 1 }"; @@ -182,8 +182,8 @@ Console.ReadLine(); // DELETE /contactdb/lists/{list_id}/recipients/{recipient_id} string queryParams = @"{ - 'list_id': 0, - 'recipient_id': 0 + 'list_id': 1, + 'recipient_id': 1 }"; var list_id = "test_url_param"; var recipient_id = "test_url_param"; @@ -287,6 +287,7 @@ Console.ReadLine(); // GET /contactdb/recipients/search string queryParams = @"{ + '%7Bfield_name%7D': 'test_string', '{field_name}': 'test_string' }"; dynamic response = sg.client.contactdb.recipients.search.get(queryParams: queryParams); @@ -413,7 +414,7 @@ Console.ReadLine(); // GET /contactdb/segments/{segment_id} string queryParams = @"{ - 'segment_id': 0 + 'segment_id': 1 }"; var segment_id = "test_url_param"; dynamic response = sg.client.contactdb.segments._(segment_id).get(queryParams: queryParams); diff --git a/examples/mail/mail.cs b/examples/mail/mail.cs index b33872c..66e118b 100644 --- a/examples/mail/mail.cs +++ b/examples/mail/mail.cs @@ -32,143 +32,138 @@ Console.ReadLine(); string data = @"{ 'asm': { - 'group_id': 1, + 'group_id': 1, 'groups_to_display': [ - 1, - 2, + 1, + 2, 3 ] - }, + }, 'attachments': [ { - 'content': '[BASE64 encoded content block here]', - 'content_id': 'ii_139db99fdb5c3704', - 'disposition': 'inline', - 'filename': 'file1.jpg', - 'name': 'file1', + 'content': '[BASE64 encoded content block here]', + 'content_id': 'ii_139db99fdb5c3704', + 'disposition': 'inline', + 'filename': 'file1.jpg', + 'name': 'file1', 'type': 'jpg' } - ], - 'batch_id': '[YOUR BATCH ID GOES HERE]', + ], + 'batch_id': '[YOUR BATCH ID GOES HERE]', 'categories': [ - 'category1', + 'category1', 'category2' - ], + ], 'content': [ { - 'type': 'text/html', + 'type': 'text/html', 'value': '<html><p>Hello, world!</p><img src=[CID GOES HERE]></img></html>' } - ], + ], 'custom_args': { - 'New Argument 1': 'New Value 1', - 'activationAttempt': '1', + 'New Argument 1': 'New Value 1', + 'activationAttempt': '1', 'customerAccountNumber': '[CUSTOMER ACCOUNT NUMBER GOES HERE]' - }, + }, 'from': { - 'email': 'sam.smith@example.com', + 'email': 'sam.smith@example.com', 'name': 'Sam Smith' - }, - 'headers': {}, - 'ip_pool_name': '[YOUR POOL NAME GOES HERE]', + }, + 'headers': {}, + 'ip_pool_name': '[YOUR POOL NAME GOES HERE]', 'mail_settings': { 'bcc': { - 'email': 'ben.doe@example.com', + 'email': 'ben.doe@example.com', 'enable': true - }, + }, 'bypass_list_management': { 'enable': true - }, + }, 'footer': { - 'enable': true, - 'html': '<p>Thanks</br>The SendGrid Team</p>', + 'enable': true, + 'html': '<p>Thanks</br>The SendGrid Team</p>', 'text': 'Thanks,/n The SendGrid Team' - }, + }, 'sandbox_mode': { 'enable': false - }, + }, 'spam_check': { - 'enable': true, - 'post_to_url': 'http://example.com/compliance', + 'enable': true, + 'post_to_url': 'http://example.com/compliance', 'threshold': 3 } - }, + }, 'personalizations': [ { 'bcc': [ { - 'email': 'sam.doe@example.com', + 'email': 'sam.doe@example.com', 'name': 'Sam Doe' } - ], + ], 'cc': [ { - 'email': 'jane.doe@example.com', + 'email': 'jane.doe@example.com', 'name': 'Jane Doe' } - ], + ], 'custom_args': { - 'New Argument 1': 'New Value 1', - 'activationAttempt': '1', + 'New Argument 1': 'New Value 1', + 'activationAttempt': '1', 'customerAccountNumber': '[CUSTOMER ACCOUNT NUMBER GOES HERE]' - }, + }, 'headers': { - 'X-Accept-Language': 'en', + 'X-Accept-Language': 'en', 'X-Mailer': 'MyApp' - }, - 'send_at': 1409348513, - 'subject': 'Hello, World!', + }, + 'send_at': 1409348513, + 'subject': 'Hello, World!', 'substitutions': { - 'sub': { - '%name%': [ - 'John', - 'Jane', - 'Sam' - ] - } - }, + 'id': 'substitutions', + 'type': 'object' + }, 'to': [ { - 'email': 'john.doe@example.com', + 'email': 'john.doe@example.com', 'name': 'John Doe' } ] } - ], + ], 'reply_to': { - 'email': 'sam.smith@example.com', + 'email': 'sam.smith@example.com', 'name': 'Sam Smith' - }, + }, 'sections': { 'section': { - ':sectionName1': 'section 1 text', + ':sectionName1': 'section 1 text', ':sectionName2': 'section 2 text' } - }, - 'send_at': 1409348513, - 'subject': 'Hello, World!', - 'template_id': '[YOUR TEMPLATE ID GOES HERE]', + }, + 'send_at': 1409348513, + 'subject': 'Hello, World!', + 'template_id': '[YOUR TEMPLATE ID GOES HERE]', 'tracking_settings': { 'click_tracking': { - 'enable': true, + 'enable': true, 'enable_text': true - }, + }, 'ganalytics': { - 'enable': true, - 'utm_campaign': '[NAME OF YOUR REFERRER SOURCE]', - 'utm_content': '[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]', - 'utm_medium': '[NAME OF YOUR MARKETING MEDIUM e.g. email]', - 'utm_name': '[NAME OF YOUR CAMPAIGN]', + 'enable': true, + 'utm_campaign': '[NAME OF YOUR REFERRER SOURCE]', + 'utm_content': '[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]', + 'utm_medium': '[NAME OF YOUR MARKETING MEDIUM e.g. email]', + 'utm_name': '[NAME OF YOUR CAMPAIGN]', 'utm_term': '[IDENTIFY PAID KEYWORDS HERE]' - }, + }, 'open_tracking': { - 'enable': true, + 'enable': true, 'substitution_tag': '%opentrack' - }, + }, 'subscription_tracking': { - 'enable': true, - 'html': 'If you would like to unsubscribe and stop receiving these emails <% clickhere %>.', - 'substitution_tag': '<%click here%>', + 'enable': true, + 'html': 'If you would like to unsubscribe and stop receiving these emails <% clickhere %>.', + 'substitution_tag': '<%click here%>', 'text': 'If you would like to unsubscribe and stop receiveing these emails <% click here %>.' } } diff --git a/examples/subusers/subusers.cs b/examples/subusers/subusers.cs index 58935ae..942ad5e 100644 --- a/examples/subusers/subusers.cs +++ b/examples/subusers/subusers.cs @@ -28,8 +28,8 @@ Console.ReadLine(); // GET /subusers string queryParams = @"{ - 'limit': 0, - 'offset': 0, + 'limit': 1, + 'offset': 1, 'username': 'test_string' }"; dynamic response = sg.client.subusers.get(queryParams: queryParams); @@ -203,7 +203,7 @@ Console.ReadLine(); string queryParams = @"{ 'date': 'test_string', - 'limit': 0, + 'limit': 1, 'offset': 1, 'sort_by_direction': 'asc', 'sort_by_metric': 'test_string' diff --git a/examples/suppression/suppression.cs b/examples/suppression/suppression.cs index 0e1d757..4ce0623 100644 --- a/examples/suppression/suppression.cs +++ b/examples/suppression/suppression.cs @@ -64,8 +64,8 @@ Console.ReadLine(); // GET /suppression/bounces string queryParams = @"{ - 'end_time': 0, - 'start_time': 0 + 'end_time': 1, + 'start_time': 1 }"; dynamic response = sg.client.suppression.bounces.get(queryParams: queryParams); Console.WriteLine(response.StatusCode); diff --git a/examples/user/user.cs b/examples/user/user.cs index 7b06150..8fef557 100644 --- a/examples/user/user.cs +++ b/examples/user/user.cs @@ -52,7 +52,7 @@ Console.ReadLine(); // PUT /user/password string data = @"{ - 'new_password': 'new_password', + 'new_password': 'new_password', 'old_password': 'old_password' }"; dynamic response = sg.client.user.password.put(requestBody: data); @@ -66,8 +66,8 @@ Console.ReadLine(); // PATCH /user/profile string data = @"{ - 'city': 'Orange', - 'first_name': 'Example', + 'city': 'Orange', + 'first_name': 'Example', 'last_name': 'User' }"; dynamic response = sg.client.user.profile.patch(requestBody: data); @@ -91,7 +91,7 @@ Console.ReadLine(); // POST /user/scheduled_sends string data = @"{ - 'batch_id': 'YOUR_BATCH_ID', + 'batch_id': 'YOUR_BATCH_ID', 'status': 'pause' }"; dynamic response = sg.client.user.scheduled_sends.post(requestBody: data); @@ -151,7 +151,7 @@ Console.ReadLine(); // PATCH /user/settings/enforced_tls string data = @"{ - 'require_tls': true, + 'require_tls': true, 'require_valid_cert': false }"; dynamic response = sg.client.user.settings.enforced_tls.patch(requestBody: data); @@ -198,21 +198,21 @@ Console.ReadLine(); // PATCH /user/webhooks/event/settings string data = @"{ - 'bounce': true, - 'click': true, - 'deferred': true, - 'delivered': true, - 'dropped': true, - 'enabled': true, - 'group_resubscribe': true, - 'group_unsubscribe': true, - 'open': true, - 'processed': true, - 'spam_report': true, - 'unsubscribe': true, + 'bounce': true, + 'click': true, + 'deferred': true, + 'delivered': true, + 'dropped': true, + 'enabled': true, + 'group_resubscribe': true, + 'group_unsubscribe': true, + 'open': true, + 'processed': true, + 'spam_report': true, + 'unsubscribe': true, 'url': 'url' }"; -dynamic response = sg.client.user.webhooks._("event").settings.patch(requestBody: data); +dynamic response = sg.client.user.webhooks._("_("event")").settings.patch(requestBody: data); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); @@ -222,27 +222,43 @@ Console.ReadLine(); // Retrieve Event Webhook settings // GET /user/webhooks/event/settings -dynamic response = sg.client.user.webhooks._("event").settings.get(); +dynamic response = sg.client.user.webhooks._("_("event")").settings.get(); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); Console.ReadLine(); //////////////////////////////////////////////////////// -// Test Event Notification Settings +// Test Event Notification Settings // POST /user/webhooks/event/test string data = @"{ 'url': 'url' }"; -dynamic response = sg.client.user.webhooks._("event").test.post(requestBody: data); +dynamic response = sg.client.user.webhooks._("_("event")").test.post(requestBody: data); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); Console.ReadLine(); //////////////////////////////////////////////////////// -// Retrieve Parse Webhook settings +// Create a parse setting +// POST /user/webhooks/parse/settings + +string data = @"{ + 'hostname': 'myhostname.com', + 'send_raw': false, + 'spam_check': true, + 'url': 'http://email.myhosthame.com' +}"; +dynamic response = sg.client.user.webhooks.parse.settings.post(requestBody: data); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); + +//////////////////////////////////////////////////////// +// Retrieve all parse settings // GET /user/webhooks/parse/settings dynamic response = sg.client.user.webhooks.parse.settings.get(); @@ -252,14 +268,52 @@ Console.WriteLine(response.Headers.ToString()); Console.ReadLine(); //////////////////////////////////////////////////////// +// Update a parse setting +// PATCH /user/webhooks/parse/settings/{hostname} + +string data = @"{ + 'send_raw': true, + 'spam_check': false, + 'url': 'http://newdomain.com/parse' +}"; +var hostname = "test_url_param"; +dynamic response = sg.client.user.webhooks.parse.settings._(hostname).patch(requestBody: data); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); + +//////////////////////////////////////////////////////// +// Retrieve a specific parse setting +// GET /user/webhooks/parse/settings/{hostname} + +var hostname = "test_url_param"; +dynamic response = sg.client.user.webhooks.parse.settings._(hostname).get(); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); + +//////////////////////////////////////////////////////// +// Delete a parse setting +// DELETE /user/webhooks/parse/settings/{hostname} + +var hostname = "test_url_param"; +dynamic response = sg.client.user.webhooks.parse.settings._(hostname).delete(); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); + +//////////////////////////////////////////////////////// // Retrieves Inbound Parse Webhook statistics. // GET /user/webhooks/parse/stats string queryParams = @"{ - 'aggregated_by': 'day', - 'end_date': '2016-04-01', - 'limit': 'test_string', - 'offset': 'test_string', + 'aggregated_by': 'day', + 'end_date': '2016-04-01', + 'limit': 'test_string', + 'offset': 'test_string', 'start_date': '2016-01-01' }"; dynamic response = sg.client.user.webhooks.parse.stats.get(queryParams: queryParams); diff --git a/examples/whitelabel/whitelabel.cs b/examples/whitelabel/whitelabel.cs index 9b4c0b1..3f856e1 100644 --- a/examples/whitelabel/whitelabel.cs +++ b/examples/whitelabel/whitelabel.cs @@ -9,15 +9,15 @@ dynamic sg = new SendGrid.SendGridAPIClient(_apiKey); // POST /whitelabel/domains string data = @"{ - 'automatic_security': false, - 'custom_spf': true, - 'default': true, - 'domain': 'example.com', + 'automatic_security': false, + 'custom_spf': true, + 'default': true, + 'domain': 'example.com', 'ips': [ - '192.168.1.1', + '192.168.1.1', '192.168.1.2' - ], - 'subdomain': 'news', + ], + 'subdomain': 'news', 'username': 'john@example.com' }"; dynamic response = sg.client.whitelabel.domains.post(requestBody: data); @@ -31,10 +31,10 @@ Console.ReadLine(); // GET /whitelabel/domains string queryParams = @"{ - 'domain': 'test_string', - 'exclude_subusers': 'true', - 'limit': 1, - 'offset': 1, + 'domain': 'test_string', + 'exclude_subusers': 'true', + 'limit': 1, + 'offset': 1, 'username': 'test_string' }"; dynamic response = sg.client.whitelabel.domains.get(queryParams: queryParams); @@ -47,7 +47,7 @@ Console.ReadLine(); // Get the default domain whitelabel. // GET /whitelabel/domains/default -dynamic response = sg.client.whitelabel.domains._("default").get(); +dynamic response = sg.client.whitelabel.domains._("_("default")").get(); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); @@ -78,7 +78,7 @@ Console.ReadLine(); // PATCH /whitelabel/domains/{domain_id} string data = @"{ - 'custom_spf': true, + 'custom_spf': true, 'default': false }"; var domain_id = "test_url_param"; @@ -166,8 +166,8 @@ Console.ReadLine(); // POST /whitelabel/ips string data = @"{ - 'domain': 'example.com', - 'ip': '192.168.1.1', + 'domain': 'example.com', + 'ip': '192.168.1.1', 'subdomain': 'email' }"; dynamic response = sg.client.whitelabel.ips.post(requestBody: data); @@ -181,8 +181,8 @@ Console.ReadLine(); // GET /whitelabel/ips string queryParams = @"{ - 'ip': 'test_string', - 'limit': 1, + 'ip': 'test_string', + 'limit': 1, 'offset': 1 }"; dynamic response = sg.client.whitelabel.ips.get(queryParams: queryParams); @@ -229,12 +229,12 @@ Console.ReadLine(); // POST /whitelabel/links string data = @"{ - 'default': true, - 'domain': 'example.com', + 'default': true, + 'domain': 'example.com', 'subdomain': 'mail' }"; string queryParams = @"{ - 'limit': 1, + 'limit': 1, 'offset': 1 }"; dynamic response = sg.client.whitelabel.links.post(requestBody: data, queryParams: queryParams); @@ -263,7 +263,7 @@ Console.ReadLine(); string queryParams = @"{ 'domain': 'test_string' }"; -dynamic response = sg.client.whitelabel.links._("default").get(queryParams: queryParams); +dynamic response = sg.client.whitelabel.links._("_("default")").get(queryParams: queryParams); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Body.ReadAsStringAsync().Result); Console.WriteLine(response.Headers.ToString()); |