mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
Postmark: Fix sending templated email to a single recipient
Fix a bug where sending an email with a template_id and a single to address would cause a Postmark API error. Thanks @jc-ee for finding and fixing.
This commit is contained in:
@@ -179,12 +179,19 @@ class PostmarkPayload(RequestsPayload):
|
||||
return params
|
||||
|
||||
def serialize_data(self):
|
||||
data = self.data
|
||||
api_endpoint = self.get_api_endpoint()
|
||||
if api_endpoint == "email/batchWithTemplates":
|
||||
if api_endpoint == "email":
|
||||
data = self.data
|
||||
elif api_endpoint == "email/batchWithTemplates":
|
||||
data = {"Messages": [self.data_for_recipient(to) for to in self.to_emails]}
|
||||
elif api_endpoint == "email/batch":
|
||||
data = [self.data_for_recipient(to) for to in self.to_emails]
|
||||
elif api_endpoint == "email/withTemplate/":
|
||||
assert len(self.to_emails) == 1
|
||||
data = self.data_for_recipient(self.to_emails[0])
|
||||
else:
|
||||
raise AssertionError("PostmarkPayload.serialize_data missing"
|
||||
" case for api_endpoint %r" % api_endpoint)
|
||||
return self.serialize_json(data)
|
||||
|
||||
def data_for_recipient(self, to):
|
||||
|
||||
Reference in New Issue
Block a user