Skip to content

Commit

Permalink
Merge 8b870ca into d23a20d
Browse files Browse the repository at this point in the history
  • Loading branch information
tuck1s committed Oct 22, 2018
2 parents d23a20d + 8b870ca commit 15ce91c
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions sparkpost/transmissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,31 @@ def _translate_keys(self, **kwargs):
model['options']['ip_pool'] = kwargs.get('ip_pool')
model['options']['inline_css'] = kwargs.get('inline_css')

model['content']['use_draft_template'] = \
kwargs.get('use_draft_template', False)
model['content']['reply_to'] = kwargs.get('reply_to')
model['content']['subject'] = kwargs.get('subject')
from_email = kwargs.get('from_email')
if isinstance(from_email, string_types):
from_email = self._parse_address(from_email)
model['content']['from'] = from_email
model['content']['html'] = kwargs.get('html')
model['content']['text'] = kwargs.get('text')
model['content']['template_id'] = kwargs.get('template')
model['content']['headers'] = kwargs.get('custom_headers', {})
rfc822 = kwargs.get('email_rfc822')
if rfc822:
model['content']['email_rfc822'] = rfc822
else:
model['content']['headers'] = kwargs.get('custom_headers', {})
model['content']['use_draft_template'] = \
kwargs.get('use_draft_template', False)
model['content']['reply_to'] = kwargs.get('reply_to')
model['content']['subject'] = kwargs.get('subject')
from_email = kwargs.get('from_email')
if isinstance(from_email, string_types):
from_email = self._parse_address(from_email)
model['content']['from'] = from_email
model['content']['html'] = kwargs.get('html')
model['content']['text'] = kwargs.get('text')
model['content']['template_id'] = kwargs.get('template')

attachments = kwargs.get('attachments', [])
model['content']['attachments'] = self._extract_attachments(
attachments)

if 'inline_images' in kwargs:
inline_images = kwargs['inline_images']
model['content']['inline_images'] = self._extract_attachments(
inline_images)

recipient_list = kwargs.get('recipient_list')
if recipient_list:
Expand All @@ -77,15 +90,6 @@ def _translate_keys(self, **kwargs):

model['recipients'] = recipients

attachments = kwargs.get('attachments', [])
model['content']['attachments'] = self._extract_attachments(
attachments)

if 'inline_images' in kwargs:
inline_images = kwargs['inline_images']
model['content']['inline_images'] = self._extract_attachments(
inline_images)

return model

def _format_copies(self, recipients, copies):
Expand Down

0 comments on commit 15ce91c

Please sign in to comment.