From 780859eae34fd900f0967326b8ebfc40de04cf91 Mon Sep 17 00:00:00 2001 From: Elmer Thomas Date: Wed, 28 Oct 2015 09:30:07 -0700 Subject: [PATCH 1/2] Minor refactoring based on feedback from GitHub community --- example_v3_test.py | 8 ++------ sendgrid/resources/asm_global_suppressions.py | 6 +++--- sendgrid/resources/asm_groups.py | 10 ---------- sendgrid/resources/asm_suppressions.py | 6 ++---- 4 files changed, 7 insertions(+), 23 deletions(-) diff --git a/example_v3_test.py b/example_v3_test.py index 24a454782..d12ed78ac 100755 --- a/example_v3_test.py +++ b/example_v3_test.py @@ -10,13 +10,13 @@ client = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY')) +""" + email = 'elmer.thomas+test_global0@gmail.com' status, msg = client.asm_global_suppressions.delete(email) print status print msg -""" - status, msg = client.suppressions.get() print status print msg @@ -38,10 +38,6 @@ 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 diff --git a/sendgrid/resources/asm_global_suppressions.py b/sendgrid/resources/asm_global_suppressions.py index 3415e4db0..a2190bc3e 100644 --- a/sendgrid/resources/asm_global_suppressions.py +++ b/sendgrid/resources/asm_global_suppressions.py @@ -35,18 +35,18 @@ def client(self): return self._client # Determine if an email belongs to the global suppression group - def get(self, email=None): + def get(self, email): self._endpoint = self._base_endpoint + '/' + email return self.client.get(self) # Add an email to the global suppressions group - def post(self, emails=None): + def post(self, emails): self._endpoint = self._base_endpoint data = {} data["recipient_emails"] = emails return self.client.post(self, data) # Remove an email from the global suppressions group - def delete(self, email=None): + def delete(self, email): self._endpoint = self._base_endpoint + '/' + email return self.client.delete(self) \ No newline at end of file diff --git a/sendgrid/resources/asm_groups.py b/sendgrid/resources/asm_groups.py index d619d1880..747d5c238 100644 --- a/sendgrid/resources/asm_groups.py +++ b/sendgrid/resources/asm_groups.py @@ -42,16 +42,6 @@ def get(self, id=None): if isinstance(id, int): self._endpoint = self._base_endpoint + "/" + str(id) - return self.client.get(self) - - if len(id) > 1: - count = 0 - for i in id: - if count == 0: - self._endpoint = self._endpoint + "?id=" + str(i) - else: - self._endpoint = self._endpoint + "&id=" + str(i) - count = count + 1 return self.client.get(self) diff --git a/sendgrid/resources/asm_suppressions.py b/sendgrid/resources/asm_suppressions.py index 92fdf4653..d57a73db7 100644 --- a/sendgrid/resources/asm_suppressions.py +++ b/sendgrid/resources/asm_suppressions.py @@ -36,10 +36,8 @@ def client(self): return self._client # Get suppressed addresses for a given group id. - def get(self, id=None): - if isinstance(id, int): - self._endpoint = self._base_endpoint + "/" + str(id) + "/suppressions" - return self.client.get(self) + def get(self, id): + self._endpoint = self._base_endpoint + "/" + str(id) + "/suppressions" return self.client.get(self) # Add recipient addresses to the suppressions list for a given group. From 483e03179d4d9e3ede0f10fc59830be6b8e20e79 Mon Sep 17 00:00:00 2001 From: Elmer Thomas Date: Wed, 28 Oct 2015 09:31:59 -0700 Subject: [PATCH 2/2] Minor refactoring based on feedback from GitHub community --- sendgrid/resources/asm_groups.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sendgrid/resources/asm_groups.py b/sendgrid/resources/asm_groups.py index 747d5c238..48c8a7371 100644 --- a/sendgrid/resources/asm_groups.py +++ b/sendgrid/resources/asm_groups.py @@ -39,8 +39,7 @@ def client(self): def get(self, id=None): if id == None: return self.client.get(self) - - if isinstance(id, int): + else: self._endpoint = self._base_endpoint + "/" + str(id) return self.client.get(self)