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

Reusing subdata from the first recipient #129

Merged
merged 2 commits into from
Nov 14, 2016
Merged
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions sparkpost/transmissions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import base64
import copy
import json
from email.utils import parseaddr

Expand Down Expand Up @@ -90,10 +91,13 @@ def _format_copies(self, recipients, copies):
formatted_copies = []
if len(recipients) > 0:
formatted_copies = self._extract_recipients(copies)
main_recipient = copy.deepcopy(recipients[0])
main_recipient.pop('address')
for recipient in formatted_copies:
recipient['address'].update({
'header_to': self._format_header_to(recipients[0])
})
recipient.update(**main_recipient)
return formatted_copies

def _format_header_to(self, recipient):
Expand Down Expand Up @@ -241,8 +245,7 @@ def send(self, **kwargs):
"""

payload = self._translate_keys(**kwargs)
results = self.request('POST', self.uri,
data=json.dumps(payload, ensure_ascii=False))
results = self.request('POST', self.uri, data=json.dumps(payload))
return results

def _fetch_get(self, transmission_id):
Expand Down
3 changes: 2 additions & 1 deletion test/test_transmissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def test_cc_with_sub_data():
'address': {
'email': '[email protected]',
'header_to': '[email protected]'
}
},
'substitution_data': {'fake': 'data'}
}
]

Expand Down