forked from sendgrid/sendgrid-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_v3_test.py
executable file
·126 lines (101 loc) · 2.71 KB
/
example_v3_test.py
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import sendgrid
import json
import os
if os.path.exists('.env'):
for line in open('.env'):
var = line.strip().split('=')
if len(var) == 2:
os.environ[var[0]] = var[1]
client = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
start_date = '2015-10-01'
end_date = None
aggregated_by = 'week' # must be day, week or month
status, msg = client.stats.get(
start_date=start_date,
end_date=end_date,
aggregated_by=aggregated_by)
print status
print msg
"""
email = 'example@example.com'
status, msg = client.asm_global_suppressions.delete(email)
print status
print msg
status, msg = client.suppressions.get()
print status
print msg
status, msg = client.asm_global_suppressions.post(['example@example.com'])
print status
print msg
group_id = 70
status, msg = client.asm_suppressions.get(group_id)
print status
print msg
status, msg = client.asm_groups.post("Magic Key 2", "Unlock your Emails", False)
print status
print msg
status, msg = client.asm_groups.get()
print status
print msg
status, msg = client.asm_groups.post("Magic Key", "Unlock your Emails")
print status
print msg
status, msg = client.asm_groups.get()
print status
print msg
# In the global suppression list
status, msg = client.asm_global_suppressions.get('example@example.com')
print status
print msg
# Not in the global suppression list
status, msg = client.asm_global_suppressions.get('example@example.com')
print status
print msg
status, msg = client.apikeys.get()
print status
print msg
status, msg = client.asm_suppressions.delete(67,'example@example.com')
print status
print msg
status, msg = client.asm_suppressions.post(60, ['example@example.com', 'example@example.com])
print status
print msg
status, msg = client.asm_groups.get([66,67,50])
print status
print msg
name = "My Amazing API Key"
status, msg = client.apikeys.post(name)
msg = json.loads(msg)
api_key_id = msg['api_key_id']
print status
print msg
name = "My NEW API Key 3000"
status, msg = client.apikeys.patch(api_key_id, name)
print status
print msg
status, msg = client.apikeys.delete(api_key_id)
print status
status, msg = client.apikeys.get()
print status
print msg
# Get a list of all valid API Keys from your account
status, msg = client.apikeys.get()
print status
print msg
# Create a new API Key
name = "My API Key 10"
status, msg = client.apikeys.post(name)
print status
print msg
# Delete an API Key with a given api_key_id
api_key_id = "zc0r5sW5TTuBQGsMPMUx0A"
status, msg = client.apikeys.delete(api_key_id)
print status
print msg
# Update the name of an API Key, given an api_key_id
api_key_id = "API_KEY"
name = "My API Key 3"
status, msg = client.apikeys.patch(api_key_id, name)
print status
print msg
"""