@indigov/sparkpost
Advanced tools
Comparing version 2.1.7 to 2.1.8
@@ -16,2 +16,8 @@ 'use strict' | ||
list: function (subAccountOptions, callback) { | ||
// Handle optional subAccountOptions argument | ||
if (typeof subAccountOptions === 'function') { | ||
callback = subAccountOptions | ||
subAccountOptions = {} | ||
} | ||
const options = { | ||
@@ -33,2 +39,8 @@ uri: api, | ||
get: function (domain, subAccountOptions, callback) { | ||
// Handle optional subAccountOptions argument | ||
if (typeof subAccountOptions === 'function') { | ||
callback = subAccountOptions | ||
subAccountOptions = {} | ||
} | ||
if (!domain || typeof domain === 'function') { | ||
@@ -54,2 +66,8 @@ return client.reject(new Error('domain is required'), callback) | ||
create: function (createOpts, subAccountOptions, callback) { | ||
// Handle optional subAccountOptions argument | ||
if (typeof subAccountOptions === 'function') { | ||
callback = subAccountOptions | ||
subAccountOptions = {} | ||
} | ||
if (!createOpts || typeof createOpts !== 'object') { | ||
@@ -77,2 +95,8 @@ return client.reject(new Error('create options are required'), callback) | ||
update: function (domain, updateOpts, subAccountOptions, callback) { | ||
// Handle optional subAccountOptions argument | ||
if (typeof subAccountOptions === 'function') { | ||
callback = subAccountOptions | ||
subAccountOptions = {} | ||
} | ||
if (typeof domain !== 'string') { | ||
@@ -103,2 +127,8 @@ return client.reject(new Error('domain is required'), callback) | ||
delete: function (domain, subAccountOptions, callback) { | ||
// Handle optional subAccountOptions argument | ||
if (typeof subAccountOptions === 'function') { | ||
callback = subAccountOptions | ||
subAccountOptions = {} | ||
} | ||
if (typeof domain !== 'string') { | ||
@@ -125,2 +155,8 @@ return client.reject(new Error('domain is required'), callback) | ||
verify: function (domain, options, subAccountOptions, callback) { | ||
// Handle optional subAccountOptions argument | ||
if (typeof subAccountOptions === 'function') { | ||
callback = subAccountOptions | ||
subAccountOptions = {} | ||
} | ||
if (typeof domain !== 'string') { | ||
@@ -127,0 +163,0 @@ return client.reject(new Error('domain is required'), callback) |
@@ -5,2 +5,3 @@ 'use strict' | ||
const api = 'transmissions' | ||
const subAccountOptionsToHeaders = require('./subAccountOptionsToHeaders') | ||
@@ -21,3 +22,3 @@ /* | ||
*/ | ||
list: function (options, callback) { | ||
list: function (options, subAccountOptions, callback) { | ||
// Handle optional options argument | ||
@@ -29,5 +30,12 @@ if (typeof options === 'function') { | ||
// Handle optional subAccountOptions argument | ||
if (typeof subAccountOptions === 'function') { | ||
callback = subAccountOptions | ||
subAccountOptions = {} | ||
} | ||
const reqOpts = { | ||
uri: api, | ||
qs: options | ||
qs: options, | ||
headers: subAccountOptionsToHeaders(subAccountOptions) | ||
} | ||
@@ -44,3 +52,9 @@ | ||
*/ | ||
get: function (id, callback) { | ||
get: function (id, subAccountOptions, callback) { | ||
// Handle optional subAccountOptions argument | ||
if (typeof subAccountOptions === 'function') { | ||
callback = subAccountOptions | ||
subAccountOptions = {} | ||
} | ||
if (typeof id !== 'string') { | ||
@@ -51,3 +65,4 @@ return client.reject(new Error('id is required'), callback) | ||
const options = { | ||
uri: `${api}/${id}` | ||
uri: `${api}/${id}`, | ||
headers: subAccountOptionsToHeaders(subAccountOptions) | ||
} | ||
@@ -65,3 +80,3 @@ | ||
*/ | ||
send: function (transmission, options, callback) { | ||
send: function (transmission, options, subAccountOptions, callback) { | ||
// Handle optional options argument | ||
@@ -73,2 +88,8 @@ if (typeof options === 'function') { | ||
// Handle optional subAccountOptions argument | ||
if (typeof subAccountOptions === 'function') { | ||
callback = subAccountOptions | ||
subAccountOptions = {} | ||
} | ||
if (!transmission || typeof transmission !== 'object') { | ||
@@ -83,3 +104,4 @@ return client.reject(new Error('transmission object is required'), callback) | ||
json: transmission, | ||
qs: options | ||
qs: options, | ||
headers: subAccountOptionsToHeaders(subAccountOptions) | ||
} | ||
@@ -86,0 +108,0 @@ |
{ | ||
"name": "@indigov/sparkpost", | ||
"version": "2.1.7", | ||
"version": "2.1.8", | ||
"description": "A Node.js wrapper for interfacing with your favorite SparkPost APIs", | ||
@@ -5,0 +5,0 @@ "main": "./lib/sparkpost.js", |
@@ -86,3 +86,3 @@ 'use strict' | ||
describe('Transmissions Library', function () { | ||
var client, transmissions, callback | ||
var client, transmissions, subAccountOptions, callback | ||
@@ -96,2 +96,4 @@ beforeEach(function () { | ||
subAccountOptions = {} | ||
callback = function () {} | ||
@@ -106,2 +108,3 @@ | ||
expect(client.get.firstCall.args[0].uri).to.equal('transmissions') | ||
expect(client.get.firstCall.args[0].headers).to.deep.equal({}) | ||
expect(client.get.firstCall.args[1]).to.equal(callback) | ||
@@ -134,4 +137,4 @@ }) | ||
it('should call client get method with the appropriate uri', function () { | ||
return transmissions.get('test', callback).then(function () { | ||
expect(client.get.firstCall.args[0]).to.deep.equal({ uri: 'transmissions/test' }) | ||
return transmissions.get('test', {}, callback).then(function () { | ||
expect(client.get.firstCall.args[0]).to.deep.equal({ uri: 'transmissions/test', headers: {} }) | ||
expect(client.get.firstCall.args[1]).to.equal(callback) | ||
@@ -155,2 +158,3 @@ }) | ||
expect(client.post.firstCall.args[0].json).to.deep.equal(transmission) | ||
expect(client.post.firstCall.args[0].headers).to.deep.equal({}) | ||
expect(client.post.firstCall.args[1]).to.equal(callback) | ||
@@ -157,0 +161,0 @@ }) |
Sorry, the diff of this file is too big to display
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
322520
6716