Comparing version 1.3.1 to 1.4.0
@@ -47,9 +47,10 @@ var defaults = require('./clientDefaults.js'); | ||
* @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). | ||
*/ | ||
AdminClient.prototype.processRequestWithoutBody = function(path, type, query, callback) { | ||
AdminClient.prototype.processRequestWithoutBody = function (path, type, query, callback) { | ||
if (query) { | ||
path += '?' + querystring.stringify(query); | ||
} | ||
this.processRequestWithBody(path, type, null, callback); | ||
} | ||
return this.processRequestWithBody(path, type, null, callback); | ||
}; | ||
@@ -64,2 +65,3 @@ /** | ||
* @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). | ||
*/ | ||
@@ -72,3 +74,3 @@ AdminClient.prototype.listSenderSignatures = function(query, callback) { | ||
}, query); | ||
this.processRequestWithoutBody('/senders', 'GET', query, callback); | ||
return this.processRequestWithoutBody('/senders', 'GET', query, callback); | ||
}; | ||
@@ -83,5 +85,6 @@ | ||
* @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). | ||
*/ | ||
AdminClient.prototype.getSenderSignature = function(id, callback) { | ||
this.processRequestWithoutBody('/senders/' + id, 'GET', null, callback); | ||
return this.processRequestWithoutBody('/senders/' + id, 'GET', null, callback); | ||
}; | ||
@@ -96,5 +99,6 @@ | ||
* @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). | ||
*/ | ||
AdminClient.prototype.createSenderSignature = function(options, callback) { | ||
this.processRequestWithBody('/senders/', 'POST', options, callback); | ||
return this.processRequestWithBody('/senders/', 'POST', options, callback); | ||
}; | ||
@@ -110,5 +114,6 @@ | ||
* @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). | ||
*/ | ||
AdminClient.prototype.editSenderSignature = function(id, options, callback) { | ||
this.processRequestWithBody('/senders/' + id, 'PUT', options, callback); | ||
return this.processRequestWithBody('/senders/' + id, 'PUT', options, callback); | ||
}; | ||
@@ -123,5 +128,6 @@ | ||
* @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). | ||
*/ | ||
AdminClient.prototype.deleteSenderSignature = function(id, callback) { | ||
this.processRequestWithoutBody('/senders/' + id, 'DELETE', null, callback); | ||
return this.processRequestWithoutBody('/senders/' + id, 'DELETE', null, callback); | ||
}; | ||
@@ -136,5 +142,6 @@ | ||
* @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). | ||
*/ | ||
AdminClient.prototype.resendSenderSignatureConfirmation = function(id, callback) { | ||
this.processRequestWithBody('/senders/' + id + '/resend', 'POST', null, callback); | ||
return this.processRequestWithBody('/senders/' + id + '/resend', 'POST', null, callback); | ||
}; | ||
@@ -150,5 +157,6 @@ | ||
* @deprecated verifyDomainSPF replaces this method | ||
* @return {Promise} If no callback is passed, returns a Promise with the JSON response from the API (or error). | ||
*/ | ||
AdminClient.prototype.verifySenderSignatureSPF = function(id, callback) { | ||
this.processRequestWithBody('/senders/' + id + '/verifyspf', 'POST', null, callback); | ||
return this.processRequestWithBody('/senders/' + id + '/verifyspf', 'POST', null, callback); | ||
}; | ||
@@ -164,5 +172,6 @@ | ||
* @deprecated rotateDKIMForDomain replaces this method | ||
* @return {Promise} If no callback is passed, returns a Promise with the JSON response from the API (or error). | ||
*/ | ||
AdminClient.prototype.requestNewDKIMForSenderSignature = function(id, callback) { | ||
this.processRequestWithBody('/senders/' + id + '/requestnewdkim', 'POST', null, callback); | ||
return this.processRequestWithBody('/senders/' + id + '/requestnewdkim', 'POST', null, callback); | ||
}; | ||
@@ -177,5 +186,6 @@ | ||
* @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). | ||
*/ | ||
AdminClient.prototype.getServer = function(id, callback) { | ||
this.processRequestWithoutBody('/servers/' + id, 'GET', null, callback); | ||
return this.processRequestWithoutBody('/servers/' + id, 'GET', null, callback); | ||
}; | ||
@@ -190,5 +200,6 @@ | ||
* @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). | ||
*/ | ||
AdminClient.prototype.createServer = function(options, callback) { | ||
this.processRequestWithBody('/servers/', 'POST', options, callback); | ||
return this.processRequestWithBody('/servers/', 'POST', options, callback); | ||
}; | ||
@@ -204,5 +215,6 @@ | ||
* @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). | ||
*/ | ||
AdminClient.prototype.editServer = function(id, options, callback) { | ||
this.processRequestWithBody('/servers/' + id, 'PUT', options, callback); | ||
return this.processRequestWithBody('/servers/' + id, 'PUT', options, callback); | ||
}; | ||
@@ -219,5 +231,6 @@ | ||
* @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). | ||
*/ | ||
AdminClient.prototype.deleteServer = function(id, callback) { | ||
this.processRequestWithoutBody('/servers/' + id, 'DELETE', null, callback); | ||
return this.processRequestWithoutBody('/servers/' + id, 'DELETE', null, callback); | ||
}; | ||
@@ -232,2 +245,3 @@ | ||
* @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). | ||
*/ | ||
@@ -240,3 +254,3 @@ AdminClient.prototype.listServers = function(query, callback) { | ||
}, query); | ||
this.processRequestWithoutBody('/servers/', 'GET', query, callback); | ||
return this.processRequestWithoutBody('/servers/', 'GET', query, callback); | ||
}; | ||
@@ -252,2 +266,3 @@ | ||
* @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). | ||
*/ | ||
@@ -260,3 +275,3 @@ AdminClient.prototype.listDomains = function(query, callback) { | ||
}, query); | ||
this.processRequestWithoutBody('/domains', 'GET', query, callback); | ||
return this.processRequestWithoutBody('/domains', 'GET', query, callback); | ||
}; | ||
@@ -271,5 +286,6 @@ | ||
* @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). | ||
*/ | ||
AdminClient.prototype.getDomain = function(id, callback) { | ||
this.processRequestWithoutBody('/domains/' + id, 'GET', null, callback); | ||
return this.processRequestWithoutBody('/domains/' + id, 'GET', null, callback); | ||
}; | ||
@@ -284,5 +300,6 @@ | ||
* @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). | ||
*/ | ||
AdminClient.prototype.createDomain = function(options, callback) { | ||
this.processRequestWithBody('/domains/', 'POST', options, callback); | ||
return this.processRequestWithBody('/domains/', 'POST', options, callback); | ||
}; | ||
@@ -298,5 +315,6 @@ | ||
* @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). | ||
*/ | ||
AdminClient.prototype.editDomain = function(id, options, callback) { | ||
this.processRequestWithBody('/domains/' + id, 'PUT', options, callback); | ||
return this.processRequestWithBody('/domains/' + id, 'PUT', options, callback); | ||
}; | ||
@@ -311,5 +329,6 @@ | ||
* @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). | ||
*/ | ||
AdminClient.prototype.deleteDomain = function(id, callback) { | ||
this.processRequestWithoutBody('/domains/' + id, 'DELETE', null, callback); | ||
return this.processRequestWithoutBody('/domains/' + id, 'DELETE', null, callback); | ||
}; | ||
@@ -324,5 +343,6 @@ | ||
* @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). | ||
*/ | ||
AdminClient.prototype.verifyDomainSPF = function(id, callback) { | ||
this.processRequestWithBody('/domains/' + id + '/verifyspf', 'POST', null, callback); | ||
return this.processRequestWithBody('/domains/' + id + '/verifyspf', 'POST', null, callback); | ||
}; | ||
@@ -337,7 +357,8 @@ | ||
* @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). | ||
*/ | ||
AdminClient.prototype.rotateDKIMForDomain = function(id, callback) { | ||
this.processRequestWithBody('/domains/' + id + '/rotatedkim', 'POST', null, callback); | ||
return this.processRequestWithBody('/domains/' + id + '/rotatedkim', 'POST', null, callback); | ||
}; | ||
module.exports = AdminClient; |
@@ -55,3 +55,3 @@ (function() { | ||
} | ||
this.processRequestWithBody(path, type, null, callback); | ||
return this.processRequestWithBody(path, type, null, callback); | ||
} | ||
@@ -67,5 +67,6 @@ | ||
* @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.send = function(message, callback) { | ||
this.processRequestWithBody('/email', 'POST', message, callback); | ||
return this.processRequestWithBody('/email', 'POST', message, callback); | ||
}; | ||
@@ -81,5 +82,6 @@ | ||
* @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.sendEmailWithTemplate = function(message, callback) { | ||
this.processRequestWithBody('/email/withTemplate', 'POST', message, callback); | ||
return this.processRequestWithBody('/email/withTemplate', 'POST', message, callback); | ||
}; | ||
@@ -95,5 +97,6 @@ | ||
* @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.batch = function(messages, callback) { | ||
this.processRequestWithBody('/email/batch', 'POST', messages, callback); | ||
return this.processRequestWithBody('/email/batch', 'POST', messages, callback); | ||
}; | ||
@@ -108,5 +111,6 @@ | ||
* @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.sendEmail = function(message, callback) { | ||
this.processRequestWithBody('/email', 'POST', message, callback); | ||
return this.processRequestWithBody('/email', 'POST', message, callback); | ||
}; | ||
@@ -121,5 +125,6 @@ | ||
* @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.sendEmailBatch = function(messages, callback) { | ||
this.processRequestWithBody('/email/batch', 'POST', messages, callback); | ||
return this.processRequestWithBody('/email/batch', 'POST', messages, callback); | ||
}; | ||
@@ -133,5 +138,6 @@ | ||
* @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.getDeliveryStatistics = function(callback) { | ||
this.processRequestWithoutBody('/deliverystats', 'GET', null, callback); | ||
return this.processRequestWithoutBody('/deliverystats', 'GET', null, callback); | ||
}; | ||
@@ -146,2 +152,3 @@ | ||
* @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). | ||
*/ | ||
@@ -155,3 +162,3 @@ Client.prototype.getBounces = function(filter, callback) { | ||
this.processRequestWithoutBody('/bounces', 'GET', filter, callback); | ||
return this.processRequestWithoutBody('/bounces', 'GET', filter, callback); | ||
}; | ||
@@ -166,5 +173,6 @@ | ||
* @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.getBounce = function(id, callback) { | ||
this.processRequestWithoutBody('/bounces/' + id, 'GET', null, callback); | ||
return this.processRequestWithoutBody('/bounces/' + id, 'GET', null, callback); | ||
}; | ||
@@ -178,5 +186,6 @@ | ||
* @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.getBounceDump = function(id, callback) { | ||
this.processRequestWithoutBody('/bounces/' + id + '/dump', 'GET', null, callback); | ||
return this.processRequestWithoutBody('/bounces/' + id + '/dump', 'GET', null, callback); | ||
}; | ||
@@ -191,5 +200,6 @@ | ||
* @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.activateBounce = function(id, callback) { | ||
this.processRequestWithBody('/bounces/' + id + '/activate', 'PUT', null, callback); | ||
return this.processRequestWithBody('/bounces/' + id + '/activate', 'PUT', null, callback); | ||
}; | ||
@@ -203,5 +213,6 @@ | ||
* @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.getBounceTags = function(callback) { | ||
this.processRequestWithoutBody('/bounces/tags', 'GET', null, callback); | ||
return this.processRequestWithoutBody('/bounces/tags', 'GET', null, callback); | ||
}; | ||
@@ -215,5 +226,6 @@ | ||
* @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.getServer = function(callback) { | ||
this.processRequestWithoutBody('/server', 'GET', null, callback); | ||
return this.processRequestWithoutBody('/server', 'GET', null, callback); | ||
}; | ||
@@ -228,5 +240,6 @@ | ||
* @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.editServer = function(options, callback) { | ||
this.processRequestWithBody('/server', 'PUT', options, callback); | ||
return this.processRequestWithBody('/server', 'PUT', options, callback); | ||
}; | ||
@@ -242,2 +255,3 @@ | ||
* @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). | ||
*/ | ||
@@ -250,3 +264,3 @@ Client.prototype.getOutboundMessages = function(filter, callback) { | ||
}, filter); | ||
this.processRequestWithoutBody('/messages/outbound', 'GET', filter, callback); | ||
return this.processRequestWithoutBody('/messages/outbound', 'GET', filter, callback); | ||
}; | ||
@@ -261,5 +275,6 @@ | ||
* @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.getOutboundMessageDetails = function(id, callback) { | ||
this.processRequestWithoutBody('/messages/outbound/' + id + '/details', 'GET', null, callback); | ||
return this.processRequestWithoutBody('/messages/outbound/' + id + '/details', 'GET', null, callback); | ||
}; | ||
@@ -275,2 +290,3 @@ | ||
* @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). | ||
*/ | ||
@@ -283,3 +299,3 @@ Client.prototype.getMessageOpens = function(filter, callback) { | ||
}, filter); | ||
this.processRequestWithoutBody('/messages/outbound/opens', 'GET', filter, callback); | ||
return this.processRequestWithoutBody('/messages/outbound/opens', 'GET', filter, callback); | ||
}; | ||
@@ -295,2 +311,3 @@ | ||
* @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). | ||
*/ | ||
@@ -303,3 +320,3 @@ Client.prototype.getMessageOpensForSingleMessage = function(id, filter, callback) { | ||
}, filter); | ||
this.processRequestWithoutBody('/messages/outbound/opens/' + id, 'GET', filter, callback); | ||
return this.processRequestWithoutBody('/messages/outbound/opens/' + id, 'GET', filter, callback); | ||
}; | ||
@@ -314,2 +331,3 @@ | ||
* @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). | ||
*/ | ||
@@ -322,3 +340,3 @@ Client.prototype.getInboundMessages = function(filter, callback) { | ||
}, filter); | ||
this.processRequestWithoutBody('/messages/inbound', 'GET', filter, callback); | ||
return this.processRequestWithoutBody('/messages/inbound', 'GET', filter, callback); | ||
}; | ||
@@ -333,5 +351,6 @@ | ||
* @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.getInboundMessageDetails = function(id, callback) { | ||
this.processRequestWithoutBody('/messages/inbound/' + id + '/details', 'GET', null, callback); | ||
return this.processRequestWithoutBody('/messages/inbound/' + id + '/details', 'GET', null, callback); | ||
}; | ||
@@ -346,5 +365,6 @@ | ||
* @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.bypassBlockedInboundMessage = function(id, callback) { | ||
this.processRequestWithBody('/messages/inbound/' + id + '/bypass', 'PUT', null, callback); | ||
return this.processRequestWithBody('/messages/inbound/' + id + '/bypass', 'PUT', null, callback); | ||
}; | ||
@@ -359,5 +379,6 @@ | ||
* @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.retryInboundHookForMessage = function(id, callback) { | ||
this.processRequestWithBody('/messages/inbound/' + id + '/retry', 'PUT', null, callback); | ||
return this.processRequestWithBody('/messages/inbound/' + id + '/retry', 'PUT', null, callback); | ||
}; | ||
@@ -373,6 +394,7 @@ | ||
* @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.getOuboundOverview = function(filter, callback) { | ||
callback = coalesceCallback(filter, callback); | ||
this.processRequestWithoutBody('/stats/outbound', 'GET', filter, callback); | ||
return this.processRequestWithoutBody('/stats/outbound', 'GET', filter, callback); | ||
}; | ||
@@ -387,6 +409,7 @@ | ||
* @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.getSentCounts = function(filter, callback) { | ||
callback = coalesceCallback(filter, callback); | ||
this.processRequestWithoutBody('/stats/outbound/sends', 'GET', filter, callback); | ||
return this.processRequestWithoutBody('/stats/outbound/sends', 'GET', filter, callback); | ||
}; | ||
@@ -401,6 +424,7 @@ | ||
* @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.getBounceCounts = function(filter, callback) { | ||
callback = coalesceCallback(filter, callback); | ||
this.processRequestWithoutBody('/stats/outbound/bounces', 'GET', filter, callback); | ||
return this.processRequestWithoutBody('/stats/outbound/bounces', 'GET', filter, callback); | ||
}; | ||
@@ -415,6 +439,7 @@ | ||
* @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.getSpamComplaints = function(filter, callback) { | ||
callback = coalesceCallback(filter, callback); | ||
this.processRequestWithoutBody('/stats/outbound/spam', 'GET', filter, callback); | ||
return this.processRequestWithoutBody('/stats/outbound/spam', 'GET', filter, callback); | ||
}; | ||
@@ -429,6 +454,7 @@ | ||
* @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.getTrackedEmailCounts = function(filter, callback) { | ||
callback = coalesceCallback(filter, callback); | ||
this.processRequestWithoutBody('/stats/outbound/tracked', 'GET', filter, callback); | ||
return this.processRequestWithoutBody('/stats/outbound/tracked', 'GET', filter, callback); | ||
}; | ||
@@ -443,6 +469,7 @@ | ||
* @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.getEmailOpenCounts = function(filter, callback) { | ||
callback = coalesceCallback(filter, callback); | ||
this.processRequestWithoutBody('/stats/outbound/opens', 'GET', filter, callback); | ||
return this.processRequestWithoutBody('/stats/outbound/opens', 'GET', filter, callback); | ||
}; | ||
@@ -457,6 +484,7 @@ | ||
* @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.getEmailPlatformUsage = function(filter, callback) { | ||
callback = coalesceCallback(filter, callback); | ||
this.processRequestWithoutBody('/stats/outbound/opens/platforms', 'GET', filter, callback); | ||
return this.processRequestWithoutBody('/stats/outbound/opens/platforms', 'GET', filter, callback); | ||
}; | ||
@@ -471,6 +499,7 @@ | ||
* @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.getEmailClientUsage = function(filter, callback) { | ||
callback = coalesceCallback(filter, callback); | ||
this.processRequestWithoutBody('/stats/outbound/opens/emailclients', 'GET', filter, callback); | ||
return this.processRequestWithoutBody('/stats/outbound/opens/emailclients', 'GET', filter, callback); | ||
}; | ||
@@ -485,6 +514,7 @@ | ||
* @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.getEmailReadTimes = function(filter, callback) { | ||
callback = coalesceCallback(filter, callback); | ||
this.processRequestWithoutBody('/stats/outbound/opens/readtimes', 'GET', filter, callback); | ||
return this.processRequestWithoutBody('/stats/outbound/opens/readtimes', 'GET', filter, callback); | ||
}; | ||
@@ -499,6 +529,7 @@ | ||
* @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.getClickCounts = function(filter, callback) { | ||
callback = coalesceCallback(filter, callback); | ||
this.processRequestWithoutBody('/stats/outbound/clicks', 'GET', filter, callback); | ||
return this.processRequestWithoutBody('/stats/outbound/clicks', 'GET', filter, callback); | ||
}; | ||
@@ -513,6 +544,7 @@ | ||
* @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.getBrowserUsage = function(filter, callback) { | ||
callback = coalesceCallback(filter, callback); | ||
this.processRequestWithoutBody('/stats/outbound/clicks/browserfamilies', 'GET', filter, callback); | ||
return this.processRequestWithoutBody('/stats/outbound/clicks/browserfamilies', 'GET', filter, callback); | ||
}; | ||
@@ -527,6 +559,7 @@ | ||
* @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.getBrowserPlatforms = function(filter, callback) { | ||
callback = coalesceCallback(filter, callback); | ||
this.processRequestWithoutBody('/stats/outbound/clicks/platforms', 'GET', filter, callback); | ||
return this.processRequestWithoutBody('/stats/outbound/clicks/platforms', 'GET', filter, callback); | ||
}; | ||
@@ -542,6 +575,7 @@ | ||
* @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.getClickLocation = function(filter, callback) { | ||
callback = coalesceCallback(filter, callback); | ||
this.processRequestWithoutBody('/stats/outbound/clicks/location', 'GET', filter, callback); | ||
return this.processRequestWithoutBody('/stats/outbound/clicks/location', 'GET', filter, callback); | ||
}; | ||
@@ -556,5 +590,6 @@ | ||
* @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.createTagTrigger = function(options, callback) { | ||
this.processRequestWithBody('/triggers/tags', 'POST', options, callback); | ||
return this.processRequestWithBody('/triggers/tags', 'POST', options, callback); | ||
}; | ||
@@ -570,2 +605,3 @@ | ||
* @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). | ||
*/ | ||
@@ -583,5 +619,6 @@ Client.prototype.editTagTrigger = function(id, options, callback) { | ||
* @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.deleteTagTrigger = function(id, callback) { | ||
this.processRequestWithoutBody('/triggers/tags/' + id, 'DELETE', null, callback); | ||
return this.processRequestWithoutBody('/triggers/tags/' + id, 'DELETE', null, callback); | ||
}; | ||
@@ -596,5 +633,6 @@ | ||
* @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.getTagTrigger = function(id, callback) { | ||
this.processRequestWithoutBody('/triggers/tags/' + id, 'GET', null, callback); | ||
return this.processRequestWithoutBody('/triggers/tags/' + id, 'GET', null, callback); | ||
}; | ||
@@ -610,2 +648,3 @@ | ||
* @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). | ||
*/ | ||
@@ -618,3 +657,3 @@ Client.prototype.getTagTriggers = function(filter, callback) { | ||
}, filter); | ||
this.processRequestWithoutBody('/triggers/tags/', 'GET', filter, callback); | ||
return this.processRequestWithoutBody('/triggers/tags/', 'GET', filter, callback); | ||
}; | ||
@@ -629,5 +668,6 @@ | ||
* @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.createInboundRuleTrigger = function(options, callback) { | ||
this.processRequestWithBody('/triggers/inboundrules', 'POST', options, callback); | ||
return this.processRequestWithBody('/triggers/inboundrules', 'POST', options, callback); | ||
}; | ||
@@ -642,5 +682,6 @@ | ||
* @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.deleteInboundRuleTrigger = function(id, callback) { | ||
this.processRequestWithoutBody('/triggers/inboundrules/' + id, 'DELETE', null, callback); | ||
return this.processRequestWithoutBody('/triggers/inboundrules/' + id, 'DELETE', null, callback); | ||
}; | ||
@@ -656,2 +697,3 @@ | ||
* @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). | ||
*/ | ||
@@ -664,3 +706,3 @@ Client.prototype.getInboundRuleTriggers = function(filter, callback) { | ||
}, filter); | ||
this.processRequestWithoutBody('/triggers/inboundrules', 'GET', filter, callback); | ||
return this.processRequestWithoutBody('/triggers/inboundrules', 'GET', filter, callback); | ||
}; | ||
@@ -675,2 +717,3 @@ | ||
* @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). | ||
*/ | ||
@@ -683,3 +726,3 @@ Client.prototype.getTemplates = function(options, callback) { | ||
}, options); | ||
this.processRequestWithoutBody('/templates', 'GET', options, callback); | ||
return this.processRequestWithoutBody('/templates', 'GET', options, callback); | ||
}; | ||
@@ -695,5 +738,6 @@ | ||
* @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) { | ||
this.processRequestWithoutBody('/templates/' + id, 'GET', null, callback); | ||
return this.processRequestWithoutBody('/templates/' + id, 'GET', null, callback); | ||
}; | ||
@@ -708,5 +752,6 @@ | ||
* @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) { | ||
this.processRequestWithoutBody('/templates/' + id, 'DELETE', null, callback); | ||
return this.processRequestWithoutBody('/templates/' + id, 'DELETE', null, callback); | ||
} | ||
@@ -721,5 +766,6 @@ | ||
* @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.createTemplate = function(template, callback) { | ||
this.processRequestWithBody('/templates/', 'POST', template, callback); | ||
return this.processRequestWithBody('/templates/', 'POST', template, callback); | ||
} | ||
@@ -735,5 +781,6 @@ | ||
* @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) { | ||
this.processRequestWithBody('/templates/' + id, 'PUT', template, callback); | ||
return this.processRequestWithBody('/templates/' + id, 'PUT', template, callback); | ||
} | ||
@@ -749,5 +796,6 @@ | ||
* @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.validateTemplate = function(templateContent, callback) { | ||
this.processRequestWithBody('/templates/validate', 'POST', templateContent, callback); | ||
return this.processRequestWithBody('/templates/validate', 'POST', templateContent, callback); | ||
} | ||
@@ -754,0 +802,0 @@ |
@@ -1,7 +0,9 @@ | ||
var rev = require('git-rev'); | ||
var sha = 'unknown revision'; | ||
var http = require('http'); | ||
var https = require('https'); | ||
var version = require('../../package.json').version; | ||
var exec = require('child_process').exec; | ||
rev.long(function(longSha) { | ||
sha = longSha || 'unknown revision'; | ||
exec('git rev-parse HEAD', { cwd: __dirname }, function (err, stdout, stderr) { | ||
sha = stdout.split('\n').join('') || 'unknown revision'; | ||
}); | ||
@@ -23,5 +25,5 @@ | ||
requestFactory: function(options) { | ||
var client = require('http' + (options.ssl === true ? 's' : '')); | ||
var client = options.ssl === true ? https : http; | ||
return function(path, type, content, callback) { | ||
function request(path, type, content, callback) { | ||
var msg = null; | ||
@@ -75,4 +77,4 @@ if (content) { | ||
status: response.statusCode, | ||
message: data['Message'], | ||
code: data['ErrorCode'] | ||
message: data.Message, | ||
code: data.ErrorCode | ||
}); | ||
@@ -103,5 +105,23 @@ } catch (e) { | ||
} | ||
return function(path, type, content, callback) { | ||
if (callback || typeof Promise === 'undefined') { | ||
request(path, type, content, callback); | ||
} | ||
else { | ||
return new Promise(function(resolve, reject) { | ||
request(path, type, content, function(error, result) { | ||
if (error) { | ||
reject(error); | ||
} | ||
else{ | ||
resolve(result); | ||
} | ||
}); | ||
}); | ||
} | ||
}; | ||
} | ||
}; | ||
module.exports = ClientDefaults; | ||
module.exports = ClientDefaults; |
// The following docs support type definitions, without the need to actually create these types. | ||
/** | ||
* A node.js Promise. This is returned if a callback is not provided when making a call to the API. | ||
* | ||
* @class Promise | ||
*/ | ||
/** | ||
* Postmark Error | ||
@@ -5,0 +11,0 @@ * |
@@ -9,3 +9,3 @@ { | ||
], | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"author": "Chris Williams <voodootikigod@gmail.com>", | ||
@@ -67,5 +67,4 @@ "contributors": [ | ||
"dependencies": { | ||
"git-rev": "0.2.1", | ||
"merge": "1.2.0" | ||
} | ||
} |
@@ -7,3 +7,3 @@ ## Postmark.js | ||
[Complete documentation can be found here](https://wildbit.github.io/postmark.js/), but the following information should get you started... | ||
As the official node.js library for Postmark, postmark.js has support for the entire REST API. To see everything that is supported, have a look at the [complete documentation](https://wildbit.github.io/postmark.js/), but the following information covers the most common sending cases... | ||
@@ -36,3 +36,3 @@ ### Install | ||
Your message must be provided in the format specified in the [Postmark API](http://developer.postmarkapp.com/developer-build.html#message-format) and will be verified. The **member names of | ||
Your message must be provided in the format specified in the [Postmark API](http://developer.postmarkapp.com/developer-api-messages.html#outbound-message-details) and will be verified. The **member names of | ||
message payloads are case-sensitive**, and messages not matching the documented format will not | ||
@@ -39,0 +39,0 @@ be accepted by the API. |
@@ -11,5 +11,6 @@ var mocha = require('mocha'); | ||
var postmark = require('../lib/postmark/index.js'); | ||
var helpers = require('./test_helpers.js'); | ||
describe('admin client domain management', function() { | ||
this.timeout(4000); | ||
this.timeout(10000); | ||
var prefix = 'node-js-test-domain'; | ||
@@ -28,3 +29,6 @@ | ||
after(function() { | ||
before(cleanup); | ||
after(cleanup); | ||
function cleanup(){ | ||
var rulePrefixTester = new RegExp(prefix); | ||
@@ -37,3 +41,3 @@ var c = new postmark.AdminClient(testingKeys.get('WRITE_ACCOUNT_TOKEN')); | ||
if (rulePrefixTester.test(domain.Name)) { | ||
c.deleteDomain(domain.ID); | ||
c.deleteDomain(domain.ID, helpers.report); | ||
} | ||
@@ -43,4 +47,4 @@ } | ||
}); | ||
}); | ||
}; | ||
it("can create a domain", function(done) { | ||
@@ -60,4 +64,8 @@ _client.createDomain({ | ||
Name: 'get-test-' + _domainName | ||
}, function(err, domain) { | ||
_client.getDomain(domain.ID, done); | ||
}, function (err, domain) { | ||
if (err) { | ||
done(err); | ||
} else { | ||
_client.getDomain(domain.ID, done); | ||
} | ||
}); | ||
@@ -64,0 +72,0 @@ }); |
@@ -11,5 +11,6 @@ var mocha = require('mocha'); | ||
var postmark = require('../lib/postmark/index.js'); | ||
var helpers = require('./test_helpers.js'); | ||
describe('admin client server management', function() { | ||
this.timeout(4000); | ||
this.timeout(10000); | ||
var prefix = "node-js-tests"; | ||
@@ -23,3 +24,3 @@ | ||
after(function() { | ||
function cleanup() { | ||
var rulePrefixTester = new RegExp(prefix); | ||
@@ -32,3 +33,3 @@ var c = new postmark.AdminClient(testingKeys.get('WRITE_ACCOUNT_TOKEN')); | ||
if (rulePrefixTester.test(server.Name)) { | ||
c.deleteServer(server.ID); | ||
c.deleteServer(server.ID, helpers.report); | ||
} | ||
@@ -38,4 +39,7 @@ } | ||
}); | ||
}); | ||
}; | ||
before(cleanup); | ||
after(cleanup); | ||
it("can get a server", function(done) { | ||
@@ -42,0 +46,0 @@ _client.listServers(function(err, servers) { |
@@ -11,9 +11,10 @@ var mocha = require('mocha'); | ||
var postmark = require('../lib/postmark/index.js'); | ||
var helpers = require('./test_helpers.js'); | ||
describe('admin client signature management', function() { | ||
this.timeout(4000); | ||
this.timeout(10000); | ||
var prefix = "node-js-tests"; | ||
var _client = null; | ||
var _email = null | ||
var _email = null; | ||
@@ -27,3 +28,3 @@ beforeEach(function() { | ||
after(function() { | ||
function cleanup() { | ||
var rulePrefixTester = new RegExp(prefix); | ||
@@ -36,8 +37,23 @@ var c = new postmark.AdminClient(testingKeys.get('WRITE_ACCOUNT_TOKEN')); | ||
if (rulePrefixTester.test(signature.Name)) { | ||
c.deleteSenderSignature(signature.ID); | ||
c.deleteSenderSignature(signature.ID, helpers.report); | ||
} | ||
} | ||
c.listDomains(function(err, resp) { | ||
if (!err) { | ||
var tester = new RegExp(_email.split('@')[1]); | ||
for (var i = 0; i < resp.Domains.length; i++) { | ||
var domain = resp.Domains[i]; | ||
if (tester.test(domain.Name)) { | ||
c.deleteDomain(domain.ID, helpers.report); | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
} | ||
after(cleanup); | ||
before(cleanup); | ||
@@ -52,4 +68,8 @@ it("can list signatures", function(done) { | ||
FromEmail: _email | ||
}, function(err, signature) { | ||
_client.getSenderSignature(signature.ID, done); | ||
}, function (err, signature) { | ||
if (!err) { | ||
_client.getSenderSignature(signature.ID, done); | ||
} else { | ||
done(err); | ||
} | ||
}); | ||
@@ -56,0 +76,0 @@ }); |
@@ -25,6 +25,2 @@ var mocha = require('mocha'); | ||
it('can get bounce counts', function(done) { | ||
_client.getMessageOpens(done); | ||
}); | ||
it('can get browser usage', function(done) { | ||
@@ -31,0 +27,0 @@ _client.getBrowserUsage(done); |
@@ -21,8 +21,2 @@ var mocha = require('mocha'); | ||
it('can get message opens', function(done) { | ||
_client.getMessageOpens({ | ||
count: 5 | ||
}, done); | ||
}); | ||
it('can get delivery statistics', function(done) { | ||
@@ -48,33 +42,6 @@ _client.getDeliveryStatistics(done); | ||
it('can get email open counts', function(done) { | ||
_client.getEmailOpenCounts(done); | ||
}); | ||
it('can get email platform usage', function(done) { | ||
_client.getEmailPlatformUsage(done); | ||
}); | ||
it('can get email client usage', function(done) { | ||
_client.getEmailClientUsage(done); | ||
}); | ||
it('can get bounce counts', function(done) { | ||
_client.getMessageOpens(done); | ||
_client.getBounceCounts(done); | ||
}); | ||
it('can get bounce counts', function(done) { | ||
_client.getMessageOpens(done); | ||
}); | ||
it('can get message opens for single message', function(done) { | ||
_client.getMessageOpens({ | ||
count: 1 | ||
}, function(err, batch) { | ||
_client.getMessageOpensForSingleMessage(batch.Opens[0].MessageID, { | ||
count: 1 | ||
}, | ||
done); | ||
}); | ||
}); | ||
it('can get outbound overview', function(done) { | ||
@@ -81,0 +48,0 @@ var now = new Date(); |
@@ -11,2 +11,3 @@ var mocha = require('mocha'); | ||
var postmark = require('../lib/postmark/index.js'); | ||
var helpers = require('./test_helpers.js'); | ||
@@ -19,16 +20,18 @@ describe('client template handling', function() { | ||
_client = new postmark.Client(testingKeys.get('WRITE_TEST_SERVER_TOKEN')); | ||
cleanup(); | ||
}); | ||
after(function() { | ||
_client.getTemplates(function(err, results) { | ||
function cleanup() { | ||
_client.getTemplates({ offset : 0, count : 100 }, function(err, results) { | ||
while (results.Templates.length > 0) { | ||
var t = results.Templates.pop(); | ||
if (/testing-template-node-js/.test(t.Name)) { | ||
_client.deleteTemplate(t.TemplateId); | ||
_client.deleteTemplate(t.TemplateId, helpers.report); | ||
} | ||
} | ||
}); | ||
}); | ||
} | ||
after(cleanup); | ||
it('should retrieve a list of templates.', function(done) { | ||
@@ -35,0 +38,0 @@ _client.getTemplates(done); |
@@ -11,5 +11,6 @@ var mocha = require('mocha'); | ||
var postmark = require('../lib/postmark/index.js'); | ||
var helpers = require('./test_helpers.js'); | ||
describe('client tag handling', function() { | ||
this.timeout(5000); | ||
this.timeout(10000); | ||
var prefix = "node-js-tests"; | ||
@@ -31,3 +32,3 @@ | ||
if (rulePrefixTester.test(trigger.Rule)) { | ||
c.deleteInboundRuleTrigger(trigger.ID); | ||
c.deleteInboundRuleTrigger(trigger.ID, helpers.report); | ||
} | ||
@@ -43,3 +44,3 @@ } | ||
if (rulePrefixTester.test(trigger.MatchName)) { | ||
c.deleteTagTrigger(trigger.ID); | ||
c.deleteTagTrigger(trigger.ID, helpers.report); | ||
} | ||
@@ -46,0 +47,0 @@ } |
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
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
3526425
1
71
124618
0
3
- Removedgit-rev@0.2.1
- Removedgit-rev@0.2.1(transitive)