Commits

Dustin Shields-Cloues committed d33de22

Add scheduled email support

Comments (0)

Files changed (3)

     port:   443,
     prefix: '/api/1.0/',
     method: 'POST',
-    headers: {'Content-Type': 'application/json', 'User-Agent': 'Mandrill-Node/1.0.24'}
+    headers: {'Content-Type': 'application/json', 'User-Agent': 'Mandrill-Node/1.0.25'}
 }
 
 class exports.Mandrill
                  - content {String} the content of the image as a base64-encoded string
     @option params {Boolean} async enable a background sending mode that is optimized for bulk sending. In async mode, messages/send will immediately return a status of "queued" for every recipient. To handle rejections when sending in async mode, set up a webhook for the 'reject' event. Defaults to false for messages with no more than 10 recipients; messages with more than 10 recipients are always sent asynchronously, regardless of the value of async.
     @option params {String} ip_pool the name of the dedicated ip pool that should be used to send the message. If you do not have any dedicated IPs, this parameter has no effect. If you specify a pool that does not exist, your default pool will be used instead.
+    @option params {String} send_at when this message should be sent as a UTC timestamp in YYYY-MM-DD HH:MM:SS format. If you specify a time in the past, the message will be sent immediately.
     @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["async"] ?= false
         params["ip_pool"] ?= null
+        params["send_at"] ?= null
 
         @master.call('messages/send', params, onsuccess, onerror)
 
                  - content {String} the content of the image as a base64-encoded string
     @option params {Boolean} async enable a background sending mode that is optimized for bulk sending. In async mode, messages/send will immediately return a status of "queued" for every recipient. To handle rejections when sending in async mode, set up a webhook for the 'reject' event. Defaults to false for messages with no more than 10 recipients; messages with more than 10 recipients are always sent asynchronously, regardless of the value of async.
     @option params {String} ip_pool the name of the dedicated ip pool that should be used to send the message. If you do not have any dedicated IPs, this parameter has no effect. If you specify a pool that does not exist, your default pool will be used instead.
+    @option params {String} send_at when this message should be sent as a UTC timestamp in YYYY-MM-DD HH:MM:SS format. If you specify a time in the past, the message will be sent immediately.
     @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["async"] ?= false
         params["ip_pool"] ?= null
+        params["send_at"] ?= null
 
         @master.call('messages/send-template', params, onsuccess, onerror)
 
          - to[] {String} the email address of the recipint
     @option params {Boolean} async enable a background sending mode that is optimized for bulk sending. In async mode, messages/sendRaw will immediately return a status of "queued" for every recipient. To handle rejections when sending in async mode, set up a webhook for the 'reject' event. Defaults to false for messages with no more than 10 recipients; messages with more than 10 recipients are always sent asynchronously, regardless of the value of async.
     @option params {String} ip_pool the name of the dedicated ip pool that should be used to send the message. If you do not have any dedicated IPs, this parameter has no effect. If you specify a pool that does not exist, your default pool will be used instead.
+    @option params {String} send_at when this message should be sent as a UTC timestamp in YYYY-MM-DD HH:MM:SS format. If you specify a time in the past, the message will be sent immediately.
     @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["to"] ?= null
         params["async"] ?= false
         params["ip_pool"] ?= null
+        params["send_at"] ?= null
 
         @master.call('messages/send-raw', params, onsuccess, onerror)
+
+    ###
+    Queries your scheduled emails by sender or recipient, or both.
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} to an optional recipient address to restrict results to
+    @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
+    ###
+    listScheduled: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+        params["to"] ?= null
+
+        @master.call('messages/list-scheduled', params, onsuccess, onerror)
+
+    ###
+    Cancels a scheduled email.
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} id a scheduled email id, as returned by any of the messages/send calls or messages/list-scheduled
+    @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
+    ###
+    cancelScheduled: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+
+        @master.call('messages/cancel-scheduled', params, onsuccess, onerror)
+
+    ###
+    Reschedules a scheduled email.
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} id a scheduled email id, as returned by any of the messages/send calls or messages/list-scheduled
+    @option params {String} send_at the new UTC timestamp when the message should sent. Mandrill can't time travel, so if you specify a time in past the message will be sent immediately
+    @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
+    ###
+    reschedule: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+
+        @master.call('messages/reschedule', params, onsuccess, onerror)
 class Whitelists
     constructor: (@master) ->
 
     method: 'POST',
     headers: {
       'Content-Type': 'application/json',
-      'User-Agent': 'Mandrill-Node/1.0.24'
+      'User-Agent': 'Mandrill-Node/1.0.25'
     }
   };
 
                      - content {String} the content of the image as a base64-encoded string
         @option params {Boolean} async enable a background sending mode that is optimized for bulk sending. In async mode, messages/send will immediately return a status of "queued" for every recipient. To handle rejections when sending in async mode, set up a webhook for the 'reject' event. Defaults to false for messages with no more than 10 recipients; messages with more than 10 recipients are always sent asynchronously, regardless of the value of async.
         @option params {String} ip_pool the name of the dedicated ip pool that should be used to send the message. If you do not have any dedicated IPs, this parameter has no effect. If you specify a pool that does not exist, your default pool will be used instead.
+        @option params {String} send_at when this message should be sent as a UTC timestamp in YYYY-MM-DD HH:MM:SS format. If you specify a time in the past, the message will be sent immediately.
         @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
     */
 
 
     Messages.prototype.send = function(params, onsuccess, onerror) {
-      var _ref, _ref1;
+      var _ref, _ref1, _ref2;
       if (params == null) {
         params = {};
       }
       if ((_ref1 = params["ip_pool"]) == null) {
         params["ip_pool"] = null;
       }
+      if ((_ref2 = params["send_at"]) == null) {
+        params["send_at"] = null;
+      }
       return this.master.call('messages/send', params, onsuccess, onerror);
     };
 
                      - content {String} the content of the image as a base64-encoded string
         @option params {Boolean} async enable a background sending mode that is optimized for bulk sending. In async mode, messages/send will immediately return a status of "queued" for every recipient. To handle rejections when sending in async mode, set up a webhook for the 'reject' event. Defaults to false for messages with no more than 10 recipients; messages with more than 10 recipients are always sent asynchronously, regardless of the value of async.
         @option params {String} ip_pool the name of the dedicated ip pool that should be used to send the message. If you do not have any dedicated IPs, this parameter has no effect. If you specify a pool that does not exist, your default pool will be used instead.
+        @option params {String} send_at when this message should be sent as a UTC timestamp in YYYY-MM-DD HH:MM:SS format. If you specify a time in the past, the message will be sent immediately.
         @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
     */
 
 
     Messages.prototype.sendTemplate = function(params, onsuccess, onerror) {
-      var _ref, _ref1;
+      var _ref, _ref1, _ref2;
       if (params == null) {
         params = {};
       }
       if ((_ref1 = params["ip_pool"]) == null) {
         params["ip_pool"] = null;
       }
+      if ((_ref2 = params["send_at"]) == null) {
+        params["send_at"] = null;
+      }
       return this.master.call('messages/send-template', params, onsuccess, onerror);
     };
 
              - to[] {String} the email address of the recipint
         @option params {Boolean} async enable a background sending mode that is optimized for bulk sending. In async mode, messages/sendRaw will immediately return a status of "queued" for every recipient. To handle rejections when sending in async mode, set up a webhook for the 'reject' event. Defaults to false for messages with no more than 10 recipients; messages with more than 10 recipients are always sent asynchronously, regardless of the value of async.
         @option params {String} ip_pool the name of the dedicated ip pool that should be used to send the message. If you do not have any dedicated IPs, this parameter has no effect. If you specify a pool that does not exist, your default pool will be used instead.
+        @option params {String} send_at when this message should be sent as a UTC timestamp in YYYY-MM-DD HH:MM:SS format. If you specify a time in the past, the message will be sent immediately.
         @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
     */
 
 
     Messages.prototype.sendRaw = function(params, onsuccess, onerror) {
-      var _ref, _ref1, _ref2, _ref3, _ref4;
+      var _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
       if (params == null) {
         params = {};
       }
       if ((_ref4 = params["ip_pool"]) == null) {
         params["ip_pool"] = null;
       }
+      if ((_ref5 = params["send_at"]) == null) {
+        params["send_at"] = null;
+      }
       return this.master.call('messages/send-raw', params, onsuccess, onerror);
     };
 
+    /*
+        Queries your scheduled emails by sender or recipient, or both.
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} to an optional recipient address to restrict results to
+        @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
+    */
+
+
+    Messages.prototype.listScheduled = function(params, onsuccess, onerror) {
+      var _ref;
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      if ((_ref = params["to"]) == null) {
+        params["to"] = null;
+      }
+      return this.master.call('messages/list-scheduled', params, onsuccess, onerror);
+    };
+
+    /*
+        Cancels a scheduled email.
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} id a scheduled email id, as returned by any of the messages/send calls or messages/list-scheduled
+        @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
+    */
+
+
+    Messages.prototype.cancelScheduled = function(params, onsuccess, onerror) {
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      return this.master.call('messages/cancel-scheduled', params, onsuccess, onerror);
+    };
+
+    /*
+        Reschedules a scheduled email.
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} id a scheduled email id, as returned by any of the messages/send calls or messages/list-scheduled
+        @option params {String} send_at the new UTC timestamp when the message should sent. Mandrill can't time travel, so if you specify a time in past the message will be sent immediately
+        @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
+    */
+
+
+    Messages.prototype.reschedule = function(params, onsuccess, onerror) {
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      return this.master.call('messages/reschedule', params, onsuccess, onerror);
+    };
+
     return Messages;
 
   })();
   "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.24",
+  "version": "1.0.25",
   "homepage": "https://bitbucket.org/mailchimp/mandrill-api-node",
   "repository": {
     "type": "git",