Skip to content

Commit

Permalink
Version Bump v3.0.6: Update docs, unit tests and examples to include …
Browse files Browse the repository at this point in the history
…Sender ID
  • Loading branch information
thinkingserious committed Jul 12, 2016
1 parent 6aeaedb commit ad958ad
Show file tree
Hide file tree
Showing 7 changed files with 325 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log
All notable changes to this project will be documented in this file.

## [3.0.6] - 2016-07-12 ##
### Added
- Update docs, unit tests and examples to include Sender ID

## [3.0.5] - 2016-07-11 ##
### Fixed
- Fixed logic errors related to issue #189
Expand Down
138 changes: 137 additions & 1 deletion USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion examples/contactdb/contactdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
# Retrieve recipients matching search criteria #
# GET /contactdb/recipients/search #

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)
Expand Down
99 changes: 99 additions & 0 deletions examples/senders/senders.py
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)

28 changes: 14 additions & 14 deletions examples/user/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,36 +248,36 @@
print(response.headers)

##################################################
# Retrieve a specific parse setting #
# GET /user/webhooks/parse/settings/{hostname} #
# Update a parse setting #
# PATCH /user/webhooks/parse/settings/{hostname} #

data = {
"send_raw": True,
"spam_check": False,
"url": "http://newdomain.com/parse"
}
hostname = "test_url_param"
response = sg.client.user.webhooks.parse.settings._(hostname).get()
response = sg.client.user.webhooks.parse.settings._(hostname).patch(request_body=data)
print(response.status_code)
print(response.body)
print(response.headers)

##################################################
# Delete a parse setting #
# DELETE /user/webhooks/parse/settings/{hostname} #
# Retrieve a specific parse setting #
# GET /user/webhooks/parse/settings/{hostname} #

hostname = "test_url_param"
response = sg.client.user.webhooks.parse.settings._(hostname).delete()
response = sg.client.user.webhooks.parse.settings._(hostname).get()
print(response.status_code)
print(response.body)
print(response.headers)

##################################################
# Update a parse setting #
# PATCH /user/webhooks/parse/settings/{hostname}/ #
# Delete a parse setting #
# DELETE /user/webhooks/parse/settings/{hostname} #

data = {
"send_raw": True,
"spam_check": False,
"url": "http://newdomain.com/parse"
}
hostname = "test_url_param"
response = sg.client.user.webhooks.parse.settings._(hostname)..patch(request_body=data)
response = sg.client.user.webhooks.parse.settings._(hostname).delete()
print(response.status_code)
print(response.body)
print(response.headers)
Expand Down
2 changes: 1 addition & 1 deletion sendgrid/version.py
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)
Loading

0 comments on commit ad958ad

Please sign in to comment.