neverbounce
Advanced tools
Comparing version 4.1.3 to 4.1.4
@@ -20,3 +20,3 @@ const NeverBounce = require('../src/NeverBounce.js'); | ||
], | ||
'supplied', // Either `supplied` or `remote_url` | ||
NeverBounce.job.inputType.supplied, // Either `supplied` or `remote_url` | ||
'Created from Array.csv' // Friendly name that can be used to identify job | ||
@@ -23,0 +23,0 @@ ).then( |
@@ -10,3 +10,3 @@ const NeverBounce = require('../src/NeverBounce.js'); | ||
// 'filename': 'Book1.csv', // Filter jobs based on filename | ||
// 'job_status': 'complete', // Show completed jobs only | ||
// 'job_status': NeverBounce.job.status.complete, // Show completed jobs only | ||
// 'page': 1, // Page to start from | ||
@@ -13,0 +13,0 @@ // 'items_per_page': 10, // Number of items per page |
@@ -11,2 +11,3 @@ const NeverBounce = require('../src/NeverBounce.js'); | ||
console.log('Result (numeric): ' + result.getNumericResult()); | ||
console.log('Is Valid? ' + result.is(NeverBounce.result.valid)); | ||
console.log('Free Credits Used: ' + result.response.credits_info.free_credits_used); | ||
@@ -13,0 +14,0 @@ console.log('Paid Credits Used: ' + result.response.credits_info.paid_credits_used); |
{ | ||
"name": "neverbounce", | ||
"version": "4.1.3", | ||
"version": "4.1.4", | ||
"description": "An API wrapper for the NeverBounce API", | ||
"engines" : { | ||
"node" : ">=4.0" | ||
}, | ||
"main": "src/NeverBounce.js", | ||
@@ -6,0 +9,0 @@ "repository": { |
@@ -28,2 +28,4 @@ <p align="center"><img src="https://neverbounce-marketing.s3.amazonaws.com/neverbounce_color_600px.png"></p> | ||
>**The API username and secret key used to authenticate V3 API requests will not work to authenticate V4 API requests.** If you are attempting to authenticate your request with the 8 character username or 12-16 character secret key the request will return an `auth_failure` error. The API key used for the V4 API will look like the following: `secret_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`. To create new V4 API credentials please go [here](https://app.neverbounce.com/apps/custom-integration/new). | ||
```js | ||
@@ -38,12 +40,40 @@ const NeverBounce = require('../src/NeverBounce.js'); | ||
result => { | ||
console.log('Result: ' + result.getResult()); | ||
console.log('Result: ' + result.getResult()); // prints: "valid" | ||
// See VerificationObject for additional helper methods for working with | ||
// verification results from the the single method | ||
}, | ||
err => console.log('ERROR: ' + err.message) | ||
err => { | ||
// Errors are returned by the Promise in the form of rejection. To | ||
// gracefully handle errors you can use a switch or if statements to | ||
// catch specific error types. | ||
switch(err.type) { | ||
case NeverBounce.errors.AuthError: | ||
// The API credentials used are bad, have you reset them recently? | ||
break; | ||
case NeverBounce.errors.BadReferrerError: | ||
// The script is being used from an unauthorized source, you may need to | ||
// adjust your app's settings to allow it to be used from here | ||
break; | ||
case NeverBounce.errors.ThrottleError: | ||
// Too many requests in a short amount of time, try again shortly or adjust | ||
// your rate limit settings for this application in the dashboard | ||
break; | ||
case NeverBounce.errors.GeneralError: | ||
// A non recoverable API error occurred check the message for details | ||
break; | ||
default: | ||
// Other non specific errors | ||
break; | ||
} | ||
} | ||
); | ||
``` | ||
>**The API username and secret key used to authenticate V3 API requests will not work to authenticate V4 API requests.** If you are attempting to authenticate your request with the 8 character username or 12-16 character secret key the request will return an `auth_failure` error. The API key used for the V4 API will look like the following: `secret_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`. To create new V4 API credentials please go [here](https://app.neverbounce.com/apps/custom-integration/new). | ||
For more information you can check out the `/examples` directory contained within the repository or visit our official documentation [here](https://developers.neverbounce.com/v4.0/reference). | ||
Constants | ||
--- | ||
The library exposes several constants that make working with jobs, verification results and errors easier. They can be accessed from the root `NeverBounce` object via the `result`, `job`, and `errors` properties. | ||
Running Examples | ||
@@ -50,0 +80,0 @@ --- |
@@ -161,2 +161,23 @@ 'use strict'; | ||
/** | ||
* @since 4.1.4 | ||
*/ | ||
Jobs.helpers = { | ||
inputType: { | ||
remote: Jobs.remote, | ||
supplied: Jobs.supplied | ||
}, | ||
status: { | ||
under_review: 'under_review', | ||
queued: 'queued', | ||
failed: 'failed', | ||
complete: 'complete', | ||
running: 'running', | ||
parsing: 'parsing', | ||
waiting: 'waiting', | ||
waiting_analyzed: 'waiting_analyzed', | ||
uploading: 'uploading' | ||
} | ||
}; | ||
module.exports = Jobs; |
@@ -90,2 +90,20 @@ 'use strict'; | ||
/** | ||
* @since 4.1.4 | ||
* @type {{valid: number, invalid: number, disposable: number, catchall: number, unknown: number, flags: {has_dns: string, has_dns_mx: string, bad_syntax: string, free_email_host: string, profanity: string, role_account: string, disposable_email: string, government_host: string, academic_host: string, military_host: string, international_host: string, squatter_host: string, spelling_mistake: string, bad_dns: string, temporary_dns_error: string, connect_fails: string, accepts_all: string, contains_alias: string, contains_subdomain: string, smtp_connectable: string, spamtrap_network: string}}} | ||
*/ | ||
NeverBounce.result = require('./VerificationObject').helpers; | ||
/** | ||
* @since 4.1.4 | ||
* @type {{inputType: {remote: string, supplied: string}, status: {under_review: string, queued: string, failed: string, complete: string, running: string, parsing: string, waiting: string, waiting_analyzed: string, uploading: string}}} | ||
*/ | ||
NeverBounce.job = require('./Jobs').helpers; | ||
/** | ||
* @since 4.1.4 | ||
* @type {{AuthError: string, BadReferrerError: string, GeneralError: string, ThrottleError: string, _lut: {general_failure: string, auth_failure: string, bad_referrer: string, throttle_triggered: string}}} | ||
*/ | ||
NeverBounce.errors = require('./Errors'); | ||
module.exports = NeverBounce; |
@@ -22,3 +22,3 @@ 'use strict'; | ||
getNumericResult() { | ||
return VerificationObject.numericCodes[this.getResult()]; | ||
return VerificationObject[this.getResult()]; | ||
} | ||
@@ -70,10 +70,57 @@ | ||
/** | ||
* @since 4.1.4 | ||
*/ | ||
VerificationObject.helpers = { | ||
// Numerically indexed | ||
[VerificationObject.valid]: 'valid', | ||
[VerificationObject.invalid]: 'invalid', | ||
[VerificationObject.disposable]: 'disposable', | ||
[VerificationObject.catchall]: 'catchall', | ||
[VerificationObject.unknown]: 'unknown', | ||
// Text indexed | ||
valid: VerificationObject.valid, | ||
invalid: VerificationObject.invalid, | ||
disposable: VerificationObject.disposable, | ||
catchall: VerificationObject.catchall, | ||
unknown: VerificationObject.unknown, | ||
flags: { | ||
has_dns: 'has_dns', | ||
has_dns_mx: 'has_dns_mx', | ||
bad_syntax: 'bad_syntax', | ||
free_email_host: 'free_email_host', | ||
profanity: 'profanity', | ||
role_account: 'role_account', | ||
disposable_email: 'disposable_email', | ||
government_host: 'government_host', | ||
academic_host: 'acedemic_host', // API returns the misspelling, kept for backwards compat | ||
military_host: 'military_host', | ||
international_host: 'international_host', | ||
squatter_host: 'squatter_host', | ||
spelling_mistake: 'spelling_mistake', | ||
bad_dns: 'bad_dns', | ||
temporary_dns_error: 'temporary_dns_error', | ||
connect_fails: 'connect_fails', | ||
accepts_all: 'accepts_all', | ||
contains_alias: 'contains_alias', | ||
contains_subdomain: 'contains_subdomain', | ||
smtp_connectable: 'smtp_connectable', | ||
spamtrap_network: 'spamtrap_network', | ||
} | ||
}; | ||
/** | ||
* @deprecated 4.1.4 Will be removed in next minor release | ||
*/ | ||
VerificationObject.numericCodes = { | ||
'valid': VerificationObject.valid, | ||
'invalid': VerificationObject.invalid, | ||
'disposable': VerificationObject.disposable, | ||
'catchall': VerificationObject.catchall, | ||
'unknown': VerificationObject.unknown, | ||
valid: VerificationObject.valid, | ||
invalid: VerificationObject.invalid, | ||
disposable: VerificationObject.disposable, | ||
catchall: VerificationObject.catchall, | ||
unknown: VerificationObject.unknown, | ||
}; | ||
module.exports = VerificationObject; |
const chai = require('chai'), | ||
chaiAsPromised = require('chai-as-promised'), | ||
nock = require('nock'), | ||
_Errors = require('../src/Errors'), | ||
NeverBounce = require('../src/NeverBounce'); | ||
@@ -6,0 +5,0 @@ |
const chai = require('chai'), | ||
chaiAsPromised = require('chai-as-promised'), | ||
nock = require('nock'), | ||
_Errors = require('../src/Errors'), | ||
NeverBounce = require('../src/NeverBounce'), | ||
@@ -49,3 +48,3 @@ HttpsClient = require('../src/HttpsClient'); | ||
.then( | ||
err => err.should.contain({'type': _Errors.GeneralError}) | ||
err => err.should.contain({'type': NeverBounce.errors.GeneralError}) | ||
) | ||
@@ -61,3 +60,3 @@ }); | ||
.then( | ||
err => err.should.contain({'type': _Errors.GeneralError}) | ||
err => err.should.contain({'type': NeverBounce.errors.GeneralError}) | ||
) | ||
@@ -73,3 +72,3 @@ }); | ||
.then( | ||
err => err.should.contain({'type': _Errors.GeneralError}) | ||
err => err.should.contain({'type': NeverBounce.errors.GeneralError}) | ||
) | ||
@@ -85,3 +84,3 @@ }); | ||
.then( | ||
err => err.should.contain({'type': _Errors.GeneralError}) | ||
err => err.should.contain({'type': NeverBounce.errors.GeneralError}) | ||
) | ||
@@ -97,3 +96,3 @@ }); | ||
.then( | ||
err => err.should.contain({'type': _Errors.AuthError}) | ||
err => err.should.contain({'type': NeverBounce.errors.AuthError}) | ||
) | ||
@@ -109,3 +108,3 @@ }); | ||
.then( | ||
err => err.should.contain({'type': _Errors.GeneralError}) | ||
err => err.should.contain({'type': NeverBounce.errors.GeneralError}) | ||
) | ||
@@ -121,3 +120,3 @@ }); | ||
.then( | ||
err => err.should.contain({'type': _Errors.ThrottleError}) | ||
err => err.should.contain({'type': NeverBounce.errors.ThrottleError}) | ||
) | ||
@@ -133,3 +132,3 @@ }); | ||
.then( | ||
err => err.should.contain({'type': _Errors.BadReferrerError}) | ||
err => err.should.contain({'type': NeverBounce.errors.BadReferrerError}) | ||
) | ||
@@ -145,5 +144,5 @@ }); | ||
.then( | ||
err => err.should.contain({'type': _Errors.GeneralError}) | ||
err => err.should.contain({'type': NeverBounce.errors.GeneralError}) | ||
) | ||
}); | ||
}); |
const chai = require('chai'), | ||
assert = chai.assert, | ||
chaiAsPromised = require('chai-as-promised'), | ||
nock = require('nock'), | ||
_Errors = require('../src/Errors'), | ||
NeverBounce = require('../src/NeverBounce'); | ||
@@ -257,2 +257,13 @@ | ||
}); | ||
/** | ||
* @since 4.1.4 | ||
*/ | ||
describe('backwards compat', function () { | ||
it('input types should be accessible from Jobs Object', function () { | ||
const jobs = require('../src/Jobs'); | ||
assert.equal(jobs.remote, 'remote_url'); | ||
assert.equal(jobs.supplied, 'supplied'); | ||
}); | ||
}); | ||
}); |
@@ -1,2 +0,2 @@ | ||
const assert = require('assert'), | ||
const assert = require('chai').assert, | ||
NeverBounce = require('../src/NeverBounce'); | ||
@@ -74,2 +74,85 @@ | ||
}); | ||
/** | ||
* @since 4.1.4 | ||
*/ | ||
describe('Helpers/Constants', function() { | ||
describe('VerificationObject Helpers', function() { | ||
it('exposes text result code definitions', function() { | ||
assert.equal(NeverBounce.result.valid, 0); | ||
assert.equal(NeverBounce.result.invalid, 1); | ||
assert.equal(NeverBounce.result.disposable, 2); | ||
assert.equal(NeverBounce.result.catchall, 3); | ||
assert.equal(NeverBounce.result.unknown, 4); | ||
}); | ||
it('exposes numeric result code definitions', function() { | ||
assert.equal(NeverBounce.result[0], 'valid'); | ||
assert.equal(NeverBounce.result[1], 'invalid'); | ||
assert.equal(NeverBounce.result[2], 'disposable'); | ||
assert.equal(NeverBounce.result[3], 'catchall'); | ||
assert.equal(NeverBounce.result[4], 'unknown'); | ||
}); | ||
it('exposes verification result flag definitions', function() { | ||
assert.equal(NeverBounce.result.flags.academic_host, 'acedemic_host'); // API returns misspelling, kept for backwards compat | ||
assert.containsAllKeys(NeverBounce.result.flags, [ | ||
'has_dns', | ||
'has_dns_mx', | ||
'bad_syntax', | ||
'free_email_host', | ||
'profanity', | ||
'role_account', | ||
'disposable_email', | ||
'government_host', | ||
'academic_host', | ||
'military_host', | ||
'international_host', | ||
'squatter_host', | ||
'spelling_mistake', | ||
'bad_dns', | ||
'temporary_dns_error', | ||
'connect_fails', | ||
'accepts_all', | ||
'contains_alias', | ||
'contains_subdomain', | ||
'smtp_connectable', | ||
'spamtrap_network', | ||
]); | ||
}); | ||
}); | ||
describe('Jobs Helpers', function() { | ||
it('exposes input type helpers', function() { | ||
assert.equal(NeverBounce.job.inputType.remote, 'remote_url'); | ||
assert.equal(NeverBounce.job.inputType.supplied, 'supplied'); | ||
}); | ||
it('exposes job status helpers', function() { | ||
assert.containsAllKeys(NeverBounce.job.status, [ | ||
'under_review', | ||
'queued', | ||
'failed', | ||
'complete', | ||
'running', | ||
'parsing', | ||
'waiting', | ||
'waiting_analyzed', | ||
'uploading' | ||
]); | ||
}); | ||
}); | ||
describe('Errors Object', function() { | ||
it('exposes error static types', function() { | ||
assert.hasAllKeys(NeverBounce.errors, [ | ||
'AuthError', | ||
'BadReferrerError', | ||
'GeneralError', | ||
'ThrottleError', | ||
'_lut' | ||
]); | ||
}); | ||
}); | ||
}); | ||
}); |
const chai = require('chai'), | ||
chaiAsPromised = require('chai-as-promised'), | ||
nock = require('nock'), | ||
_Errors = require('../src/Errors'), | ||
NeverBounce = require('../src/NeverBounce'); | ||
@@ -6,0 +5,0 @@ |
const chai = require('chai'), | ||
chaiAsPromised = require('chai-as-promised'), | ||
nock = require('nock'), | ||
_Errors = require('../src/Errors'), | ||
VerificationObject = require('../src/VerificationObject'), | ||
@@ -6,0 +5,0 @@ NeverBounce = require('../src/NeverBounce'); |
@@ -1,2 +0,2 @@ | ||
const assert = require('assert'), | ||
const assert = require('chai').assert, | ||
VerificationObject = require('../src/VerificationObject'); | ||
@@ -86,2 +86,23 @@ | ||
}); | ||
/** | ||
* @since 4.1.4 | ||
*/ | ||
describe('backwards compat', function () { | ||
it('numericCodes object should be accessible from VerificationObject', function () { | ||
assert.equal(VerificationObject.numericCodes.valid, 0); | ||
assert.equal(VerificationObject.numericCodes.invalid, 1); | ||
assert.equal(VerificationObject.numericCodes.disposable, 2); | ||
assert.equal(VerificationObject.numericCodes.catchall, 3); | ||
assert.equal(VerificationObject.numericCodes.unknown, 4); | ||
}); | ||
it('result code definitions should be accessible from VerificationObject', function () { | ||
assert.equal(VerificationObject.valid, 0); | ||
assert.equal(VerificationObject.invalid, 1); | ||
assert.equal(VerificationObject.disposable, 2); | ||
assert.equal(VerificationObject.catchall, 3); | ||
assert.equal(VerificationObject.unknown, 4); | ||
}); | ||
}); | ||
}); |
62344
38
1465
93