Comparing version 1.2.1 to 1.3.0
@@ -139,4 +139,5 @@ var defaults = require('./clientDefaults.js'); | ||
* @method verifySenderSignatureSPF | ||
* @param {number} id The ID for the Sender Signature for which you wish to have the SPI verified. | ||
* @param {number} id The ID for the Sender Signature for which you wish to have the SPF verified. | ||
* @param {PostmarkCallback} callback A standard callback that is called when the API request completes. | ||
* @deprecated verifyDomainSPF replaces this method | ||
*/ | ||
@@ -154,2 +155,3 @@ AdminClient.prototype.verifySenderSignatureSPF = function(id, callback) { | ||
* @param {PostmarkCallback} callback A standard callback that is called when the API request completes. | ||
* @deprecated rotateDKIMForDomain replaces this method | ||
*/ | ||
@@ -216,3 +218,3 @@ AdminClient.prototype.requestNewDKIMForSenderSignature = function(id, callback) { | ||
* @method listServers | ||
* @param {number} [query] An optional filter to use when retrieving the list of Servers. | ||
* @param {object} [query] An optional filter to use when retrieving the list of Servers. | ||
* @param {PostmarkCallback} callback A standard callback that is called when the API request completes. | ||
@@ -229,2 +231,93 @@ */ | ||
module.exports = AdminClient; | ||
/** | ||
* Get a list of Domains associated with this account. By default, | ||
* this method returns the first 100 domains in your account. | ||
* | ||
* @memberOf AdminClient.prototype | ||
* @method listDomains | ||
* @param {object} [query] An optional filter to be used when retrieving the list of Domains. | ||
* @param {PostmarkCallback} callback A standard callback that is called when the API request completes. | ||
*/ | ||
AdminClient.prototype.listDomains = function(query, callback) { | ||
callback = coalesceCallback(query, callback); | ||
query = merge({ | ||
count: 100, | ||
offset: 0 | ||
}, query); | ||
this.processRequestWithoutBody('/domains', 'GET', query, callback); | ||
}; | ||
/** | ||
* Get a single Domain by id. | ||
* | ||
* @memberOf AdminClient.prototype | ||
* @method getDomain | ||
* @param {number} id The ID for the Domain you wish to retrieve. | ||
* @param {PostmarkCallback} callback A standard callback that is called when the API request completes. | ||
*/ | ||
AdminClient.prototype.getDomain = function(id, callback) { | ||
this.processRequestWithoutBody('/domains/' + id, 'GET', null, callback); | ||
}; | ||
/** | ||
* Create a Domain. | ||
* | ||
* @memberOf AdminClient.prototype | ||
* @method createDomain | ||
* @param {object} options The configuration options for the Domain to be created. | ||
* @param {PostmarkCallback} callback A standard callback that is called when the API request completes. | ||
*/ | ||
AdminClient.prototype.createDomain = function(options, callback) { | ||
this.processRequestWithBody('/domains/', 'POST', options, callback); | ||
}; | ||
/** | ||
* Modify an existing Domain. | ||
* | ||
* @memberOf AdminClient.prototype | ||
* @method editDomain | ||
* @param {number} id The ID of the Domain to be modified. | ||
* @param {object} options The updated options for the Domain to be modified. | ||
* @param {postmarkCallback} callback A standard callback that is called when the API request completes. | ||
*/ | ||
AdminClient.prototype.editDomain = function(id, options, callback) { | ||
this.processRequestWithBody('/domains/' + id, 'PUT', options, callback); | ||
}; | ||
/** | ||
* Delete a Domain. | ||
* | ||
* @memberOf AdminClient.prototype | ||
* @method deleteDomain | ||
* @param {number} id The ID for the Domain you wish to delete. | ||
* @param {PostmarkCallback} callback A standard callback that is called when the API request completes. | ||
*/ | ||
AdminClient.prototype.deleteDomain = function(id, callback) { | ||
this.processRequestWithoutBody('/domains/' + id, 'DELETE', null, callback); | ||
}; | ||
/** | ||
* Request that the SPF records for Domain be verified. | ||
* | ||
* @memberOf AdminClient.prototype | ||
* @method verifyDomainSPF | ||
* @param {number} id The ID for the Domain for which you wish to have the SPF verified. | ||
* @param {PostmarkCallback} callback A standard callback that is called when the API request completes. | ||
*/ | ||
AdminClient.prototype.verifyDomainSPF = function(id, callback) { | ||
this.processRequestWithBody('/domains/' + id + '/verifyspf', 'POST', null, callback); | ||
}; | ||
/** | ||
* Rotate DKIM keys for the specified Domain. | ||
* | ||
* @memberOf AdminClient.prototype | ||
* @method rotateDKIMForDomain | ||
* @param {number} id The ID for the for which you wish have a new DKIM issued. | ||
* @param {PostmarkCallback} callback A standard callback that is called when the API request completes. | ||
*/ | ||
AdminClient.prototype.rotateDKIMForDomain = function(id, callback) { | ||
this.processRequestWithBody('/domains/' + id + '/rotatedkim', 'POST', null, callback); | ||
}; | ||
module.exports = AdminClient; |
@@ -77,5 +77,3 @@ (function() { | ||
* @method sendEmailWithTemplate | ||
* @param { PostmarkTemplateMessage | ||
} | ||
message The message you wish to send. | ||
* @param {PostmarkTemplateMessage} message The message you wish to send. | ||
* @param {PostmarkCallback} callback A standard callback that is called when the API request completes. | ||
@@ -460,2 +458,55 @@ */ | ||
/** | ||
* Get total clicks statistics for tracked links for messages sent from the Server associated with this Client. | ||
* | ||
* @memberof Client.prototype | ||
* @method getClickCounts | ||
* @param {object} [filter] Optional filtering parameters. | ||
* @param {PostmarkCallback} callback A standard callback that is called when the API request completes. | ||
*/ | ||
Client.prototype.getClickCounts = function(filter, callback) { | ||
callback = coalesceCallback(filter, callback); | ||
this.processRequestWithoutBody('/stats/outbound/clicks', 'GET', filter, callback); | ||
}; | ||
/** | ||
* Get browser family statistics for tracked links for messages sent from the Server associated with this Client. | ||
* | ||
* @memberof Client.prototype | ||
* @method getBrowserUsage | ||
* @param {object} [filter] Optional filtering parameters. | ||
* @param {PostmarkCallback} callback A standard callback that is called when the API request completes. | ||
*/ | ||
Client.prototype.getBrowserUsage = function(filter, callback) { | ||
callback = coalesceCallback(filter, callback); | ||
this.processRequestWithoutBody('/stats/outbound/clicks/browserfamilies', 'GET', filter, callback); | ||
}; | ||
/** | ||
* Get browser platform statistics for tracked links for messages sent from the Server associated with this Client. | ||
* | ||
* @memberof Client.prototype | ||
* @method getBrowserPlatforms | ||
* @param {object} [filter] Optional filtering parameters. | ||
* @param {PostmarkCallback} callback A standard callback that is called when the API request completes. | ||
*/ | ||
Client.prototype.getBrowserPlatforms = function(filter, callback) { | ||
callback = coalesceCallback(filter, callback); | ||
this.processRequestWithoutBody('/stats/outbound/clicks/platforms', 'GET', filter, callback); | ||
}; | ||
/** | ||
* Get click location statistics for tracked links for messages sent from the Server associated with this Client. | ||
* (Shows whether a tracked link was clicked from "HTML" or "Text" body of the email) | ||
* | ||
* @memberof Client.prototype | ||
* @method getClickLocation | ||
* @param {object} [filter] Optional filtering parameters. | ||
* @param {PostmarkCallback} callback A standard callback that is called when the API request completes. | ||
*/ | ||
Client.prototype.getClickLocation = function(filter, callback) { | ||
callback = coalesceCallback(filter, callback); | ||
this.processRequestWithoutBody('/stats/outbound/clicks/location', 'GET', filter, callback); | ||
}; | ||
/** | ||
* Create a new Tag Trigger. | ||
@@ -650,2 +701,2 @@ * | ||
module.exports = Client; | ||
})(); | ||
})(); |
@@ -35,2 +35,3 @@ // The following docs support type definitions, without the need to actually create these types. | ||
* @property {boolean} [TrackOpens] Should a tracking image be included on HTML emails to track statistics? | ||
* @property {string} [TrackLinks] Should a link tracking be enabled for this message? (Possible values: 'HtmlOnly', 'TextOnly', 'HtmlAndText', 'None', and null) | ||
* @property {PostmarkMessageHeader[]} Headers The headers to apply when sending this message. | ||
@@ -54,2 +55,3 @@ * @property {PostmarkAttachment[]} Attachments Any attachments that should be included when sending the email. | ||
* @property {boolean} [TrackOpens] Should a tracking image be included on HTML emails to track statistics? | ||
* @property {string} [TrackLinks] Should a link tracking be enabled for this message? (Possible values: 'HtmlOnly', 'TextOnly', 'HtmlAndText', 'None', and null) | ||
* @property {PostmarkMessageHeader[]} [Headers] The headers to apply when sending this message. | ||
@@ -56,0 +58,0 @@ * @property {PostmarkAttachment[]} [Attachments] Any attachments that should be included when sending the email. |
@@ -9,3 +9,3 @@ { | ||
], | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"author": "Chris Williams <voodootikigod@gmail.com>", | ||
@@ -21,2 +21,3 @@ "contributors": [ | ||
"Chris Williams", | ||
"Jake Huggart", | ||
"Jakub Borys", | ||
@@ -23,0 +24,0 @@ "Mark Nguyen", |
@@ -17,3 +17,3 @@ ## Postmark.js | ||
### Sending an Email: | ||
### Sending an Email | ||
@@ -52,2 +52,3 @@ To send your first email, all you need to do is: | ||
var client = new postmark.Client("<server key>"); | ||
var fs = require('fs'); | ||
@@ -60,7 +61,8 @@ client.sendEmail({ | ||
"Attachments": [{ | ||
"Content": File.readFileSync("./unicorns.jpg").toString('base64'), | ||
// Reading synchronously here to condense code snippet: | ||
"Content": fs.readFileSync("./unicorns.jpg").toString('base64'), | ||
"Name": "PrettyUnicorn.jpg", | ||
"ContentType": "image/jpeg" | ||
}] | ||
}, function(error, success) { | ||
}, function(error, result) { | ||
if(error) { | ||
@@ -109,1 +111,35 @@ console.error("Unable to send via postmark: " + error.message); | ||
The Postmark API will return an array of statuses, one for each message sent. You may iterate over the `batchResults` for information about each sent message. For further details, please see the [Postmark Batch API](http://developer.postmarkapp.com/developer-build.html#batching-messages). | ||
### Sending an Email using a Template | ||
The process of sending an email using a template in Postmark is similar to sending a single email, but there is a little bit of setup. | ||
If you have not already created a template, login to the [Postmark UI](https://postmarkapp.com), navigate to one of your `Server`s, and add a template. Make note of the `TemplateId`, you will use that below. (You can also use our Template API to manage templates, if you wish to do so). | ||
After you have created/selected a template to use, there are minor differences in the request payload for sending with a template.. | ||
First, you need to include the `TemplateId`, and `TemplateModel` (the values that you want to use in your template), | ||
Next, *exclude* the `Subject`, `TextBody`, and `HtmlBody` properties that you'd normally include when sending a non-templated email. | ||
That's it! You're ready to send using a template stored with Postmark. | ||
The following is a snippet showing a complete email with template request: | ||
```javascript | ||
var postmark = require("postmark"); | ||
var client = new postmark.Client("<server key>"); | ||
client.sendEmailWithTemplate({ | ||
"From": "donotreply@example.com", | ||
"TemplateId": <templateId>, | ||
"To": "target@example.us", | ||
"TemplateModel": { | ||
"Property1" : 1, | ||
"Property2" : "hello" | ||
} | ||
}); | ||
``` | ||
As with all other Postmark client calls, you can include an optional callback function, allowing you to handle any errors, and to examine the API response. | ||
*Happy Sending!* |
@@ -5,3 +5,3 @@ var mocha = require('mocha'); | ||
var testingKeys = nconf.env().file({ | ||
file: __dirname + '/testing_keys.json' | ||
file: __dirname + '/../testing_keys.json' | ||
}); | ||
@@ -8,0 +8,0 @@ var util = require('util'); |
@@ -5,3 +5,3 @@ var mocha = require('mocha'); | ||
var testingKeys = nconf.env().file({ | ||
file: __dirname + '/testing_keys.json' | ||
file: __dirname + '/../testing_keys.json' | ||
}); | ||
@@ -8,0 +8,0 @@ var util = require('util'); |
@@ -5,3 +5,3 @@ var mocha = require('mocha'); | ||
var testingKeys = nconf.env().file({ | ||
file: __dirname + '/testing_keys.json' | ||
file: __dirname + '/../testing_keys.json' | ||
}); | ||
@@ -18,3 +18,3 @@ var util = require('util'); | ||
beforeEach(function() { | ||
_client = new postmark.Client(testingKeys.get('WRITE_TEST_SERVER_TOKEN')); | ||
_client = new postmark.Client(testingKeys.get('READ_SELENIUM_TEST_SERVER_TOKEN')); | ||
}); | ||
@@ -21,0 +21,0 @@ |
@@ -5,3 +5,3 @@ var mocha = require('mocha'); | ||
var testingKeys = nconf.env().file({ | ||
file: __dirname + '/testing_keys.json' | ||
file: __dirname + '/../testing_keys.json' | ||
}); | ||
@@ -17,3 +17,3 @@ var util = require('util'); | ||
it('can search outbound message', function(done) { | ||
var client = new postmark.Client(testingKeys.get('WRITE_TEST_SERVER_TOKEN')); | ||
var client = new postmark.Client(testingKeys.get('READ_SELENIUM_TEST_SERVER_TOKEN')); | ||
client.getOutboundMessages({ | ||
@@ -25,3 +25,3 @@ count: 1 | ||
it('can get outbound message details', function(done) { | ||
var client = new postmark.Client(testingKeys.get('WRITE_TEST_SERVER_TOKEN')); | ||
var client = new postmark.Client(testingKeys.get('READ_SELENIUM_TEST_SERVER_TOKEN')); | ||
client.getOutboundMessages({ | ||
@@ -28,0 +28,0 @@ count: 1 |
@@ -5,3 +5,3 @@ var mocha = require('mocha'); | ||
var testingKeys = nconf.env().file({ | ||
file: __dirname + '/testing_keys.json' | ||
file: __dirname + '/../testing_keys.json' | ||
}); | ||
@@ -19,3 +19,3 @@ var util = require('util'); | ||
beforeEach(function() { | ||
_client = new postmark.Client(testingKeys.get('WRITE_TEST_SERVER_TOKEN')); | ||
_client = new postmark.Client(testingKeys.get('READ_SELENIUM_TEST_SERVER_TOKEN')); | ||
}); | ||
@@ -65,2 +65,6 @@ | ||
it('can get bounce counts', function(done) { | ||
_client.getMessageOpens(done); | ||
}); | ||
it('can get message opens for single message', function(done) { | ||
@@ -67,0 +71,0 @@ _client.getMessageOpens({ |
@@ -5,3 +5,3 @@ var mocha = require('mocha'); | ||
var testingKeys = nconf.env().file({ | ||
file: __dirname + '/testing_keys.json' | ||
file: __dirname + '/../testing_keys.json' | ||
}); | ||
@@ -26,3 +26,3 @@ var util = require('util'); | ||
it("should edit current server", function() { | ||
var newName = "test-server" + (new Date()).toISOString() | ||
var newName = "node-js-base-test-server" + (new Date()).toISOString() | ||
_client.editServer({ | ||
@@ -34,2 +34,3 @@ Name: newName | ||
assert.equal(server.Name, newName); | ||
}); | ||
@@ -36,0 +37,0 @@ }); |
@@ -5,3 +5,3 @@ var mocha = require('mocha'); | ||
var testingKeys = nconf.env().file({ | ||
file: __dirname + '/testing_keys.json' | ||
file: __dirname + '/../testing_keys.json' | ||
}); | ||
@@ -8,0 +8,0 @@ var util = require('util'); |
@@ -5,3 +5,3 @@ var mocha = require('mocha'); | ||
var testingKeys = nconf.env().file({ | ||
file: __dirname + '/testing_keys.json' | ||
file: __dirname + '/../testing_keys.json' | ||
}); | ||
@@ -8,0 +8,0 @@ var util = require('util'); |
@@ -5,3 +5,3 @@ var mocha = require('mocha'); | ||
var testingKeys = nconf.env().file({ | ||
file: __dirname + '/testing_keys.json' | ||
file: __dirname + '/../testing_keys.json' | ||
}); | ||
@@ -8,0 +8,0 @@ var util = require('util'); |
@@ -5,3 +5,3 @@ var mocha = require('mocha'); | ||
var testingKeys = nconf.env().file({ | ||
file: __dirname + '/testing_keys.json' | ||
file: __dirname + '/../testing_keys.json' | ||
}); | ||
@@ -8,0 +8,0 @@ var util = require('util'); |
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
Sorry, the diff of this file is not supported yet
3455699
68
124474
142