Skip to content
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
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ Everyone that made python-postmark awesome
- Nicholas Serra (https://github.com/nicholasserra)
- Nikolay Fominykh (https://github.com/tigrus)
- Gabe Limon (https://github.com/gabelimon)
- Olle Hellgren (https://github.com/anulaibar)

(Did I miss anyone?)
14 changes: 13 additions & 1 deletion postmark/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def __init__(self, **kwargs):
metadata: A dictionary of key-value pairs of custom metadata. Keys and values can only be strings or ints.
template_id: id of Postmark template. See: https://postmarkapp.com/blog/special-delivery-postmark-templates
template_model: a dictionary containing the values to be loaded into the template
message_stream: Message stream ID that's used for sending. If not provided, message will default to the "outbound" transactional stream.
'''
# initialize properties
self.__api_key = None
Expand All @@ -95,6 +96,7 @@ def __init__(self, **kwargs):
self.__metadata = {}
self.__template_id = None
self.__template_model = None
self.__message_stream = None

acceptable_keys = (
'api_key',
Expand All @@ -113,7 +115,8 @@ def __init__(self, **kwargs):
# 'multipart',
'metadata',
'template_id',
'template_model'
'template_model',
'message_stream'
)

for key in kwargs:
Expand Down Expand Up @@ -343,6 +346,12 @@ def _set_attachments(self, value):
lambda self: setattr(self, '_PMMail__template_model', {}),
)

message_stream = property(
lambda self: self.__message_stream,
lambda self, value: setattr(self, '_PMMail__message_stream', value),
lambda self: setattr(self, '_PMMail__message_stream', None),
)

message_id = property(
lambda self: self.__message_id,
lambda self, value: setattr(self, '_PMMail__message_id', value),
Expand Down Expand Up @@ -472,6 +481,9 @@ def to_json_message(self):
attachments.append(file_item)
json_message['Attachments'] = attachments

if self.__message_stream:
json_message['MessageStream'] = self.__message_stream

return json_message

def send(self, test=None):
Expand Down