1+ class ASMSuppressions (object ):
2+ """Advanced Suppression Manager gives your recipients more control over the types of emails they want to receive
3+ by letting them opt out of messages from a certain type of email.
4+
5+ Suppressions are email addresses that can be added to groups to prevent certain types of emails from being
6+ delivered to those addresses.
7+ """
8+
9+ def __init__ (self , client , ** opts ):
10+ """
11+ Constructs SendGrid ASM suppressions object.
12+
13+ See https://sendgrid.com/docs/API_Reference/Web_API_v3/Advanced_Suppression_Manager/index.html and
14+ https://sendgrid.com/docs/API_Reference/Web_API_v3/Advanced_Suppression_Manager/groups.html
15+ """
16+ self ._name = None
17+ self ._base_endpoint = "/v3/asm/groups"
18+ self ._endpoint = "/v3/asm/groups"
19+ self ._client = client
20+
21+ @property
22+ def base_endpoint (self ):
23+ return self ._base_endpoint
24+
25+ @property
26+ def endpoint (self ):
27+ endpoint = self ._endpoint
28+ return endpoint
29+
30+ @endpoint .setter
31+ def endpoint (self , value ):
32+ self ._endpoint = value
33+
34+ @property
35+ def client (self ):
36+ return self ._client
37+
38+ # Get suppressed addresses for a given group id.
39+ def get (self , id = None , email = None ):
40+ if id == None and email == None :
41+ return self .client .get (self )
42+
43+ if isinstance (id , int ):
44+ self ._endpoint = self ._base_endpoint + "/" + str (id ) + "/suppressions"
45+ return self .client .get (self )
46+
47+ if isinstance (email , str ):
48+ self ._endpoint = "/v3/asm/suppressions/" + email
49+
50+ return self .client .get (self )
51+
52+ # Add recipient addresses to the suppressions list for a given group.
53+ # If the group has been deleted, this request will add the address to the global suppression.
54+ def post (self , id , emails ):
55+ self ._endpoint = self ._base_endpoint + "/" + str (id ) + "/suppressions"
56+ data = {}
57+ data ["recipient_emails" ] = emails
58+ return self .client .post (self , data )
0 commit comments