Repository navigation
Expand file tree
/
Copy pathsenders.py
More file actions
97 lines (83 loc) · 2.36 KB
/
Copy pathsenders.py
File metadata and controls
97 lines (83 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import sendgrid
import os
sg = sendgrid.SendGridAPIClient(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": "from@example.com",
"name": "Example INC"
},
"nickname": "My Sender ID",
"reply_to": {
"email": "replyto@example.com",
"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": "from@example.com",
"name": "Example INC"
},
"nickname": "My Sender ID",
"reply_to": {
"email": "replyto@example.com",
"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)