neverbounce
Advanced tools
Comparing version 4.2.3 to 4.3.0
{ | ||
"name": "neverbounce", | ||
"version": "4.2.3", | ||
"version": "4.3.0", | ||
"description": "An API wrapper for the NeverBounce API", | ||
@@ -5,0 +5,0 @@ "engines": { |
@@ -15,3 +15,3 @@ 'use strict'; | ||
method: 'GET', | ||
path: '/v4/account/info' | ||
path: 'account/info' | ||
}).then( | ||
@@ -24,2 +24,2 @@ (resp) => Promise.resolve(resp), | ||
module.exports = Account; | ||
module.exports = Account; |
@@ -23,4 +23,5 @@ 'use strict'; | ||
return new Promise((resolve, reject) => { | ||
const config = this._nb.getConfig() | ||
// Set key | ||
data.key = this._nb.getConfig().apiKey; | ||
data.key = config.apiKey; | ||
@@ -32,2 +33,5 @@ // Encode params | ||
const opts = this._nb.getRequestOpts(params); | ||
if(opts.path) { | ||
opts.path = `/${config.apiVersion}/${opts.path}`; | ||
} | ||
opts.headers['User-Agent'] = 'NeverBounceApi-NodeJS/' + _Version; | ||
@@ -83,4 +87,4 @@ opts.headers['Content-Length'] = Buffer.byteLength(query); | ||
// Handle timeout | ||
if (this._nb.getConfig().timeout) { | ||
req.setTimeout(this._nb.getConfig().timeout, () => { | ||
if (config.timeout) { | ||
req.setTimeout(config.timeout, () => { | ||
req.destroy(); | ||
@@ -192,2 +196,2 @@ }); | ||
module.exports = HttpsClient; | ||
module.exports = HttpsClient; |
@@ -15,3 +15,3 @@ 'use strict'; | ||
method: 'GET', | ||
path: '/v4/jobs/search' | ||
path: 'jobs/search' | ||
}, query || {}).then( | ||
@@ -31,9 +31,7 @@ (resp) => Promise.resolve(resp), | ||
* @param autostart | ||
* @param historicalData | ||
* @returns {Promise.<*>} | ||
*/ | ||
create(input, inputlocation, filename, runsample, autoparse, autostart) { | ||
return this.request({ | ||
method: 'POST', | ||
path: '/v4/jobs/create' | ||
}, { | ||
create(input, inputlocation, filename, runsample, autoparse, autostart, historicalData) { | ||
const data = { | ||
'input': input, | ||
@@ -45,3 +43,12 @@ 'input_location': inputlocation, | ||
'auto_parse': autoparse || null, | ||
}).then( | ||
}; | ||
if(historicalData !== undefined) { | ||
data.request_meta_data = { leverage_historical_data: historicalData ? 1 : 0 }; | ||
} | ||
return this.request({ | ||
method: 'POST', | ||
path: 'jobs/create' | ||
}, data).then( | ||
(resp) => Promise.resolve(resp), | ||
@@ -61,3 +68,3 @@ (e) => Promise.reject(e) | ||
method: 'POST', | ||
path: '/v4/jobs/parse' | ||
path: 'jobs/parse' | ||
}, { | ||
@@ -81,3 +88,3 @@ 'job_id': jobid, | ||
method: 'POST', | ||
path: '/v4/jobs/start' | ||
path: 'jobs/start' | ||
}, { | ||
@@ -100,3 +107,3 @@ 'job_id': jobid, | ||
method: 'GET', | ||
path: '/v4/jobs/status' | ||
path: 'jobs/status' | ||
}, { | ||
@@ -119,3 +126,3 @@ 'job_id': jobid, | ||
method: 'GET', | ||
path: '/v4/jobs/results' | ||
path: 'jobs/results' | ||
}, | ||
@@ -139,3 +146,3 @@ Object.assign({'job_id': jobid}, query || {}) | ||
method: 'GET', | ||
path: '/v4/jobs/download' | ||
path: 'jobs/download' | ||
}, | ||
@@ -157,3 +164,3 @@ Object.assign({'job_id': jobid}, query || {}) | ||
method: 'POST', | ||
path: '/v4/jobs/delete' | ||
path: 'jobs/delete' | ||
}, { | ||
@@ -192,2 +199,2 @@ 'job_id': jobid, | ||
module.exports = Jobs; | ||
module.exports = Jobs; |
@@ -61,2 +61,9 @@ 'use strict'; | ||
/** | ||
* @param version | ||
*/ | ||
setApiVersion(version) { | ||
this.config.apiVersion = version; | ||
} | ||
/** | ||
* Loads resources (endpoints) into object | ||
@@ -79,2 +86,3 @@ * e.g. this.single && this.jobs | ||
NeverBounce.defaultConfig = { | ||
apiVersion: 'v4', | ||
apiKey: null, | ||
@@ -111,2 +119,2 @@ timeout: 30000, | ||
module.exports = NeverBounce; | ||
module.exports = NeverBounce; |
@@ -18,3 +18,3 @@ 'use strict'; | ||
method: 'POST', | ||
path: '/v4/poe/confirm' | ||
path: 'poe/confirm' | ||
}, { | ||
@@ -32,2 +32,2 @@ 'email': email, | ||
module.exports = POE; | ||
module.exports = POE; |
@@ -14,9 +14,7 @@ 'use strict'; | ||
* @param timeout | ||
* @param historicalData | ||
* @returns {Promise} | ||
*/ | ||
check(email, address_info, credits_info, timeout) { | ||
return this.request({ | ||
method: 'GET', | ||
path: '/v4/single/check' | ||
}, { | ||
check(email, address_info, credits_info, timeout, historicalData) { | ||
const data = { | ||
email: email, | ||
@@ -26,3 +24,12 @@ address_info: address_info || null, | ||
timeout: timeout || null | ||
}).then( | ||
}; | ||
if(historicalData !== undefined) { | ||
data.request_meta_data = { leverage_historical_data: historicalData ? 1 : 0 }; | ||
} | ||
return this.request({ | ||
method: 'GET', | ||
path: 'single/check' | ||
}, data).then( | ||
(resp) => Promise.resolve(new VerificationObject(resp)), | ||
@@ -34,2 +41,2 @@ (e) => Promise.reject(e) | ||
module.exports = Single; | ||
module.exports = Single; |
@@ -24,3 +24,3 @@ const chai = require('chai'), | ||
return http.request({path: '/v4/test'}).should.be.fulfilled | ||
return http.request({path: 'test'}).should.be.fulfilled | ||
.then( | ||
@@ -36,3 +36,3 @@ resp => resp.should.be.an('object').that.have.property('status') | ||
return http.request({path: '/v4/test', acceptedType: 'text/plain'}).should.be.fulfilled | ||
return http.request({path: 'test', acceptedType: 'text/plain'}).should.be.fulfilled | ||
.then( | ||
@@ -48,3 +48,3 @@ resp => resp.should.be.a('string').that.is.equal('Hello World!') | ||
return http.request({path: '/v4/test'}).should.be.rejected | ||
return http.request({path: 'test'}).should.be.rejected | ||
.then( | ||
@@ -60,3 +60,3 @@ err => err.should.contain({'type': NeverBounce.errors.GeneralError}) | ||
return http.request({path: '/v4/test'}).should.be.rejected | ||
return http.request({path: 'test'}).should.be.rejected | ||
.then( | ||
@@ -72,3 +72,3 @@ err => err.should.contain({'type': NeverBounce.errors.GeneralError}) | ||
return http.request({path: '/v4/test'}).should.be.rejected | ||
return http.request({path: 'test'}).should.be.rejected | ||
.then( | ||
@@ -84,3 +84,3 @@ err => err.should.contain({'type': NeverBounce.errors.GeneralError}) | ||
return http.request({path: '/v4/test'}).should.be.rejected | ||
return http.request({path: 'test'}).should.be.rejected | ||
.then( | ||
@@ -96,3 +96,3 @@ err => err.should.contain({'type': NeverBounce.errors.GeneralError}) | ||
return http.request({path: '/v4/test'}).should.be.rejected | ||
return http.request({path: 'test'}).should.be.rejected | ||
.then( | ||
@@ -108,3 +108,3 @@ err => err.should.contain({'type': NeverBounce.errors.AuthError}) | ||
return http.request({path: '/v4/test'}).should.be.rejected | ||
return http.request({path: 'test'}).should.be.rejected | ||
.then( | ||
@@ -120,3 +120,3 @@ err => err.should.contain({'type': NeverBounce.errors.GeneralError}) | ||
return http.request({path: '/v4/test'}).should.be.rejected | ||
return http.request({path: 'test'}).should.be.rejected | ||
.then( | ||
@@ -132,3 +132,3 @@ err => err.should.contain({'type': NeverBounce.errors.ThrottleError}) | ||
return http.request({path: '/v4/test'}).should.be.rejected | ||
return http.request({path: 'test'}).should.be.rejected | ||
.then( | ||
@@ -144,3 +144,3 @@ err => err.should.contain({'type': NeverBounce.errors.BadReferrerError}) | ||
return http.request({path: '/v4/test'}).should.be.rejected | ||
return http.request({path: 'test'}).should.be.rejected | ||
.then( | ||
@@ -150,2 +150,2 @@ err => err.should.contain({'type': NeverBounce.errors.GeneralError}) | ||
}); | ||
}); | ||
}); |
@@ -14,2 +14,3 @@ const assert = require('chai').assert, | ||
apiKey: 'xxx', | ||
apiVersion: 'v4', | ||
timeout: 100, | ||
@@ -23,2 +24,3 @@ opts: { | ||
assert.equal(nb0.getConfig().apiKey, 'xxx'); | ||
assert.equal(nb0.getConfig().apiVersion, 'v4'); | ||
assert.deepEqual(nb0.getConfig().opts, { | ||
@@ -52,2 +54,7 @@ acceptedType: 'application/json', | ||
}); | ||
it('should be able to set API version after initialization', function () { | ||
nb0.setApiVersion('v4'); | ||
assert.equal(nb0.getConfig().apiVersion, 'v4'); | ||
}); | ||
}); | ||
@@ -163,2 +170,2 @@ | ||
}); | ||
}); | ||
}); |
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
64130
1513
1