Comparing version 1.5.0 to 1.6.0
@@ -1,2 +0,4 @@ | ||
(function() { | ||
'use strict'; | ||
(function () { | ||
var defaults = require('./clientDefaults.js'); | ||
@@ -114,2 +116,15 @@ var merge = require('merge'); | ||
/** | ||
* Send a batch of templated email messages. | ||
* | ||
* @memberof Client.prototype | ||
* @method sendEmailBatch | ||
* @param {PostmarkTemplateMessage[]} messages An array of `PostmarkTemplateMessage` you wish to send using this Client. | ||
* @param {PostmarkCallback} callback A standard callback that is called when the API request completes. | ||
* @return {Promise} If no callback is passed, returns a Promise with the JSON response from the API (or error). | ||
*/ | ||
Client.prototype.sendEmailBatchWithTemplates = function(messages, callback) { | ||
return this.processRequestWithBody('/email/batchWithTemplates', 'POST', { Messages: messages }, callback); | ||
}; | ||
/** | ||
* Send a batch of email messages. | ||
@@ -724,8 +739,8 @@ * | ||
* @method getTemplate | ||
* @param {int} [id] The templateid for the template you wish to retrieve. | ||
* @param {int|string} [idOrAlias] The templateid or alias for the template you wish to retrieve. | ||
* @param {PostmarkCallback} callback A standard callback that is called when the API request completes. | ||
* @return {Promise} If no callback is passed, returns a Promise with the JSON response from the API (or error). | ||
*/ | ||
Client.prototype.getTemplate = function(id, callback) { | ||
return this.processRequestWithoutBody('/templates/' + id, 'GET', null, callback); | ||
Client.prototype.getTemplate = function(idOrAlias, callback) { | ||
return this.processRequestWithoutBody('/templates/' + idOrAlias, 'GET', null, callback); | ||
}; | ||
@@ -738,8 +753,8 @@ | ||
* @method deleteTemplate | ||
* @param {int} [id] The templateid you wish to delete. | ||
* @param {int|string} [idOrAlias] The templateid or template alias you wish to delete. | ||
* @param {PostmarkCallback} callback A standard callback that is called when the API request completes. | ||
* @return {Promise} If no callback is passed, returns a Promise with the JSON response from the API (or error). | ||
*/ | ||
Client.prototype.deleteTemplate = function(id, callback) { | ||
return this.processRequestWithoutBody('/templates/' + id, 'DELETE', null, callback); | ||
Client.prototype.deleteTemplate = function(idOrAlias, callback) { | ||
return this.processRequestWithoutBody('/templates/' + idOrAlias, 'DELETE', null, callback); | ||
} | ||
@@ -765,9 +780,9 @@ | ||
* @method editTemplate | ||
* @param {number} id The id of the template you wish to update. | ||
* @param {object} template The values on the template you wish to update. | ||
* @param {PostmarkCallback} callback A standard callback that is called when the API request completes. | ||
* @param {number|string} [idOrAlias] The id or alias of the template you wish to update. | ||
* @param {object} [template] The values on the template you wish to update. | ||
* @param {PostmarkCallback} [callback] A standard callback that is called when the API request completes. | ||
* @return {Promise} If no callback is passed, returns a Promise with the JSON response from the API (or error). | ||
*/ | ||
Client.prototype.editTemplate = function(id, template, callback) { | ||
return this.processRequestWithBody('/templates/' + id, 'PUT', template, callback); | ||
Client.prototype.editTemplate = function(idOrAlias, template, callback) { | ||
return this.processRequestWithBody('/templates/' + idOrAlias, 'PUT', template, callback); | ||
} | ||
@@ -781,3 +796,3 @@ | ||
* @method validateTemplate | ||
* @param {object} [templateContent] The template you wish to update. | ||
* @param {object} [templateContent] The template you wish to validate. | ||
* @param {PostmarkCallback} callback A standard callback that is called when the API request completes. | ||
@@ -784,0 +799,0 @@ * @return {Promise} If no callback is passed, returns a Promise with the JSON response from the API (or error). |
@@ -50,3 +50,4 @@ // The following docs support type definitions, without the need to actually create these types. | ||
* @typedef PostmarkTemplateMessage | ||
* @property {number} TemplateId The templateId to use when sending this message. | ||
* @property {number} [TemplateId] The templateId to use when sending this message, optionally, you may use TemplateAlias instead of this property. If both are set, then TemplateID is used to select which template to send. | ||
* @property {string} [TemplateAlias] The templateAlias to use when sending this message. | ||
* @property {string} To A comma-separate list of recipients. | ||
@@ -53,0 +54,0 @@ * @property {string} From The email address of the sender, must be a registered and confirmed Sender Signature. |
@@ -9,3 +9,3 @@ { | ||
], | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"author": "Andrew Theken <andrew+postmark.js@wildbit.com>", | ||
@@ -12,0 +12,0 @@ "contributors": [ |
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
var mocha = require('mocha'); | ||
@@ -2,0 +4,0 @@ var assert = require('assert'); |
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
var mocha = require('mocha'); | ||
@@ -2,0 +4,0 @@ var assert = require('assert'); |
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
var mocha = require('mocha'); | ||
@@ -16,5 +18,7 @@ var assert = require('assert'); | ||
var _client = null; | ||
var testTemplateAlias = 'postmark-js-batch-testing template'; | ||
beforeEach(function() { | ||
_client = new postmark.Client(testingKeys.get('WRITE_TEST_SERVER_TOKEN')); | ||
_client.deleteTemplate(testTemplateAlias); | ||
}); | ||
@@ -67,2 +71,22 @@ | ||
}); | ||
it('can send a batch of templated emails', function(done) { | ||
var emailBatch = []; | ||
//create a template, and then send with it. | ||
_client.createTemplate({ | ||
subject: 'postmark-js-batch-testing template', | ||
textBody: 'postmark-js-batch-testing template', | ||
name: testTemplateAlias, | ||
alias: testTemplateAlias | ||
}, function(){ | ||
for (var i = 0; i < 3; i++) { | ||
emailBatch.push({ | ||
to: testingKeys.get('WRITE_TEST_EMAIL_RECIPIENT_ADDRESS'), | ||
from: testingKeys.get('WRITE_TEST_SENDER_EMAIL_ADDRESS'), | ||
templateAlias: 'postmark-js-batch-testing' | ||
}); | ||
} | ||
_client.sendEmailBatchWithTemplates(emailBatch, done); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3510702
124692