forked from sendgrid/sendgrid-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasm_groups.py
More file actions
54 lines (44 loc) · 1.78 KB
/
asm_groups.py
File metadata and controls
54 lines (44 loc) · 1.78 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
class ASMGroups(object):
"""Advanced Suppression Manager gives your recipients more control over the types of emails they want to receive
by letting them opt out of messages from a certain type of email.
Groups are specific types of email you would like your recipients to be able to unsubscribe from or subscribe to.
For example: Daily Newsletters, Invoices, System Alerts.
"""
def __init__(self, client, **opts):
"""
Constructs SendGrid ASM group object.
See https://sendgrid.com/docs/API_Reference/Web_API_v3/Advanced_Suppression_Manager/index.html and
https://sendgrid.com/docs/API_Reference/Web_API_v3/Advanced_Suppression_Manager/groups.html
"""
self._name = None
self._base_endpoint = "/v3/asm/groups"
self._endpoint = "/v3/asm/groups"
self._client = client
@property
def base_endpoint(self):
return self._base_endpoint
@property
def endpoint(self):
endpoint = self._endpoint
return endpoint
@endpoint.setter
def endpoint(self, value):
self._endpoint = value
@property
def client(self):
return self._client
# Retrieve all suppression groups associated with the user.
def get(self, id=None):
if id == None:
return self.client.get(self)
else:
self._endpoint = self._base_endpoint + "/" + str(id)
return self.client.get(self)
# Create a new unsubscribe group
def post(self, name, description, is_default):
self._endpoint = self._base_endpoint
data = {}
data["name"] = name
data["description"] = description
data["is_default"] = is_default
return self.client.post(self, data)