forked from sendgrid/sendgrid-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcategories.py
More file actions
42 lines (34 loc) · 1.33 KB
/
Copy pathcategories.py
File metadata and controls
42 lines (34 loc) · 1.33 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
import sendgrid
import os
sg = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
##################################################
# Retrieve all categories #
# GET /categories #
params = {'category': 'test_string', 'limit': 1, 'offset': 1}
response = sg.client.categories.get(query_params=params)
print(response.status_code)
print(response.body)
print(response.headers)
##################################################
# Retrieve Email Statistics for Categories #
# GET /categories/stats #
params = {'end_date': '2016-04-01', 'aggregated_by': 'day', 'limit': 1,
'offset': 1, 'start_date': '2016-01-01', 'categories': 'test_string'}
response = sg.client.categories.stats.get(query_params=params)
print(response.status_code)
print(response.body)
print(response.headers)
##################################################
# Retrieve sums of email stats for each category [Needs: Stats object defined, has category ID?] #
# GET /categories/stats/sums #
params = {'end_date': '2016-04-01',
'aggregated_by': 'day',
'limit': 1,
'sort_by_metric': 'test_string',
'offset': 1,
'start_date': '2016-01-01',
'sort_by_direction': 'asc'}
response = sg.client.categories.stats.sums.get(query_params=params)
print(response.status_code)
print(response.body)
print(response.headers)