Commits

Dustin Shields-Cloues  committed d59bb06

Add data export api calls

  • Participants
  • Parent commits 751777e
  • Tags 1.0.21

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.20'}
+    headers: {'Content-Type': 'application/json', 'User-Agent': 'Mandrill-Node/1.0.21'}
 }
 
 class exports.Mandrill
     constructor: (@apikey=null, @debug=false) ->
         @templates = new Templates(this)
+        @exports = new Exports(this)
         @users = new Users(this)
         @rejects = new Rejects(this)
         @inbound = new Inbound(this)
         params["merge_vars"] ?= null
 
         @master.call('templates/render', params, onsuccess, onerror)
+class Exports
+    constructor: (@master) ->
+
+
+    ###
+    Returns information about an export job. If the export job's state is 'complete',
+the returned data will include a URL you can use to fetch the results. Every export
+job produces a zip archive, but the format of the archive is distinct for each job
+type. The api calls that initiate exports include more details about the output format
+for that job type.
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} id an export job identifier
+    @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
+    ###
+    info: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+
+        @master.call('exports/info', params, onsuccess, onerror)
+
+    ###
+    Returns a list of your exports.
+    @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
+    ###
+    list: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+
+        @master.call('exports/list', params, onsuccess, onerror)
+
+    ###
+    Begins an export of your rejection blacklist. The blacklist will be exported to a zip archive
+containing a single file named rejects.csv that includes the following fields: email,
+reason, detail, created_at, expires_at, last_event_at, expires_at.
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} notify_email an optional email address to notify when the export job has finished.
+    @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: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+        params["notify_email"] ?= null
+
+        @master.call('exports/rejects', params, onsuccess, onerror)
+
+    ###
+    Begins an export of your rejection whitelist. The whitelist will be exported to a zip archive
+containing a single file named whitelist.csv that includes the following fields:
+email, detail, created_at.
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} notify_email an optional email address to notify when the export job has finished.
+    @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
+    ###
+    whitelist: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+        params["notify_email"] ?= null
+
+        @master.call('exports/whitelist', params, onsuccess, onerror)
+
+    ###
+    Begins an export of your activity history. The activity will be exported to a zaip archive
+containing a single file named activity.csv in the same format as you would be able to export
+from your account's activity view. It includes the following fields: Date, Email Address,
+Sender, Subject, Status, Tags, Opens, Clicks, Bounce Detail. If you have configured any custom
+metadata fields, they will be included in the exported data.
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} notify_email an optional email address to notify when the export job has finished
+    @option params {String} date_from start date as a UTC string in YYYY-MM-DD HH:MM:SS format
+    @option params {String} date_to end date as a UTC string in YYYY-MM-DD HH:MM:SS format
+    @option params {Array} tags an array of tag names to narrow the export to; will match messages that contain ANY of the tags
+         - tags[] {String} a tag name
+    @option params {Array} senders an array of senders to narrow the export to
+         - senders[] {String} a sender address
+    @option params {Array} states an array of states to narrow the export to; messages with ANY of the states will be included
+         - states[] {String} a message state
+    @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
+    ###
+    activity: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+        params["notify_email"] ?= null
+        params["date_from"] ?= null
+        params["date_to"] ?= null
+        params["tags"] ?= null
+        params["senders"] ?= null
+        params["states"] ?= null
+
+        @master.call('exports/activity', params, onsuccess, onerror)
 class Users
     constructor: (@master) ->
 
 // Generated by CoffeeScript 1.3.3
 (function() {
-  var Inbound, Internal, Messages, OPTS, Rejects, Senders, Tags, Templates, Urls, Users, Webhooks, Whitelists, https;
+  var Exports, 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.20'
+      'User-Agent': 'Mandrill-Node/1.0.21'
     }
   };
 
       this.apikey = apikey != null ? apikey : null;
       this.debug = debug != null ? debug : false;
       this.templates = new Templates(this);
+      this.exports = new Exports(this);
       this.users = new Users(this);
       this.rejects = new Rejects(this);
       this.inbound = new Inbound(this);
 
   })();
 
+  Exports = (function() {
+
+    function Exports(master) {
+      this.master = master;
+    }
+
+    /*
+        Returns information about an export job. If the export job's state is 'complete',
+    the returned data will include a URL you can use to fetch the results. Every export
+    job produces a zip archive, but the format of the archive is distinct for each job
+    type. The api calls that initiate exports include more details about the output format
+    for that job type.
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} id an export job identifier
+        @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
+    */
+
+
+    Exports.prototype.info = function(params, onsuccess, onerror) {
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      return this.master.call('exports/info', params, onsuccess, onerror);
+    };
+
+    /*
+        Returns a list of your exports.
+        @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
+    */
+
+
+    Exports.prototype.list = function(params, onsuccess, onerror) {
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      return this.master.call('exports/list', params, onsuccess, onerror);
+    };
+
+    /*
+        Begins an export of your rejection blacklist. The blacklist will be exported to a zip archive
+    containing a single file named rejects.csv that includes the following fields: email,
+    reason, detail, created_at, expires_at, last_event_at, expires_at.
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} notify_email an optional email address to notify when the export job has finished.
+        @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
+    */
+
+
+    Exports.prototype.rejects = function(params, onsuccess, onerror) {
+      var _ref;
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      if ((_ref = params["notify_email"]) == null) {
+        params["notify_email"] = null;
+      }
+      return this.master.call('exports/rejects', params, onsuccess, onerror);
+    };
+
+    /*
+        Begins an export of your rejection whitelist. The whitelist will be exported to a zip archive
+    containing a single file named whitelist.csv that includes the following fields:
+    email, detail, created_at.
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} notify_email an optional email address to notify when the export job has finished.
+        @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
+    */
+
+
+    Exports.prototype.whitelist = function(params, onsuccess, onerror) {
+      var _ref;
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      if ((_ref = params["notify_email"]) == null) {
+        params["notify_email"] = null;
+      }
+      return this.master.call('exports/whitelist', params, onsuccess, onerror);
+    };
+
+    /*
+        Begins an export of your activity history. The activity will be exported to a zaip archive
+    containing a single file named activity.csv in the same format as you would be able to export
+    from your account's activity view. It includes the following fields: Date, Email Address,
+    Sender, Subject, Status, Tags, Opens, Clicks, Bounce Detail. If you have configured any custom
+    metadata fields, they will be included in the exported data.
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} notify_email an optional email address to notify when the export job has finished
+        @option params {String} date_from start date as a UTC string in YYYY-MM-DD HH:MM:SS format
+        @option params {String} date_to end date as a UTC string in YYYY-MM-DD HH:MM:SS format
+        @option params {Array} tags an array of tag names to narrow the export to; will match messages that contain ANY of the tags
+             - tags[] {String} a tag name
+        @option params {Array} senders an array of senders to narrow the export to
+             - senders[] {String} a sender address
+        @option params {Array} states an array of states to narrow the export to; messages with ANY of the states will be included
+             - states[] {String} a message state
+        @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
+    */
+
+
+    Exports.prototype.activity = function(params, onsuccess, onerror) {
+      var _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      if ((_ref = params["notify_email"]) == null) {
+        params["notify_email"] = null;
+      }
+      if ((_ref1 = params["date_from"]) == null) {
+        params["date_from"] = null;
+      }
+      if ((_ref2 = params["date_to"]) == null) {
+        params["date_to"] = null;
+      }
+      if ((_ref3 = params["tags"]) == null) {
+        params["tags"] = null;
+      }
+      if ((_ref4 = params["senders"]) == null) {
+        params["senders"] = null;
+      }
+      if ((_ref5 = params["states"]) == null) {
+        params["states"] = null;
+      }
+      return this.master.call('exports/activity', params, onsuccess, onerror);
+    };
+
+    return Exports;
+
+  })();
+
   Users = (function() {
 
     function Users(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.20",
+  "version": "1.0.21",
   "homepage": "https://bitbucket.org/mailchimp/mandrill-api-node",
   "repository": {
     "type": "git",