diff --git a/CHANGELOG.md b/CHANGELOG.md index a5de7b606..9f31ea843 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,20 @@ # Change Log All notable changes to this project will be documented in this file. +## [7.0.6] - 2016-07-12 +### Added +- Update docs, unit tests and examples to include Sender ID + ## [7.0.5] - 2016-07-08 ### Added - Tests now mocked automatically against [prism](https://stoplight.io/prism/) ## [7.0.4] - 2016-07-05 -### Added -- Accept: application/json header per https://sendgrid.com/docs/API_Reference/Web_API_v3/How_To_Use_The_Web_API_v3/requests.html +### Added +- Accept: application/json header per https://sendgrid.com/docs/API_Reference/Web_API_v3/How_To_Use_The_Web_API_v3/requests.html -### Updated -- Content based on our updated [Swagger/OAI doc](https://github.com/sendgrid/sendgrid-oai) +### Updated +- Content based on our updated [Swagger/OAI doc](https://github.com/sendgrid/sendgrid-oai) ## [7.0.3] - 2016-06-28 ### Fixed @@ -22,7 +26,7 @@ All notable changes to this project will be documented in this file. ## [7.0.1] - 2016-06-15 ### Fixed -- Hard-coded subject in mail helper: https://github.com/sendgrid/sendgrid-csharp/issues/234 +- Hard-coded subject in mail helper: https://github.com/sendgrid/sendgrid-csharp/issues/234 - Thanks [digime99](https://github.com/digime99)! ## [7.0.0] - 2016-06-13 diff --git a/SendGrid/Example/Properties/AssemblyInfo.cs b/SendGrid/Example/Properties/AssemblyInfo.cs index ef92cf21f..acda2b017 100644 --- a/SendGrid/Example/Properties/AssemblyInfo.cs +++ b/SendGrid/Example/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("7.0.5")] -[assembly: AssemblyFileVersion("7.0.5")] \ No newline at end of file +[assembly: AssemblyVersion("7.0.6")] +[assembly: AssemblyFileVersion("7.0.6")] \ No newline at end of file diff --git a/SendGrid/SendGrid/Properties/AssemblyInfo.cs b/SendGrid/SendGrid/Properties/AssemblyInfo.cs index 11fd49839..f4714045f 100644 --- a/SendGrid/SendGrid/Properties/AssemblyInfo.cs +++ b/SendGrid/SendGrid/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("7.0.5")] -[assembly: AssemblyFileVersion("7.0.5")] +[assembly: AssemblyVersion("7.0.6")] +[assembly: AssemblyFileVersion("7.0.6")] diff --git a/SendGrid/UnitTest/Properties/AssemblyInfo.cs b/SendGrid/UnitTest/Properties/AssemblyInfo.cs index 5257d49c7..65149d3ad 100644 --- a/SendGrid/UnitTest/Properties/AssemblyInfo.cs +++ b/SendGrid/UnitTest/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("7.0.5")] -[assembly: AssemblyFileVersion("7.0.5")] +[assembly: AssemblyVersion("7.0.6")] +[assembly: AssemblyFileVersion("7.0.6")] diff --git a/SendGrid/UnitTest/UnitTest.cs b/SendGrid/UnitTest/UnitTest.cs index 85e246f06..d312e4a32 100644 --- a/SendGrid/UnitTest/UnitTest.cs +++ b/SendGrid/UnitTest/UnitTest.cs @@ -1222,7 +1222,6 @@ public void test_contactdb_recipients_count_get() public void test_contactdb_recipients_search_get() { string queryParams = @"{ - '%7Bfield_name%7D': 'test_string', '{field_name}': 'test_string' }"; Dictionary headers = new Dictionary(); @@ -2062,6 +2061,104 @@ public void test_scopes_get() Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); } + [Test] + public void test_senders_post() + { + string data = @"{ + 'address': '123 Elm St.', + 'address_2': 'Apt. 456', + 'city': 'Denver', + 'country': 'United States', + 'from': { + 'email': 'from@example.com', + 'name': 'Example INC' + }, + 'nickname': 'My Sender ID', + 'reply_to': { + 'email': 'replyto@example.com', + 'name': 'Example INC' + }, + 'state': 'Colorado', + 'zip': '80202' +}"; + Dictionary headers = new Dictionary(); + headers.Clear(); + headers.Add("X-Mock", "201"); + dynamic response = sg.client.senders.post(requestBody: data, requestHeaders: headers); + Assert.AreEqual(response.StatusCode, HttpStatusCode.Created); + } + + [Test] + public void test_senders_get() + { + Dictionary headers = new Dictionary(); + headers.Clear(); + headers.Add("X-Mock", "200"); + dynamic response = sg.client.senders.get(requestHeaders: headers); + Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); + } + + [Test] + public void test_senders__sender_id__patch() + { + string data = @"{ + 'address': '123 Elm St.', + 'address_2': 'Apt. 456', + 'city': 'Denver', + 'country': 'United States', + 'from': { + 'email': 'from@example.com', + 'name': 'Example INC' + }, + 'nickname': 'My Sender ID', + 'reply_to': { + 'email': 'replyto@example.com', + 'name': 'Example INC' + }, + 'state': 'Colorado', + 'zip': '80202' +}"; + var sender_id = "test_url_param"; + Dictionary headers = new Dictionary(); + headers.Clear(); + headers.Add("X-Mock", "200"); + dynamic response = sg.client.senders._(sender_id).patch(requestBody: data, requestHeaders: headers); + Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); + } + + [Test] + public void test_senders__sender_id__get() + { + var sender_id = "test_url_param"; + Dictionary headers = new Dictionary(); + headers.Clear(); + headers.Add("X-Mock", "200"); + dynamic response = sg.client.senders._(sender_id).get(requestHeaders: headers); + Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); + } + + [Test] + public void test_senders__sender_id__delete() + { + var sender_id = "test_url_param"; + Dictionary headers = new Dictionary(); + headers.Clear(); + headers.Add("X-Mock", "204"); + dynamic response = sg.client.senders._(sender_id).delete(requestHeaders: headers); + Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent); + } + + [Test] + public void test_senders__sender_id__resend_verification_post() + { + var sender_id = "test_url_param"; + Dictionary headers = new Dictionary(); + headers.Clear(); + headers.Add("X-Mock", "204"); + dynamic response = sg.client.senders._(sender_id).resend_verification.post(requestHeaders: headers); + Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent); + } + [Test] public void test_stats_get() { diff --git a/USAGE.md b/USAGE.md index 08d539203..e65fb6ee4 100644 --- a/USAGE.md +++ b/USAGE.md @@ -29,6 +29,7 @@ dynamic sg = new SendGrid.SendGridAPIClient(_apiKey); * [MAILBOX PROVIDERS](#mailbox_providers) * [PARTNER SETTINGS](#partner_settings) * [SCOPES](#scopes) +* [SENDERS](#senders) * [STATS](#stats) * [SUBUSERS](#subusers) * [SUPPRESSION](#suppression) @@ -1683,7 +1684,6 @@ 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); @@ -3063,6 +3063,153 @@ Console.WriteLine(response.Headers.ToString()); Console.ReadLine(); ``` + +# SENDERS + +## Create a Sender Identity + +**This endpoint allows you to create a new sender identity.** + +*You may create up to 100 unique sender identities.* + +Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`. + +### POST /senders + + +```csharp +string data = @"{ + 'address': '123 Elm St.', + 'address_2': 'Apt. 456', + 'city': 'Denver', + 'country': 'United States', + 'from': { + 'email': 'from@example.com', + 'name': 'Example INC' + }, + 'nickname': 'My Sender ID', + 'reply_to': { + 'email': 'replyto@example.com', + 'name': 'Example INC' + }, + 'state': 'Colorado', + 'zip': '80202' +}"; +dynamic response = sg.client.senders.post(requestBody: data); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); +``` + +## Get all Sender Identities + +**This endpoint allows you to retrieve a list of all sender identities that have been created for your account.** + +Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`. + +### GET /senders + + +```csharp +dynamic response = sg.client.senders.get(); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); +``` + +## Update a Sender Identity + +**This endpoint allows you to update a sender identity.** + +Updates to `from.email` require re-verification. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`. + +Partial updates are allowed, but fields that are marked as "required" in the POST (create) endpoint must not be nil if that field is included in the PATCH request. + +### PATCH /senders/{sender_id} + + +```csharp +string data = @"{ + 'address': '123 Elm St.', + 'address_2': 'Apt. 456', + 'city': 'Denver', + 'country': 'United States', + 'from': { + 'email': 'from@example.com', + 'name': 'Example INC' + }, + 'nickname': 'My Sender ID', + 'reply_to': { + 'email': 'replyto@example.com', + 'name': 'Example INC' + }, + 'state': 'Colorado', + 'zip': '80202' +}"; +var sender_id = "test_url_param"; +dynamic response = sg.client.senders._(sender_id).patch(requestBody: data); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); +``` + +## View a Sender Identity + +**This endpoint allows you to retrieve a specific sender identity.** + +Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`. + +### GET /senders/{sender_id} + + +```csharp +var sender_id = "test_url_param"; +dynamic response = sg.client.senders._(sender_id).get(); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); +``` + +## Delete a Sender Identity + +**This endoint allows you to delete one of your sender identities.** + +Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`. + +### DELETE /senders/{sender_id} + + +```csharp +var sender_id = "test_url_param"; +dynamic response = sg.client.senders._(sender_id).delete(); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); +``` + +## Resend Sender Identity Verification + +**This enpdoint allows you to resend a sender identity verification email.** + +Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`. + +### POST /senders/{sender_id}/resend_verification + + +```csharp +var sender_id = "test_url_param"; +dynamic response = sg.client.senders._(sender_id).resend_verification.post(); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); +``` + # STATS diff --git a/examples/contactdb/contactdb.cs b/examples/contactdb/contactdb.cs index 9afbd9b1e..38e6e015c 100644 --- a/examples/contactdb/contactdb.cs +++ b/examples/contactdb/contactdb.cs @@ -287,7 +287,6 @@ // 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); diff --git a/examples/senders/senders.cs b/examples/senders/senders.cs new file mode 100644 index 000000000..7e8279d4c --- /dev/null +++ b/examples/senders/senders.cs @@ -0,0 +1,104 @@ +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 Sender Identity +// POST /senders + +string data = @"{ + 'address': '123 Elm St.', + 'address_2': 'Apt. 456', + 'city': 'Denver', + 'country': 'United States', + 'from': { + 'email': 'from@example.com', + 'name': 'Example INC' + }, + 'nickname': 'My Sender ID', + 'reply_to': { + 'email': 'replyto@example.com', + 'name': 'Example INC' + }, + 'state': 'Colorado', + 'zip': '80202' +}"; +dynamic response = sg.client.senders.post(requestBody: data); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); + +//////////////////////////////////////////////////////// +// Get all Sender Identities +// GET /senders + +dynamic response = sg.client.senders.get(); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); + +//////////////////////////////////////////////////////// +// Update a Sender Identity +// PATCH /senders/{sender_id} + +string data = @"{ + 'address': '123 Elm St.', + 'address_2': 'Apt. 456', + 'city': 'Denver', + 'country': 'United States', + 'from': { + 'email': 'from@example.com', + 'name': 'Example INC' + }, + 'nickname': 'My Sender ID', + 'reply_to': { + 'email': 'replyto@example.com', + 'name': 'Example INC' + }, + 'state': 'Colorado', + 'zip': '80202' +}"; +var sender_id = "test_url_param"; +dynamic response = sg.client.senders._(sender_id).patch(requestBody: data); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); + +//////////////////////////////////////////////////////// +// View a Sender Identity +// GET /senders/{sender_id} + +var sender_id = "test_url_param"; +dynamic response = sg.client.senders._(sender_id).get(); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); + +//////////////////////////////////////////////////////// +// Delete a Sender Identity +// DELETE /senders/{sender_id} + +var sender_id = "test_url_param"; +dynamic response = sg.client.senders._(sender_id).delete(); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); + +//////////////////////////////////////////////////////// +// Resend Sender Identity Verification +// POST /senders/{sender_id}/resend_verification + +var sender_id = "test_url_param"; +dynamic response = sg.client.senders._(sender_id).resend_verification.post(); +Console.WriteLine(response.StatusCode); +Console.WriteLine(response.Body.ReadAsStringAsync().Result); +Console.WriteLine(response.Headers.ToString()); +Console.ReadLine(); +