forked from sendgrid/sendgrid-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/sendgrid/sendgrid-ruby in…
…to patch-3
- Loading branch information
Showing
6 changed files
with
317 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY']) | |
* [MAILBOX PROVIDERS](#mailbox_providers) | ||
* [PARTNER SETTINGS](#partner_settings) | ||
* [SCOPES](#scopes) | ||
* [SENDERS](#senders) | ||
* [STATS](#stats) | ||
* [SUBUSERS](#subusers) | ||
* [SUPPRESSION](#suppression) | ||
|
@@ -1469,7 +1470,7 @@ The contactdb is a database of your contacts for [SendGrid Marketing Campaigns]( | |
|
||
|
||
```ruby | ||
params = JSON.parse('{"%7Bfield_name%7D": "test_string", "{field_name}": "test_string"}') | ||
params = JSON.parse('{"{field_name}": "test_string"}') | ||
response = sg.client.contactdb.recipients.search.get(query_params: params) | ||
puts response.status_code | ||
puts response.body | ||
|
@@ -2698,6 +2699,141 @@ puts response.status_code | |
puts response.body | ||
puts response.headers | ||
``` | ||
<a name="senders"></a> | ||
# 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 | ||
|
||
|
||
```ruby | ||
data = JSON.parse('{ | ||
"address": "123 Elm St.", | ||
"address_2": "Apt. 456", | ||
"city": "Denver", | ||
"country": "United States", | ||
"from": { | ||
"email": "[email protected]", | ||
"name": "Example INC" | ||
}, | ||
"nickname": "My Sender ID", | ||
"reply_to": { | ||
"email": "[email protected]", | ||
"name": "Example INC" | ||
}, | ||
"state": "Colorado", | ||
"zip": "80202" | ||
}') | ||
response = sg.client.senders.post(request_body: data) | ||
puts response.status_code | ||
puts response.body | ||
puts response.headers | ||
``` | ||
## 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 | ||
|
||
|
||
```ruby | ||
response = sg.client.senders.get() | ||
puts response.status_code | ||
puts response.body | ||
puts response.headers | ||
``` | ||
## 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} | ||
|
||
|
||
```ruby | ||
data = JSON.parse('{ | ||
"address": "123 Elm St.", | ||
"address_2": "Apt. 456", | ||
"city": "Denver", | ||
"country": "United States", | ||
"from": { | ||
"email": "[email protected]", | ||
"name": "Example INC" | ||
}, | ||
"nickname": "My Sender ID", | ||
"reply_to": { | ||
"email": "[email protected]", | ||
"name": "Example INC" | ||
}, | ||
"state": "Colorado", | ||
"zip": "80202" | ||
}') | ||
sender_id = "test_url_param" | ||
response = sg.client.senders._(sender_id).patch(request_body: data) | ||
puts response.status_code | ||
puts response.body | ||
puts response.headers | ||
``` | ||
## 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} | ||
|
||
|
||
```ruby | ||
sender_id = "test_url_param" | ||
response = sg.client.senders._(sender_id).get() | ||
puts response.status_code | ||
puts response.body | ||
puts response.headers | ||
``` | ||
## 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} | ||
|
||
|
||
```ruby | ||
sender_id = "test_url_param" | ||
response = sg.client.senders._(sender_id).delete() | ||
puts response.status_code | ||
puts response.body | ||
puts response.headers | ||
``` | ||
## 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 | ||
|
||
|
||
```ruby | ||
sender_id = "test_url_param" | ||
response = sg.client.senders._(sender_id).resend_verification.post() | ||
puts response.status_code | ||
puts response.body | ||
puts response.headers | ||
``` | ||
<a name="stats"></a> | ||
# STATS | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
require 'sendgrid-ruby' | ||
|
||
|
||
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY']) | ||
|
||
|
||
################################################## | ||
# Create a Sender Identity # | ||
# POST /senders # | ||
|
||
data = JSON.parse('{ | ||
"address": "123 Elm St.", | ||
"address_2": "Apt. 456", | ||
"city": "Denver", | ||
"country": "United States", | ||
"from": { | ||
"email": "[email protected]", | ||
"name": "Example INC" | ||
}, | ||
"nickname": "My Sender ID", | ||
"reply_to": { | ||
"email": "[email protected]", | ||
"name": "Example INC" | ||
}, | ||
"state": "Colorado", | ||
"zip": "80202" | ||
}') | ||
response = sg.client.senders.post(request_body: data) | ||
puts response.status_code | ||
puts response.body | ||
puts response.headers | ||
|
||
################################################## | ||
# Get all Sender Identities # | ||
# GET /senders # | ||
|
||
response = sg.client.senders.get() | ||
puts response.status_code | ||
puts response.body | ||
puts response.headers | ||
|
||
################################################## | ||
# Update a Sender Identity # | ||
# PATCH /senders/{sender_id} # | ||
|
||
data = JSON.parse('{ | ||
"address": "123 Elm St.", | ||
"address_2": "Apt. 456", | ||
"city": "Denver", | ||
"country": "United States", | ||
"from": { | ||
"email": "[email protected]", | ||
"name": "Example INC" | ||
}, | ||
"nickname": "My Sender ID", | ||
"reply_to": { | ||
"email": "[email protected]", | ||
"name": "Example INC" | ||
}, | ||
"state": "Colorado", | ||
"zip": "80202" | ||
}') | ||
sender_id = "test_url_param" | ||
response = sg.client.senders._(sender_id).patch(request_body: data) | ||
puts response.status_code | ||
puts response.body | ||
puts response.headers | ||
|
||
################################################## | ||
# View a Sender Identity # | ||
# GET /senders/{sender_id} # | ||
|
||
sender_id = "test_url_param" | ||
response = sg.client.senders._(sender_id).get() | ||
puts response.status_code | ||
puts response.body | ||
puts response.headers | ||
|
||
################################################## | ||
# Delete a Sender Identity # | ||
# DELETE /senders/{sender_id} # | ||
|
||
sender_id = "test_url_param" | ||
response = sg.client.senders._(sender_id).delete() | ||
puts response.status_code | ||
puts response.body | ||
puts response.headers | ||
|
||
################################################## | ||
# Resend Sender Identity Verification # | ||
# POST /senders/{sender_id}/resend_verification # | ||
|
||
sender_id = "test_url_param" | ||
response = sg.client.senders._(sender_id).resend_verification.post() | ||
puts response.status_code | ||
puts response.body | ||
puts response.headers | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module SendGrid | ||
VERSION = '3.0.5' | ||
VERSION = '3.0.6' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ def test_init | |
') | ||
assert_equal(test_headers, sg.request_headers) | ||
assert_equal("v3", sg.version) | ||
assert_equal("3.0.5", SendGrid::VERSION) | ||
assert_equal("3.0.6", SendGrid::VERSION) | ||
assert_instance_of(SendGrid::Client, sg.client) | ||
end | ||
|
||
|
@@ -659,7 +659,7 @@ def test_contactdb_recipients_count_get | |
end | ||
|
||
def test_contactdb_recipients_search_get | ||
params = JSON.parse('{"%7Bfield_name%7D": "test_string", "{field_name}": "test_string"}') | ||
params = JSON.parse('{"{field_name}": "test_string"}') | ||
headers = JSON.parse('{"X-Mock": 200}') | ||
response = @sg.client.contactdb.recipients.search.get(query_params: params, request_headers: headers) | ||
self.assert_equal(response.status_code, "200") | ||
|
@@ -1242,6 +1242,80 @@ def test_scopes_get | |
self.assert_equal(response.status_code, "200") | ||
end | ||
|
||
def test_senders_post | ||
data = JSON.parse('{ | ||
"address": "123 Elm St.", | ||
"address_2": "Apt. 456", | ||
"city": "Denver", | ||
"country": "United States", | ||
"from": { | ||
"email": "[email protected]", | ||
"name": "Example INC" | ||
}, | ||
"nickname": "My Sender ID", | ||
"reply_to": { | ||
"email": "[email protected]", | ||
"name": "Example INC" | ||
}, | ||
"state": "Colorado", | ||
"zip": "80202" | ||
}') | ||
headers = JSON.parse('{"X-Mock": 201}') | ||
response = @sg.client.senders.post(request_body: data, request_headers: headers) | ||
self.assert_equal(response.status_code, "201") | ||
end | ||
|
||
def test_senders_get | ||
headers = JSON.parse('{"X-Mock": 200}') | ||
response = @sg.client.senders.get(request_headers: headers) | ||
self.assert_equal(response.status_code, "200") | ||
end | ||
|
||
def test_senders__sender_id__patch | ||
data = JSON.parse('{ | ||
"address": "123 Elm St.", | ||
"address_2": "Apt. 456", | ||
"city": "Denver", | ||
"country": "United States", | ||
"from": { | ||
"email": "[email protected]", | ||
"name": "Example INC" | ||
}, | ||
"nickname": "My Sender ID", | ||
"reply_to": { | ||
"email": "[email protected]", | ||
"name": "Example INC" | ||
}, | ||
"state": "Colorado", | ||
"zip": "80202" | ||
}') | ||
sender_id = "test_url_param" | ||
headers = JSON.parse('{"X-Mock": 200}') | ||
response = @sg.client.senders._(sender_id).patch(request_body: data, request_headers: headers) | ||
self.assert_equal(response.status_code, "200") | ||
end | ||
|
||
def test_senders__sender_id__get | ||
sender_id = "test_url_param" | ||
headers = JSON.parse('{"X-Mock": 200}') | ||
response = @sg.client.senders._(sender_id).get(request_headers: headers) | ||
self.assert_equal(response.status_code, "200") | ||
end | ||
|
||
def test_senders__sender_id__delete | ||
sender_id = "test_url_param" | ||
headers = JSON.parse('{"X-Mock": 204}') | ||
response = @sg.client.senders._(sender_id).delete(request_headers: headers) | ||
self.assert_equal(response.status_code, "204") | ||
end | ||
|
||
def test_senders__sender_id__resend_verification_post | ||
sender_id = "test_url_param" | ||
headers = JSON.parse('{"X-Mock": 204}') | ||
response = @sg.client.senders._(sender_id).resend_verification.post(request_headers: headers) | ||
self.assert_equal(response.status_code, "204") | ||
end | ||
|
||
def test_stats_get | ||
params = JSON.parse('{"aggregated_by": "day", "limit": 1, "start_date": "2016-01-01", "end_date": "2016-04-01", "offset": 1}') | ||
headers = JSON.parse('{"X-Mock": 200}') | ||
|