-
Notifications
You must be signed in to change notification settings - Fork 716
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version Bump v3.0.6: Update docs, unit tests and examples to include …
…Sender ID
- Loading branch information
1 parent
6aeaedb
commit ad958ad
Showing
7 changed files
with
325 additions
and
18 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 |
---|---|---|
|
@@ -29,6 +29,7 @@ sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY')) | |
* [MAILBOX PROVIDERS](#mailbox_providers) | ||
* [PARTNER SETTINGS](#partner_settings) | ||
* [SCOPES](#scopes) | ||
* [SENDERS](#senders) | ||
* [STATS](#stats) | ||
* [SUBUSERS](#subusers) | ||
* [SUPPRESSION](#suppression) | ||
|
@@ -1487,7 +1488,7 @@ The contactdb is a database of your contacts for [SendGrid Marketing Campaigns]( | |
|
||
|
||
```python | ||
params = {'%7Bfield_name%7D': 'test_string', '{field_name}': 'test_string'} | ||
params = {'{field_name}': 'test_string'} | ||
response = sg.client.contactdb.recipients.search.get(query_params=params) | ||
print response.status_code | ||
print response.body | ||
|
@@ -2716,6 +2717,141 @@ print response.status_code | |
print response.body | ||
print 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 | ||
|
||
|
||
```python | ||
data = { | ||
"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) | ||
print response.status_code | ||
print response.body | ||
print 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 | ||
|
||
|
||
```python | ||
response = sg.client.senders.get() | ||
print response.status_code | ||
print response.body | ||
print 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} | ||
|
||
|
||
```python | ||
data = { | ||
"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) | ||
print response.status_code | ||
print response.body | ||
print 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} | ||
|
||
|
||
```python | ||
sender_id = "test_url_param" | ||
response = sg.client.senders._(sender_id).get() | ||
print response.status_code | ||
print response.body | ||
print 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} | ||
|
||
|
||
```python | ||
sender_id = "test_url_param" | ||
response = sg.client.senders._(sender_id).delete() | ||
print response.status_code | ||
print response.body | ||
print 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 | ||
|
||
|
||
```python | ||
sender_id = "test_url_param" | ||
response = sg.client.senders._(sender_id).resend_verification.post() | ||
print response.status_code | ||
print response.body | ||
print 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,99 @@ | ||
import sendgrid | ||
import json | ||
import os | ||
|
||
|
||
sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY')) | ||
|
||
################################################## | ||
# Create a Sender Identity # | ||
# POST /senders # | ||
|
||
data = { | ||
"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) | ||
print(response.status_code) | ||
print(response.body) | ||
print(response.headers) | ||
|
||
################################################## | ||
# Get all Sender Identities # | ||
# GET /senders # | ||
|
||
response = sg.client.senders.get() | ||
print(response.status_code) | ||
print(response.body) | ||
print(response.headers) | ||
|
||
################################################## | ||
# Update a Sender Identity # | ||
# PATCH /senders/{sender_id} # | ||
|
||
data = { | ||
"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) | ||
print(response.status_code) | ||
print(response.body) | ||
print(response.headers) | ||
|
||
################################################## | ||
# View a Sender Identity # | ||
# GET /senders/{sender_id} # | ||
|
||
sender_id = "test_url_param" | ||
response = sg.client.senders._(sender_id).get() | ||
print(response.status_code) | ||
print(response.body) | ||
print(response.headers) | ||
|
||
################################################## | ||
# Delete a Sender Identity # | ||
# DELETE /senders/{sender_id} # | ||
|
||
sender_id = "test_url_param" | ||
response = sg.client.senders._(sender_id).delete() | ||
print(response.status_code) | ||
print(response.body) | ||
print(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() | ||
print(response.status_code) | ||
print(response.body) | ||
print(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
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,2 +1,2 @@ | ||
version_info = (3, 0, 5) | ||
version_info = (3, 0, 6) | ||
__version__ = '.'.join(str(v) for v in version_info) |
Oops, something went wrong.