Comparing version 1.3.4 to 1.3.5
@@ -1,10 +0,17 @@ | ||
## Change Log | ||
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
### v1.3.4 (2016/05/10) | ||
## [Unreleased][unreleased] | ||
## [1.3.5] - 2016-05-13 | ||
- [#146](https://github.com/SparkPost/node-sparkpost/pull/146) Single recipient suppression list upserts now use the bulk update endpoint (@jgzamora) | ||
## [1.3.4] - 2016-05-10 | ||
- [#144](https://github.com/SparkPost/node-sparkpost/pull/144) Updated bulk suppression list upsert payload (@aydrian) | ||
### v1.3.3 (2016/04/25) | ||
## [1.3.3] - 2016-04-25 | ||
- [#142](https://github.com/SparkPost/node-sparkpost/pull/142) Upgrade request to 2.72.0 and fix affected test (@artlogic) | ||
### v1.3.2 (2016/04/13) | ||
## [1.3.2] - 2016-04-13 | ||
- [#139](https://github.com/SparkPost/node-sparkpost/pull/139) Make Gruntfile.js cross-platform friendly (@coldacid) | ||
@@ -15,6 +22,6 @@ - [#137](https://github.com/SparkPost/node-sparkpost/pull/137) Fix missing `subaccounts` property in SparkPost class (@coldacid) | ||
### v1.3.1 (2016/04/01) | ||
## [1.3.1] - 2016-04-01 | ||
- [#130](https://github.com/SparkPost/node-sparkpost/pull/130) Refactored toApiFormat.js to use json-pointer (@orval) | ||
### v1.3.0 (2016/04/01) | ||
## [1.3.0] - 2016-04-01 | ||
- [#129](https://github.com/SparkPost/node-sparkpost/pull/129) Added support for subaccounts (@coldacid) | ||
@@ -27,3 +34,3 @@ - [#126](https://github.com/SparkPost/node-sparkpost/pull/126) body might be undefined (@mstdokumaci) | ||
### v1.2.0 (2016/03/14) | ||
## [1.2.0] - 2016-03-14 | ||
- [#109](https://github.com/SparkPost/node-sparkpost/pull/109) README updates (@aydrian) | ||
@@ -37,3 +44,3 @@ - [#108](https://github.com/SparkPost/node-sparkpost/pull/108) removes from and subject from transmission stored template send example (@colestrode) | ||
### v1.1.0 (2015/08/13) | ||
## [1.1.0] - 2015-08-13 | ||
- [#92](https://github.com/SparkPost/node-sparkpost/pull/92) Added Coveralls.io (@aydrian) | ||
@@ -43,3 +50,3 @@ - [#91](https://github.com/SparkPost/node-sparkpost/pull/91) Added Recipient List Update method, Docs, and Examples (@aydrian) | ||
### v1.0.1 (2015/08/06) | ||
## [1.0.1] - 2015-08-06 | ||
- [#88](https://github.com/SparkPost/node-sparkpost/pull/88) Modified toApiFormat spec test file to fit standard naming convention. Added tests for code coverage. (@aydrian) | ||
@@ -52,3 +59,3 @@ - [#87](https://github.com/SparkPost/node-sparkpost/pull/87) Removed dependency for snake-case (@aydrian) | ||
### v1.0.0 (2015/06/06) - *breaking* | ||
## [1.0.0] - 2015-06-06 - *breaking* | ||
- [#68](https://github.com/SparkPost/node-sparkpost/pull/68) Added keywords for searching in npm (@nornholdj) | ||
@@ -68,3 +75,3 @@ - [#67](https://github.com/SparkPost/node-sparkpost/pull/67) Created a change log as CHANGELOG.md (@aydrian) | ||
### v0.9.0 (2015/05/12) - *breaking* | ||
## [0.9.0] - 2015-05-12 - *breaking* | ||
- [#49](https://github.com/SparkPost/node-sparkpost/pull/49) Issue [#48](https://github.com/SparkPost/node-sparkpost/issues/48) Add Grunt Bump (@aydrian) | ||
@@ -82,21 +89,40 @@ - [#47](https://github.com/SparkPost/node-sparkpost/pull/47) Issue [#44](https://github.com/SparkPost/node-sparkpost/issues/44) Create docs and examples for new APIs (@aydrian) | ||
### v0.1.6 (2015/04/16) | ||
## [0.1.6] - 2015-04-16 | ||
- [#26](https://github.com/SparkPost/node-sparkpost/pull/26) removed defaulting open/click tracking to true (@jmartin4563) | ||
### v0.1.5 (2015/04/02) | ||
## [0.1.5] - 2015-04-02 | ||
- [#22](https://github.com/SparkPost/node-sparkpost/pull/22) Apply fix for [#21](https://github.com/SparkPost/node-sparkpost/issues/21) and add appropriate unit test / update mock (@jmartin4563) | ||
### v0.1.4 (2015/02/24) | ||
## [0.1.4] - 2015-02-24 | ||
- Sending Domains Functionality and Transmissions Sandbox Option | ||
### v0.1.3 (2015/01/08) | ||
## [0.1.3] - 2015-01-08 | ||
- Open & Click Tracking Disabling Bug Fix | ||
### v0.1.2 (2014/12/10) | ||
## [0.1.2] - 2014-12-10 | ||
- Added SendGrid compatibility layer | ||
### v0.1.1 (2014/12/10) | ||
## [0.1.1] - 2014-12-10 | ||
- Added SendGrid compatibility layer | ||
### v0.1.0 (2014/11/10) | ||
## 0.1.0 - 2014-11-10 | ||
- First Release! | ||
[unreleased]: https://github.com/sparkpost/node-sparkpost/compare/1.3.5...HEAD | ||
[1.3.5]: https://github.com/sparkpost/node-sparkpost/compare/1.3.4...1.3.5 | ||
[1.3.4]: https://github.com/sparkpost/node-sparkpost/compare/1.3.3...1.3.4 | ||
[1.3.3]: https://github.com/sparkpost/node-sparkpost/compare/1.3.2...1.3.3 | ||
[1.3.2]: https://github.com/sparkpost/node-sparkpost/compare/1.3.1...1.3.2 | ||
[1.3.1]: https://github.com/sparkpost/node-sparkpost/compare/1.3.0...1.3.1 | ||
[1.3.0]: https://github.com/sparkpost/node-sparkpost/compare/1.2.0...1.3.0 | ||
[1.2.0]: https://github.com/sparkpost/node-sparkpost/compare/1.1.0...1.2.0 | ||
[1.1.0]: https://github.com/sparkpost/node-sparkpost/compare/1.0.1...1.1.0 | ||
[1.0.1]: https://github.com/sparkpost/node-sparkpost/compare/1.0.0...1.0.1 | ||
[1.0.0]: https://github.com/sparkpost/node-sparkpost/compare/0.9.0...1.0.0 | ||
[0.9.0]: https://github.com/sparkpost/node-sparkpost/compare/0.1.6...0.9.0 | ||
[0.1.6]: https://github.com/sparkpost/node-sparkpost/compare/0.1.5...0.1.6 | ||
[0.1.5]: https://github.com/sparkpost/node-sparkpost/compare/0.1.4...0.1.5 | ||
[0.1.4]: https://github.com/sparkpost/node-sparkpost/compare/0.1.3...0.1.4 | ||
[0.1.3]: https://github.com/sparkpost/node-sparkpost/compare/0.1.2...0.1.3 | ||
[0.1.2]: https://github.com/sparkpost/node-sparkpost/compare/0.1.1...0.1.2 | ||
[0.1.1]: https://github.com/sparkpost/node-sparkpost/compare/0.1.0...0.1.1 |
@@ -6,10 +6,24 @@ 'use strict'; | ||
, client = new SparkPost(key) | ||
, recipient = { | ||
email: 'test@test.com' | ||
, transactional: false | ||
, non_transactional: true | ||
, description: 'Test description' | ||
}; | ||
, recipients = [ | ||
{ | ||
email: 'test1@test.com' | ||
, transactional: false | ||
, non_transactional: true | ||
, description: 'Test description 1' | ||
}, | ||
{ | ||
email: 'test2@test.com' | ||
, transactional: true | ||
, non_transactional: true | ||
, description: 'Test description 2' | ||
}, | ||
{ | ||
email: 'test3@test.com' | ||
, transactional: true | ||
, non_transactional: false | ||
, description: 'Test description 3' | ||
} | ||
]; | ||
client.suppressionList.upsert(recipient, function(err, res) { | ||
client.suppressionList.upsert(recipients, function(err, res) { | ||
if (err) { | ||
@@ -16,0 +30,0 @@ console.log(err); |
@@ -48,9 +48,11 @@ 'use strict'; | ||
}, | ||
upsert: function(recipient, callback) { | ||
if(typeof recipient === 'function') { | ||
callback = recipient; | ||
recipient = null; | ||
upsert: function(recipients, callback) { | ||
var options; | ||
if(typeof recipients === 'function') { | ||
callback = recipients; | ||
recipients = null; | ||
} | ||
if(!recipient) { | ||
if(!recipients) { | ||
callback(new Error('recipient is required')); | ||
@@ -60,16 +62,12 @@ return; | ||
var options = { | ||
uri: api + '/' + recipient.email | ||
, json: recipient | ||
if(!Array.isArray(recipients)) { | ||
recipients = [recipients]; | ||
} | ||
recipients = toApiFormat(recipients); | ||
options = { | ||
uri: api, | ||
json: { recipients: recipients } | ||
}; | ||
// Check for bulk upsert | ||
if(recipient.constructor === Array) { | ||
options.uri = api; | ||
options.json = { recipients: toApiFormat(recipient) }; | ||
} else if(!recipient.email) { | ||
callback(new Error('email is required in the recipient object')); | ||
return; | ||
} | ||
client.put(options, callback); | ||
@@ -76,0 +74,0 @@ } |
{ | ||
"name": "sparkpost", | ||
"version": "1.3.4", | ||
"version": "1.3.5", | ||
"description": "A Node.js wrapper for interfacing with your favorite SparkPost APIs", | ||
@@ -5,0 +5,0 @@ "main": "./lib/sparkpost.js", |
@@ -82,13 +82,6 @@ var chai = require('chai') | ||
describe('upsert Method', function() { | ||
it('should call client put method with the appropriate uri', function(done) { | ||
suppressionList.upsert({email: 'test@test.com'}, function(err, data) { | ||
expect(client.put.firstCall.args[0].uri).to.equal('suppression-list/test@test.com'); | ||
done(); | ||
}); | ||
}); | ||
it('should accept an array of recipients for bulk upsert', function(done) { | ||
it('should accept an array of recipients', function(done) { | ||
var recipients = [ | ||
{email: 'test1@test.com'} | ||
, {email: 'test2@test.com'} | ||
{ email: 'test1@test.com' }, | ||
{ email: 'test2@test.com' } | ||
]; | ||
@@ -98,2 +91,3 @@ | ||
expect(client.put.firstCall.args[0].uri).to.equal('suppression-list'); | ||
expect(client.put.firstCall.args[0].json.recipients).to.deep.equal(recipients); | ||
done(); | ||
@@ -119,6 +113,6 @@ }); | ||
it('should throw an error if email is missing on recipient object', function(done) { | ||
suppressionList.upsert({name: 'test'}, function(err, data) { | ||
expect(err.message).to.equal('email is required in the recipient object'); | ||
expect(client.put).not.to.have.been.called; | ||
it('should upsert a single recipient as an array', function(done) { | ||
var recipient = { email: 'test1@test.com' }; | ||
suppressionList.upsert(recipient, function(err, data) { | ||
expect(client.put.firstCall.args[0].json.recipients).to.deep.equal([recipient]); | ||
done(); | ||
@@ -125,0 +119,0 @@ }); |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
220864
114
4436
1