Skip to content
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