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

Commits

Dustin Shields-Cloues  committed 6823c3f

Add calls for managing message metadata

  • Participants
  • Parent commits d6dcc30
  • Branches master
  • Tags 1.0.38

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.37'}
+    headers: {'Content-Type': 'application/json', 'User-Agent': 'Mandrill-Node/1.0.38'}
 }
 
 class exports.Mandrill
         @urls = new Urls(this)
         @webhooks = new Webhooks(this)
         @senders = new Senders(this)
+        @metadata = new Metadata(this)
 
         if @apikey == null then @apikey = process.env['MANDRILL_APIKEY']
 
 
 
         @master.call('senders/time-series', params, onsuccess, onerror)
+class Metadata
+    constructor: (@master) ->
+
+
+    ###
+    Get the list of custom metadata fields indexed for the 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
+    ###
+    list: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+
+        @master.call('metadata/list', params, onsuccess, onerror)
+
+    ###
+    Add a new custom metadata field to be indexed for the account.
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} name a unique identifier for the metadata field
+    @option params {String} view_template optional Mustache template to control how the metadata is rendered in your activity log
+    @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 = {}
+
+        params["view_template"] ?= null
+
+        @master.call('metadata/add', params, onsuccess, onerror)
+
+    ###
+    Update an existing custom metadata field.
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} name the unique identifier of the metadata field to update
+    @option params {String} view_template optional Mustache template to control how the metadata is rendered in your activity log
+    @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
+    ###
+    update: (params={}, onsuccess, onerror) ->
+        if typeof params == 'function'
+            onerror = onsuccess
+            onsuccess = params
+            params = {}
+
+
+        @master.call('metadata/update', params, onsuccess, onerror)
+
+    ###
+    Delete an existing custom metadata field. Deletion isn't instataneous, and /metadata/list will continue to return the field until the asynchronous deletion process is complete.
+    @param {Object} params the hash of the parameters to pass to the request
+    @option params {String} name the unique identifier of the metadata field to update
+    @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('metadata/delete', params, onsuccess, onerror)
 
 

File mandrill.js

View file
  • Ignore whitespace
 // Generated by CoffeeScript 1.3.3
 (function() {
-  var Exports, Inbound, Internal, Ips, Messages, OPTS, Rejects, Senders, Subaccounts, Tags, Templates, Urls, Users, Webhooks, Whitelists, https;
+  var Exports, Inbound, Internal, Ips, Messages, Metadata, OPTS, Rejects, Senders, Subaccounts, Tags, Templates, Urls, Users, Webhooks, Whitelists, https;
 
   https = require('https');
 
     method: 'POST',
     headers: {
       'Content-Type': 'application/json',
-      'User-Agent': 'Mandrill-Node/1.0.37'
+      'User-Agent': 'Mandrill-Node/1.0.38'
     }
   };
 
       this.urls = new Urls(this);
       this.webhooks = new Webhooks(this);
       this.senders = new Senders(this);
+      this.metadata = new Metadata(this);
       if (this.apikey === null) {
         this.apikey = process.env['MANDRILL_APIKEY'];
       }
 
   })();
 
+  Metadata = (function() {
+
+    function Metadata(master) {
+      this.master = master;
+    }
+
+    /*
+        Get the list of custom metadata fields indexed for the 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
+    */
+
+
+    Metadata.prototype.list = function(params, onsuccess, onerror) {
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      return this.master.call('metadata/list', params, onsuccess, onerror);
+    };
+
+    /*
+        Add a new custom metadata field to be indexed for the account.
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} name a unique identifier for the metadata field
+        @option params {String} view_template optional Mustache template to control how the metadata is rendered in your activity log
+        @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
+    */
+
+
+    Metadata.prototype.add = function(params, onsuccess, onerror) {
+      var _ref;
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      if ((_ref = params["view_template"]) == null) {
+        params["view_template"] = null;
+      }
+      return this.master.call('metadata/add', params, onsuccess, onerror);
+    };
+
+    /*
+        Update an existing custom metadata field.
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} name the unique identifier of the metadata field to update
+        @option params {String} view_template optional Mustache template to control how the metadata is rendered in your activity log
+        @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
+    */
+
+
+    Metadata.prototype.update = function(params, onsuccess, onerror) {
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      return this.master.call('metadata/update', params, onsuccess, onerror);
+    };
+
+    /*
+        Delete an existing custom metadata field. Deletion isn't instataneous, and /metadata/list will continue to return the field until the asynchronous deletion process is complete.
+        @param {Object} params the hash of the parameters to pass to the request
+        @option params {String} name the unique identifier of the metadata field to update
+        @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
+    */
+
+
+    Metadata.prototype["delete"] = function(params, onsuccess, onerror) {
+      if (params == null) {
+        params = {};
+      }
+      if (typeof params === 'function') {
+        onerror = onsuccess;
+        onsuccess = params;
+        params = {};
+      }
+      return this.master.call('metadata/delete', params, onsuccess, onerror);
+    };
+
+    return Metadata;
+
+  })();
+
 }).call(this);

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.37",
+  "version": "1.0.38",
   "homepage": "https://bitbucket.org/mailchimp/mandrill-api-node",
   "repository": {
     "type": "git",