Skip to content

fix similar code issue in mail.js helper as per #458 #488

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

Closed
wants to merge 2 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
26 changes: 8 additions & 18 deletions sendgrid/helpers/mail/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,28 +82,18 @@ 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 prop_name in ['sections', 'headers', 'custom_args']:
prop = getattr(self, prop_name)
if prop is not None:
obj = {}
for key in prop:
obj.update(key.get())
mail[prop_name] = obj

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