forked from zerobounce/zerobounce-javascript-api-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZeroBounceApi.js
49 lines (45 loc) · 1.31 KB
/
ZeroBounceApi.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* eslint-disable camelcase */
const rp = require('request-promise');
const baseUrl = 'https://api.zerobounce.net/v2';
/**
* @param {string} api_key - your private API key
* @return {{
* getCredits: function(): (PromiseLike<number> | Promise<number>),
* validate: function(string, string): (PromiseLike<*> | Promise<*>)
* }}
* @constructor object
*/
function
ZeroBounceApi(api_key) {
return {
/**
* @return {Promise<number>} the number of credits
* remaining on your account
* */
getCredits: () => rp({
uri: baseUrl + '/getcredits',
qs: {
api_key,
},
json: true,
}).then((resp) => resp.Credits),
/**
*
* @param {string} email the email you want to validate
* @param {string} ip_address - the ip to be used
* for this validation (optional)
* @return {string} - a JSONObject with all of the information
* for the specified email
*/
validate: (email, ip_address) => rp({
uri: baseUrl + '/validate',
qs: {
api_key,
email,
ip_address: (ip_address) ? ip_address : ' ',
},
json: true,
}),
};
}
module.exports = ZeroBounceApi;