Skip to content

Commit 38939ed

Browse files
Update ASM groups to retrieve particular records.
1 parent e180847 commit 38939ed

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

example_v3_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
client = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
1212

13-
status, msg = client.asm_groups.get()
13+
status, msg = client.asm_groups.get([66,67,50])
1414
print status
1515
print msg
1616

sendgrid/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def _build_request(self, url, json_header=False, method='GET', data=None):
7272
return response.getcode(), body
7373

7474
def get(self, api):
75-
url = self.host + api.base_endpoint
75+
url = self.host + api.endpoint
7676
response, body = self._build_request(url, False, 'GET')
7777
return response, body
7878

sendgrid/resources/asm_groups.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,21 @@ def client(self):
3636
return self._client
3737

3838
# Retrieve all suppression groups associated with the user.
39-
def get(self):
39+
def get(self, id=None):
40+
if id == None:
41+
return self.client.get(self)
42+
43+
if isinstance(id, int):
44+
self._endpoint = self._base_endpoint + "/" + str(id)
45+
return self.client.get(self)
46+
47+
if len(id) > 1:
48+
count = 0
49+
for i in id:
50+
if count == 0:
51+
self._endpoint = self._endpoint + "?id=" + str(i)
52+
else:
53+
self._endpoint = self._endpoint + "&id=" + str(i)
54+
count = count + 1
55+
4056
return self.client.get(self)

0 commit comments

Comments
 (0)