diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 443d203..4543e05 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -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?) diff --git a/postmark/core.py b/postmark/core.py index d77a583..ddd8b0b 100644 --- a/postmark/core.py +++ b/postmark/core.py @@ -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 @@ -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', @@ -113,7 +115,8 @@ def __init__(self, **kwargs): # 'multipart', 'metadata', 'template_id', - 'template_model' + 'template_model', + 'message_stream' ) for key in kwargs: @@ -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), @@ -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):