Skip to content

Commit d5b4242

Browse files
committed
Merge pull request #59 from SparkPost/issue-58
Add support for additional transmission options
2 parents 9cdfbf2 + de20a80 commit d5b4242

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from sparkpost import SparkPost
2+
3+
sp = SparkPost()
4+
5+
response = sp.transmission.send(
6+
recipients=[
7+
8+
9+
{
10+
'address': {
11+
'email': '[email protected]',
12+
'name': 'John Doe'
13+
}
14+
}
15+
],
16+
html='<p>Hello world {{name}}</p>',
17+
text='Hello world {{name}}',
18+
from_email='[email protected]',
19+
subject='Example Script',
20+
description='contrived example',
21+
custom_headers={
22+
'X-CUSTOM-HEADER': 'foo bar'
23+
},
24+
track_opens=True,
25+
track_clicks=True,
26+
start_time='2015-11-06T09:10:00-05:00',
27+
campaign='python-sparkpost example',
28+
metadata={
29+
'key': 'value',
30+
'arbitrary': 'values'
31+
},
32+
substitution_data={
33+
'name': 'Example User'
34+
}
35+
)
36+
37+
print response

sparkpost/transmissions.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ def _translate_keys(self, **kwargs):
2626
model['metadata'] = kwargs.get('metadata')
2727
model['substitution_data'] = kwargs.get('substitution_data')
2828

29+
model['options']['start_time'] = kwargs.get('start_time')
2930
model['options']['open_tracking'] = kwargs.get('track_opens')
3031
model['options']['click_tracking'] = kwargs.get('track_clicks')
32+
model['options']['transactional'] = kwargs.get('transactional')
3133
model['options']['sandbox'] = kwargs.get('use_sandbox')
34+
model['options']['skip_suppression'] = kwargs.get('skip_suppression')
3235

3336
model['content']['use_draft_template'] = \
3437
kwargs.get('use_draft_template', False)
@@ -83,13 +86,21 @@ def send(self, **kwargs):
8386
:param dict substitution_data: Corresponds to substitutions in
8487
html/text content. See `substitutions reference
8588
<https://www.sparkpost.com/docs/substitutions-reference>`_.
89+
:param str start_time: Delay generation of messages until this
90+
datetime. Format YYYY-MM-DDTHH:MM:SS+-HH:MM. Example:
91+
'2015-02-11T08:00:00-04:00'.
8692
:param bool track_opens: Defaults to True. Used to track opens of
8793
transmission
8894
:param bool track_clicks: Defaults to True. Used to track clicks of
8995
transmission
9096
:param bool use_sandbox: Flag must be set to use sandbox domain instead
9197
of verified sending domain. Limited to a lifetime of 50
9298
transmissions with this domain
99+
:param bool transactional: Whether message is transactional or
100+
non-transactional for unsubscribe and suppression purposes
101+
:param bool skip_suppression: Whether or not to ignore customer
102+
suppression rules, for this transmission only. Only applicable if
103+
your configuration supports this parameter. (SparkPost Elite only)
93104
:param dict custom_headers: Used to set any headers associated with
94105
transmission
95106

0 commit comments

Comments
 (0)