Commits

Dustin Shields-Cloues  committed 75d5d5b

Add API calls for rejection blacklist and whitelist management

  • Participants
  • Parent commits 5f27d83
  • Tags 1.0.19

Comments (0)

Files changed (3)

File mandrill.coffee

     port:   443,
     prefix: '/api/1.0/',
     method: 'POST',
-    headers: {'Content-Type': 'application/json', 'User-Agent': 'Mandrill-Node/1.0.18'}
+    headers: {'Content-Type': 'application/json', 'User-Agent': 'Mandrill-Node/1.0.19'}
 }
 
 class exports.Mandrill
         @inbound = new Inbound(this)
         @tags = new Tags(this)
         @messages = new Messages(this)
+        @whitelists = new Whitelists(this)
         @internal = new Internal(this)
         @urls = new Urls(this)
         @webhooks = new Webhooks(this)
 
 
     ###
+    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
+address that has been whitelisted will have no effect.
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} email an email address to block
+    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
+    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
+    ###
+    add: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+
+        @master.call('rejects/add', params, onsuccess, onerror)
+
+    ###
     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
         params["async"] ?= false
 
         @master.call('messages/send-raw', params, onsuccess, onerror)
+class Whitelists
+    constructor: (@master) ->
+
+
+    ###
+    Adds an email to your email rejection whitelist. If the address is
+currently on your blacklist, that blacklist entry will be removed
+automatically.
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} email an email address to add to the whitelist
+    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
+    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
+    ###
+    add: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+
+        @master.call('whitelists/add', params, onsuccess, onerror)
+
+    ###
+    Retrieves your email rejection whitelist. You can provide an email
+address or search prefix to limit the results. Returns up to 1000 results.
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} email an optional email address or prefix to search by
+    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
+    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
+    ###
+    list: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+        params["email"] ?= null
+
+        @master.call('whitelists/list', params, onsuccess, onerror)
+
+    ###
+    Removes an email address from the whitelist.
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} email the email address to remove from the whitelist
+    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
+    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
+    ###
+    delete: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+
+        @master.call('whitelists/delete', params, onsuccess, onerror)
 class Internal
     constructor: (@master) ->
 
 // Generated by CoffeeScript 1.3.3
 (function() {
-  var Inbound, Internal, Messages, OPTS, Rejects, Senders, Tags, Templates, Urls, Users, Webhooks, https;
+  var Inbound, Internal, Messages, OPTS, Rejects, Senders, Tags, Templates, Urls, Users, Webhooks, Whitelists, https;
 
   https = require('https');
 
     method: 'POST',
     headers: {
       'Content-Type': 'application/json',
-      'User-Agent': 'Mandrill-Node/1.0.18'
+      'User-Agent': 'Mandrill-Node/1.0.19'
     }
   };
 
       this.inbound = new Inbound(this);
       this.tags = new Tags(this);
       this.messages = new Messages(this);
+      this.whitelists = new Whitelists(this);
       this.internal = new Internal(this);
       this.urls = new Urls(this);
       this.webhooks = new Webhooks(this);
     }
 
     /*
+        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
+    address that has been whitelisted will have no effect.
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} email an email address to block
+        @param {Function} onsuccess an optional callback to execute when the API call is successfully made
+        @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
+    */
+
+
+    Rejects.prototype.add = function(params, onsuccess, onerror) {
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      return this.master.call('rejects/add', params, onsuccess, onerror);
+    };
+
+    /*
         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
 
   })();
 
+  Whitelists = (function() {
+
+    function Whitelists(master) {
+      this.master = master;
+    }
+
+    /*
+        Adds an email to your email rejection whitelist. If the address is
+    currently on your blacklist, that blacklist entry will be removed
+    automatically.
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} email an email address to add to the whitelist
+        @param {Function} onsuccess an optional callback to execute when the API call is successfully made
+        @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
+    */
+
+
+    Whitelists.prototype.add = function(params, onsuccess, onerror) {
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      return this.master.call('whitelists/add', params, onsuccess, onerror);
+    };
+
+    /*
+        Retrieves your email rejection whitelist. You can provide an email
+    address or search prefix to limit the results. Returns up to 1000 results.
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} email an optional email address or prefix to search by
+        @param {Function} onsuccess an optional callback to execute when the API call is successfully made
+        @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
+    */
+
+
+    Whitelists.prototype.list = function(params, onsuccess, onerror) {
+      var _ref;
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      if ((_ref = params["email"]) == null) {
+        params["email"] = null;
+      }
+      return this.master.call('whitelists/list', params, onsuccess, onerror);
+    };
+
+    /*
+        Removes an email address from the whitelist.
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} email the email address to remove from the whitelist
+        @param {Function} onsuccess an optional callback to execute when the API call is successfully made
+        @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
+    */
+
+
+    Whitelists.prototype["delete"] = function(params, onsuccess, onerror) {
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      return this.master.call('whitelists/delete', params, onsuccess, onerror);
+    };
+
+    return Whitelists;
+
+  })();
+
   Internal = (function() {
 
     function Internal(master) {

File package.json

   "author": "Mandrill Devs <community@mandrill.com> (http://mandrill.com)",
   "name": "mandrill-api",
   "description": "The official API client for the Mandrill email as a service product.",
-  "version": "1.0.18",
+  "version": "1.0.19",
   "homepage": "https://bitbucket.org/mailchimp/mandrill-api-node",
   "repository": {
     "type": "git",