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

Commits

MailChimp  committed 8b395a3

Add API calls for template labels, tracking domains, and inbound domains and routes

  • Participants
  • Parent commits 8e27a41
  • Branches master
  • Tags 1.0.36

Comments (0)

Files changed (3)

File mandrill.coffee

View file
  • Ignore whitespace
     port:   443,
     prefix: '/api/1.0/',
     method: 'POST',
-    headers: {'Content-Type': 'application/json', 'User-Agent': 'Mandrill-Node/1.0.35'}
+    headers: {'Content-Type': 'application/json', 'User-Agent': 'Mandrill-Node/1.0.36'}
 }
 
 class exports.Mandrill
     @option params {String} code the HTML code for the template with mc:edit attributes for the editable elements
     @option params {String} text a default text part to be used when sending with this template
     @option params {Boolean} publish set to false to add a draft template without publishing
+    @option params {Array} labels an optional array of up to 10 labels to use for filtering templates
+         - labels[] {String} a single label
     @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
     ###
         params["code"] ?= null
         params["text"] ?= null
         params["publish"] ?= true
+        params["labels"] ?= []
 
         @master.call('templates/add', params, onsuccess, onerror)
 
     @option params {String} code the new code for the template
     @option params {String} text the new default text part to be used
     @option params {Boolean} publish set to false to update the draft version of the template without publishing
+    @option params {Array} labels an optional array of up to 10 labels to use for filtering templates
+         - labels[] {String} a single label
     @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
     ###
         params["code"] ?= null
         params["text"] ?= null
         params["publish"] ?= true
+        params["labels"] ?= null
 
         @master.call('templates/update', params, onsuccess, onerror)
 
     ###
     Return a list of all the templates available to this user
     @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} label an optional label to filter the templates
     @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
     ###
             onsuccess = params
             params = {}
 
+        params["label"] ?= null
 
         @master.call('templates/list', params, onsuccess, onerror)
 
         @master.call('inbound/domains', params, onsuccess, onerror)
 
     ###
+    Add an inbound domain to your account
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} domain a domain name
+    @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
+    ###
+    addDomain: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+
+        @master.call('inbound/add-domain', params, onsuccess, onerror)
+
+    ###
+    Check the MX settings for an inbound domain. The domain must have already been added with the add-domain call
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} domain an existing inbound domain
+    @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
+    ###
+    checkDomain: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+
+        @master.call('inbound/check-domain', params, onsuccess, onerror)
+
+    ###
+    Delete an inbound domain from the account. All mail will stop routing for this domain immediately.
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} domain an existing inbound domain
+    @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
+    ###
+    deleteDomain: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+
+        @master.call('inbound/delete-domain', params, onsuccess, onerror)
+
+    ###
     List the mailbox routes defined for an inbound domain
     @param {Object} params the hash of the parameters to pass to the request
     @option params {String} domain the domain to check
         @master.call('inbound/routes', params, onsuccess, onerror)
 
     ###
+    Add a new mailbox route to an inbound domain
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} domain an existing inbound domain
+    @option params {String} pattern the search pattern that the mailbox name should match
+    @option params {String} url the webhook URL where the inbound messages will be published
+    @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
+    ###
+    addRoute: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+
+        @master.call('inbound/add-route', params, onsuccess, onerror)
+
+    ###
+    Update the pattern or webhook of an existing inbound mailbox route. If null is provided for any fields, the values will remain unchanged.
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} id the unique identifier of an existing mailbox route
+    @option params {String} pattern the search pattern that the mailbox name should match
+    @option params {String} url the webhook URL where the inbound messages will be published
+    @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
+    ###
+    updateRoute: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+        params["pattern"] ?= null
+        params["url"] ?= null
+
+        @master.call('inbound/update-route', params, onsuccess, onerror)
+
+    ###
+    Delete an existing inbound mailbox route
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} id the unique identifier of an existing route
+    @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
+    ###
+    deleteRoute: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+
+        @master.call('inbound/delete-route', params, onsuccess, onerror)
+
+    ###
     Take a raw MIME document destined for a domain with inbound domains set up, and send it to the inbound hook exactly as if it had been sent over SMTP
     @param {Object} params the hash of the parameters to pass to the request
     @option params {String} raw_message the full MIME document of an email message
 
 
         @master.call('urls/time-series', params, onsuccess, onerror)
+
+    ###
+    Get the list of tracking domains set up for this account
+    @param {Object} params the hash of the parameters to pass to the request
+    @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
+    ###
+    trackingDomains: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+
+        @master.call('urls/tracking-domains', params, onsuccess, onerror)
+
+    ###
+    Add a tracking domain to your account
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} domain a domain name
+    @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
+    ###
+    addTrackingDomain: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+
+        @master.call('urls/add-tracking-domain', params, onsuccess, onerror)
+
+    ###
+    Checks the CNAME settings for a tracking domain. The domain must have been added already with the add-tracking-domain call
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} domain an existing tracking domain name
+    @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
+    ###
+    checkTrackingDomain: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+
+        @master.call('urls/check-tracking-domain', params, onsuccess, onerror)
 class Webhooks
     constructor: (@master) ->
 

File mandrill.js

View file
  • Ignore whitespace
     method: 'POST',
     headers: {
       'Content-Type': 'application/json',
-      'User-Agent': 'Mandrill-Node/1.0.35'
+      'User-Agent': 'Mandrill-Node/1.0.36'
     }
   };
 
         @option params {String} code the HTML code for the template with mc:edit attributes for the editable elements
         @option params {String} text a default text part to be used when sending with this template
         @option params {Boolean} publish set to false to add a draft template without publishing
+        @option params {Array} labels an optional array of up to 10 labels to use for filtering templates
+             - labels[] {String} a single label
         @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
     */
 
 
     Templates.prototype.add = function(params, onsuccess, onerror) {
-      var _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
+      var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6;
       if (params == null) {
         params = {};
       }
       if ((_ref5 = params["publish"]) == null) {
         params["publish"] = true;
       }
+      if ((_ref6 = params["labels"]) == null) {
+        params["labels"] = [];
+      }
       return this.master.call('templates/add', params, onsuccess, onerror);
     };
 
         @option params {String} code the new code for the template
         @option params {String} text the new default text part to be used
         @option params {Boolean} publish set to false to update the draft version of the template without publishing
+        @option params {Array} labels an optional array of up to 10 labels to use for filtering templates
+             - labels[] {String} a single label
         @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
     */
 
 
     Templates.prototype.update = function(params, onsuccess, onerror) {
-      var _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
+      var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6;
       if (params == null) {
         params = {};
       }
       if ((_ref5 = params["publish"]) == null) {
         params["publish"] = true;
       }
+      if ((_ref6 = params["labels"]) == null) {
+        params["labels"] = null;
+      }
       return this.master.call('templates/update', params, onsuccess, onerror);
     };
 
     /*
         Return a list of all the templates available to this user
         @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} label an optional label to filter the templates
         @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
     */
 
 
     Templates.prototype.list = function(params, onsuccess, onerror) {
+      var _ref;
       if (params == null) {
         params = {};
       }
         onsuccess = params;
         params = {};
       }
+      if ((_ref = params["label"]) == null) {
+        params["label"] = null;
+      }
       return this.master.call('templates/list', params, onsuccess, onerror);
     };
 
     };
 
     /*
+        Add an inbound domain to your account
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} domain a domain name
+        @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
+    */
+
+
+    Inbound.prototype.addDomain = function(params, onsuccess, onerror) {
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      return this.master.call('inbound/add-domain', params, onsuccess, onerror);
+    };
+
+    /*
+        Check the MX settings for an inbound domain. The domain must have already been added with the add-domain call
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} domain an existing inbound domain
+        @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
+    */
+
+
+    Inbound.prototype.checkDomain = function(params, onsuccess, onerror) {
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      return this.master.call('inbound/check-domain', params, onsuccess, onerror);
+    };
+
+    /*
+        Delete an inbound domain from the account. All mail will stop routing for this domain immediately.
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} domain an existing inbound domain
+        @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
+    */
+
+
+    Inbound.prototype.deleteDomain = function(params, onsuccess, onerror) {
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      return this.master.call('inbound/delete-domain', params, onsuccess, onerror);
+    };
+
+    /*
         List the mailbox routes defined for an inbound domain
         @param {Object} params the hash of the parameters to pass to the request
         @option params {String} domain the domain to check
     };
 
     /*
+        Add a new mailbox route to an inbound domain
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} domain an existing inbound domain
+        @option params {String} pattern the search pattern that the mailbox name should match
+        @option params {String} url the webhook URL where the inbound messages will be published
+        @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
+    */
+
+
+    Inbound.prototype.addRoute = function(params, onsuccess, onerror) {
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      return this.master.call('inbound/add-route', params, onsuccess, onerror);
+    };
+
+    /*
+        Update the pattern or webhook of an existing inbound mailbox route. If null is provided for any fields, the values will remain unchanged.
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} id the unique identifier of an existing mailbox route
+        @option params {String} pattern the search pattern that the mailbox name should match
+        @option params {String} url the webhook URL where the inbound messages will be published
+        @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
+    */
+
+
+    Inbound.prototype.updateRoute = function(params, onsuccess, onerror) {
+      var _ref, _ref1;
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      if ((_ref = params["pattern"]) == null) {
+        params["pattern"] = null;
+      }
+      if ((_ref1 = params["url"]) == null) {
+        params["url"] = null;
+      }
+      return this.master.call('inbound/update-route', params, onsuccess, onerror);
+    };
+
+    /*
+        Delete an existing inbound mailbox route
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} id the unique identifier of an existing route
+        @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
+    */
+
+
+    Inbound.prototype.deleteRoute = function(params, onsuccess, onerror) {
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      return this.master.call('inbound/delete-route', params, onsuccess, onerror);
+    };
+
+    /*
         Take a raw MIME document destined for a domain with inbound domains set up, and send it to the inbound hook exactly as if it had been sent over SMTP
         @param {Object} params the hash of the parameters to pass to the request
         @option params {String} raw_message the full MIME document of an email message
       return this.master.call('urls/time-series', params, onsuccess, onerror);
     };
 
+    /*
+        Get the list of tracking domains set up for this account
+        @param {Object} params the hash of the parameters to pass to the request
+        @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
+    */
+
+
+    Urls.prototype.trackingDomains = function(params, onsuccess, onerror) {
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      return this.master.call('urls/tracking-domains', params, onsuccess, onerror);
+    };
+
+    /*
+        Add a tracking domain to your account
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} domain a domain name
+        @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
+    */
+
+
+    Urls.prototype.addTrackingDomain = function(params, onsuccess, onerror) {
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      return this.master.call('urls/add-tracking-domain', params, onsuccess, onerror);
+    };
+
+    /*
+        Checks the CNAME settings for a tracking domain. The domain must have been added already with the add-tracking-domain call
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} domain an existing tracking domain name
+        @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
+    */
+
+
+    Urls.prototype.checkTrackingDomain = function(params, onsuccess, onerror) {
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      return this.master.call('urls/check-tracking-domain', params, onsuccess, onerror);
+    };
+
     return Urls;
 
   })();

File package.json

View file
  • Ignore whitespace
   "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.35",
+  "version": "1.0.36",
   "homepage": "https://bitbucket.org/mailchimp/mandrill-api-node",
   "repository": {
     "type": "git",