Skip to content

Commit ad958ad

Browse files
Version Bump v3.0.6: Update docs, unit tests and examples to include Sender ID
1 parent 6aeaedb commit ad958ad

File tree

7 files changed

+325
-18
lines changed

7 files changed

+325
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## [3.0.6] - 2016-07-12 ##
5+
### Added
6+
- Update docs, unit tests and examples to include Sender ID
7+
48
## [3.0.5] - 2016-07-11 ##
59
### Fixed
610
- Fixed logic errors related to issue #189

USAGE.md

Lines changed: 137 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY'))
2929
* [MAILBOX PROVIDERS](#mailbox_providers)
3030
* [PARTNER SETTINGS](#partner_settings)
3131
* [SCOPES](#scopes)
32+
* [SENDERS](#senders)
3233
* [STATS](#stats)
3334
* [SUBUSERS](#subusers)
3435
* [SUPPRESSION](#suppression)
@@ -1487,7 +1488,7 @@ The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](
14871488

14881489

14891490
```python
1490-
params = {'%7Bfield_name%7D': 'test_string', '{field_name}': 'test_string'}
1491+
params = {'{field_name}': 'test_string'}
14911492
response = sg.client.contactdb.recipients.search.get(query_params=params)
14921493
print response.status_code
14931494
print response.body
@@ -2716,6 +2717,141 @@ print response.status_code
27162717
print response.body
27172718
print response.headers
27182719
```
2720+
<a name="senders"></a>
2721+
# SENDERS
2722+
2723+
## Create a Sender Identity
2724+
2725+
**This endpoint allows you to create a new sender identity.**
2726+
2727+
*You may create up to 100 unique sender identities.*
2728+
2729+
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`.
2730+
2731+
### POST /senders
2732+
2733+
2734+
```python
2735+
data = {
2736+
"address": "123 Elm St.",
2737+
"address_2": "Apt. 456",
2738+
"city": "Denver",
2739+
"country": "United States",
2740+
"from": {
2741+
"email": "[email protected]",
2742+
"name": "Example INC"
2743+
},
2744+
"nickname": "My Sender ID",
2745+
"reply_to": {
2746+
"email": "[email protected]",
2747+
"name": "Example INC"
2748+
},
2749+
"state": "Colorado",
2750+
"zip": "80202"
2751+
}
2752+
response = sg.client.senders.post(request_body=data)
2753+
print response.status_code
2754+
print response.body
2755+
print response.headers
2756+
```
2757+
## Get all Sender Identities
2758+
2759+
**This endpoint allows you to retrieve a list of all sender identities that have been created for your account.**
2760+
2761+
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`.
2762+
2763+
### GET /senders
2764+
2765+
2766+
```python
2767+
response = sg.client.senders.get()
2768+
print response.status_code
2769+
print response.body
2770+
print response.headers
2771+
```
2772+
## Update a Sender Identity
2773+
2774+
**This endpoint allows you to update a sender identity.**
2775+
2776+
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`.
2777+
2778+
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.
2779+
2780+
### PATCH /senders/{sender_id}
2781+
2782+
2783+
```python
2784+
data = {
2785+
"address": "123 Elm St.",
2786+
"address_2": "Apt. 456",
2787+
"city": "Denver",
2788+
"country": "United States",
2789+
"from": {
2790+
"email": "[email protected]",
2791+
"name": "Example INC"
2792+
},
2793+
"nickname": "My Sender ID",
2794+
"reply_to": {
2795+
"email": "[email protected]",
2796+
"name": "Example INC"
2797+
},
2798+
"state": "Colorado",
2799+
"zip": "80202"
2800+
}
2801+
sender_id = "test_url_param"
2802+
response = sg.client.senders._(sender_id).patch(request_body=data)
2803+
print response.status_code
2804+
print response.body
2805+
print response.headers
2806+
```
2807+
## View a Sender Identity
2808+
2809+
**This endpoint allows you to retrieve a specific sender identity.**
2810+
2811+
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`.
2812+
2813+
### GET /senders/{sender_id}
2814+
2815+
2816+
```python
2817+
sender_id = "test_url_param"
2818+
response = sg.client.senders._(sender_id).get()
2819+
print response.status_code
2820+
print response.body
2821+
print response.headers
2822+
```
2823+
## Delete a Sender Identity
2824+
2825+
**This endoint allows you to delete one of your sender identities.**
2826+
2827+
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`.
2828+
2829+
### DELETE /senders/{sender_id}
2830+
2831+
2832+
```python
2833+
sender_id = "test_url_param"
2834+
response = sg.client.senders._(sender_id).delete()
2835+
print response.status_code
2836+
print response.body
2837+
print response.headers
2838+
```
2839+
## Resend Sender Identity Verification
2840+
2841+
**This enpdoint allows you to resend a sender identity verification email.**
2842+
2843+
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`.
2844+
2845+
### POST /senders/{sender_id}/resend_verification
2846+
2847+
2848+
```python
2849+
sender_id = "test_url_param"
2850+
response = sg.client.senders._(sender_id).resend_verification.post()
2851+
print response.status_code
2852+
print response.body
2853+
print response.headers
2854+
```
27192855
<a name="stats"></a>
27202856
# STATS
27212857

examples/contactdb/contactdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@
251251
# Retrieve recipients matching search criteria #
252252
# GET /contactdb/recipients/search #
253253

254-
params = {'%7Bfield_name%7D': 'test_string', '{field_name}': 'test_string'}
254+
params = {'{field_name}': 'test_string'}
255255
response = sg.client.contactdb.recipients.search.get(query_params=params)
256256
print(response.status_code)
257257
print(response.body)

examples/senders/senders.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import sendgrid
2+
import json
3+
import os
4+
5+
6+
sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY'))
7+
8+
##################################################
9+
# Create a Sender Identity #
10+
# POST /senders #
11+
12+
data = {
13+
"address": "123 Elm St.",
14+
"address_2": "Apt. 456",
15+
"city": "Denver",
16+
"country": "United States",
17+
"from": {
18+
"email": "[email protected]",
19+
"name": "Example INC"
20+
},
21+
"nickname": "My Sender ID",
22+
"reply_to": {
23+
"email": "[email protected]",
24+
"name": "Example INC"
25+
},
26+
"state": "Colorado",
27+
"zip": "80202"
28+
}
29+
response = sg.client.senders.post(request_body=data)
30+
print(response.status_code)
31+
print(response.body)
32+
print(response.headers)
33+
34+
##################################################
35+
# Get all Sender Identities #
36+
# GET /senders #
37+
38+
response = sg.client.senders.get()
39+
print(response.status_code)
40+
print(response.body)
41+
print(response.headers)
42+
43+
##################################################
44+
# Update a Sender Identity #
45+
# PATCH /senders/{sender_id} #
46+
47+
data = {
48+
"address": "123 Elm St.",
49+
"address_2": "Apt. 456",
50+
"city": "Denver",
51+
"country": "United States",
52+
"from": {
53+
"email": "[email protected]",
54+
"name": "Example INC"
55+
},
56+
"nickname": "My Sender ID",
57+
"reply_to": {
58+
"email": "[email protected]",
59+
"name": "Example INC"
60+
},
61+
"state": "Colorado",
62+
"zip": "80202"
63+
}
64+
sender_id = "test_url_param"
65+
response = sg.client.senders._(sender_id).patch(request_body=data)
66+
print(response.status_code)
67+
print(response.body)
68+
print(response.headers)
69+
70+
##################################################
71+
# View a Sender Identity #
72+
# GET /senders/{sender_id} #
73+
74+
sender_id = "test_url_param"
75+
response = sg.client.senders._(sender_id).get()
76+
print(response.status_code)
77+
print(response.body)
78+
print(response.headers)
79+
80+
##################################################
81+
# Delete a Sender Identity #
82+
# DELETE /senders/{sender_id} #
83+
84+
sender_id = "test_url_param"
85+
response = sg.client.senders._(sender_id).delete()
86+
print(response.status_code)
87+
print(response.body)
88+
print(response.headers)
89+
90+
##################################################
91+
# Resend Sender Identity Verification #
92+
# POST /senders/{sender_id}/resend_verification #
93+
94+
sender_id = "test_url_param"
95+
response = sg.client.senders._(sender_id).resend_verification.post()
96+
print(response.status_code)
97+
print(response.body)
98+
print(response.headers)
99+

examples/user/user.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -248,36 +248,36 @@
248248
print(response.headers)
249249

250250
##################################################
251-
# Retrieve a specific parse setting #
252-
# GET /user/webhooks/parse/settings/{hostname} #
251+
# Update a parse setting #
252+
# PATCH /user/webhooks/parse/settings/{hostname} #
253253

254+
data = {
255+
"send_raw": True,
256+
"spam_check": False,
257+
"url": "http://newdomain.com/parse"
258+
}
254259
hostname = "test_url_param"
255-
response = sg.client.user.webhooks.parse.settings._(hostname).get()
260+
response = sg.client.user.webhooks.parse.settings._(hostname).patch(request_body=data)
256261
print(response.status_code)
257262
print(response.body)
258263
print(response.headers)
259264

260265
##################################################
261-
# Delete a parse setting #
262-
# DELETE /user/webhooks/parse/settings/{hostname} #
266+
# Retrieve a specific parse setting #
267+
# GET /user/webhooks/parse/settings/{hostname} #
263268

264269
hostname = "test_url_param"
265-
response = sg.client.user.webhooks.parse.settings._(hostname).delete()
270+
response = sg.client.user.webhooks.parse.settings._(hostname).get()
266271
print(response.status_code)
267272
print(response.body)
268273
print(response.headers)
269274

270275
##################################################
271-
# Update a parse setting #
272-
# PATCH /user/webhooks/parse/settings/{hostname}/ #
276+
# Delete a parse setting #
277+
# DELETE /user/webhooks/parse/settings/{hostname} #
273278

274-
data = {
275-
"send_raw": True,
276-
"spam_check": False,
277-
"url": "http://newdomain.com/parse"
278-
}
279279
hostname = "test_url_param"
280-
response = sg.client.user.webhooks.parse.settings._(hostname)..patch(request_body=data)
280+
response = sg.client.user.webhooks.parse.settings._(hostname).delete()
281281
print(response.status_code)
282282
print(response.body)
283283
print(response.headers)

sendgrid/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version_info = (3, 0, 5)
1+
version_info = (3, 0, 6)
22
__version__ = '.'.join(str(v) for v in version_info)

0 commit comments

Comments
 (0)