1. MailChimp
  2. Untitled project
  3. mandrill-api-python

Commits

MailChimp  committed 8566006

Add subaccount filters to rejection blacklists

  • Participants
  • Parent commits ddea2e5
  • Branches master
  • Tags 1.0.50

Comments (0)

Files changed (2)

File mandrill.py

View file
         params = json.dumps(params)
         self.log('POST to %s%s.json: %s' % (ROOT, url, params))
         start = time.time()
-        r = self.session.post('%s%s.json' % (ROOT, url), data=params, headers={'content-type': 'application/json', 'user-agent': 'Mandrill-Python/1.0.49'})
+        r = self.session.post('%s%s.json' % (ROOT, url), data=params, headers={'content-type': 'application/json', 'user-agent': 'Mandrill-Python/1.0.50'})
         try:
             remote_addr = r.raw._original_response.fp._sock.getpeername() # grab the remote_addr before grabbing the text since the socket will go away
         except:
     def __init__(self, master):
         self.master = master
 
-    def add(self, email):
+    def add(self, email, comment=None, subaccount=None):
         """Adds an email to your email rejection blacklist. Addresses that you
 add manually will never expire and there is no reputation penalty
 for removing them from your blacklist. Attempting to blacklist an
 
         Args:
            email (string): an email address to block
+           comment (string): an optional comment describing the rejection
+           subaccount (string): an optional unique identifier for the subaccount to limit the blacklist entry
 
         Returns:
            struct.  a status object containing the address and the result of the operation::
 
         Raises:
            InvalidKeyError: The provided API key is not a valid Mandrill API key
+           UnknownSubaccountError: The provided subaccount id does not exist.
            Error: A general Mandrill error has occurred
         """
-        _params = {'email': email}
+        _params = {'email': email, 'comment': comment, 'subaccount': subaccount}
         return self.master.call('rejects/add', _params)
 
-    def list(self, email=None, include_expired=False):
+    def list(self, email=None, include_expired=False, subaccount=None):
         """Retrieves your email rejection blacklist. You can provide an email
 address to limit the results. Returns up to 1000 results. By default,
 entries that have expired are excluded from the results; set
         Args:
            email (string): an optional email address to search by
            include_expired (boolean): whether to include rejections that have already expired.
+           subaccount (string): an optional unique identifier for the subaccount to limit the blacklist
 
         Returns:
            array.  Up to 1000 rejection entries::
                        [].sender.unique_opens (integer): the number of unique opens for emails sent for this sender
                        [].sender.unique_clicks (integer): the number of unique clicks for emails sent for this sender
 
+                   [].subaccount (string): the subaccount that this blacklist entry applies to, or null if none.
 
 
         Raises:
            InvalidKeyError: The provided API key is not a valid Mandrill API key
+           UnknownSubaccountError: The provided subaccount id does not exist.
            Error: A general Mandrill error has occurred
         """
-        _params = {'email': email, 'include_expired': include_expired}
+        _params = {'email': email, 'include_expired': include_expired, 'subaccount': subaccount}
         return self.master.call('rejects/list', _params)
 
-    def delete(self, email):
+    def delete(self, email, subaccount=None):
         """Deletes an email rejection. There is no limit to how many rejections
 you can remove from your blacklist, but keep in mind that each deletion
 has an affect on your reputation.
 
         Args:
            email (string): an email address
+           subaccount (string): an optional unique identifier for the subaccount to limit the blacklist deletion
 
         Returns:
            struct.  a status object containing the address and whether the deletion succeeded.::
                email (string): the email address that was removed from the blacklist
                deleted (boolean): whether the address was deleted successfully.
+               subaccount (string): the subaccount blacklist that the address was removed from, if any
 
         Raises:
            InvalidRejectError: The requested email is not in the rejection list
            InvalidKeyError: The provided API key is not a valid Mandrill API key
+           UnknownSubaccountError: The provided subaccount id does not exist.
            Error: A general Mandrill error has occurred
         """
-        _params = {'email': email}
+        _params = {'email': email, 'subaccount': subaccount}
         return self.master.call('rejects/delete', _params)
 
 

File setup.py

View file
 
 setup(
     name='mandrill',
-    version='1.0.49',
+    version='1.0.50',
     author='Mandrill Devs',
     author_email='community@mandrill.com',
     description='A CLI client and Python API library for the Mandrill email as a service platform.',