Skip to content
Browse files

Added api_key and sender properties in PMBatchMail

  • Loading branch information...
1 parent 5e1df27 commit 237291dafa3606bc72e611151043019ebd9822da @maximebf maximebf committed
Showing with 34 additions and 3 deletions.
  1. +34 −3 postmark/core.py
View
37 postmark/core.py
@@ -442,15 +442,17 @@ class PMBatchMail(object):
def __init__(self, **kwargs):
self.__api_key = None
self.__sender = None
- self.messages = []
+ self.__messages = []
acceptable_keys = (
- 'messages',
+ 'api_key',
+ 'sender',
+ 'messages'
)
for key in kwargs:
if key in acceptable_keys:
- setattr(self, key, kwargs[key])
+ setattr(self, '_PMBatchMail__%s' % key, kwargs[key])
# Set up the user-agent
self.__user_agent = 'Python/%s (python-postmark library version %s)' % ('_'.join([str(var) for var in sys.version_info]), __version__)
@@ -466,7 +468,36 @@ def __init__(self, **kwargs):
self.__sender = django_settings.POSTMARK_SENDER
except ImportError:
pass
+
+ api_key = property(
+ lambda self: self.__api_key,
+ lambda self, value: setattr(self, '_PMMail__api_key', value),
+ lambda self: setattr(self, '_PMMail__api_key', None),
+ '''
+ The API Key for your rack server on Postmark
+ '''
+ )
+ sender = property(
+ lambda self: self.__sender,
+ lambda self, value: setattr(self, '_PMMail__sender', value),
+ lambda self: setattr(self, '_PMMail__sender', None),
+ '''
+ The sender, in either "name@email.com" or "First Last <name@email.com>" formats.
+ The address should match one of your Sender Signatures in Postmark.
+ Specifying the address in the second fashion will allow you to replace
+ the name of the sender as it appears in the recipient's email client.
+ '''
+ )
+
+ messages = property(
+ lambda self: self.__messages,
+ lambda self, value: setattr(self, '_PMMail__messages', value),
+ lambda self: setattr(self, '_PMMail__messages', None),
+ '''
+ Messages to send
+ '''
+ )
def send(self, test=None):
json_message = []

0 comments on commit 237291d

Please sign in to comment.
Something went wrong with that request. Please try again.