Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactors code #509

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions sendgrid/helpers/mail/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,28 +82,17 @@ def get(self):
if self.template_id is not None:
mail["template_id"] = self.template_id

if self.sections:
sections = {}
for key in self.sections:
sections.update(key.get())
mail["sections"] = sections

if self.headers:
headers = {}
for key in self.headers:
headers.update(key.get())
mail["headers"] = headers
for attribute in [(self.sections, "sections"), (self.headers, "headers"), (self.custom_args, "custom_args")]:
if attribute[0] is not None:
tmp = {}
for key in attribute[0]:
tmp.update(key.get())
mail[attribute[1]] = tmp

if self.categories:
mail["categories"] = [category.get() for category in
self.categories]

if self.custom_args:
custom_args = {}
for key in self.custom_args:
custom_args.update(key.get())
mail["custom_args"] = custom_args

if self.send_at is not None:
mail["send_at"] = self.send_at

Expand Down