-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathZeroBounceApi.js
37 lines (34 loc) · 1.22 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
class ZeroBounceApi {
constructor(apiKey){
var baseUrl = "https://api.zerobounce.net/v2";
var get = new XMLHttpRequest();
/**
* @param apiKey - your private API key
* */
this.apiKey = apiKey;
/**
* @return the number of credits remaining on your account
* */
this.getCredits = function(){
var uri = baseUrl + "/getcredits" + "?api_key=" + apiKey;
get.open('GET', uri, false);
get.send();
if (get.readyState === 4 && get.status === 200) {
return get.responseText;
}
}
/**
* @param email - the email you want to validate
* @param ip - the ip to be use for this validation (optional)
* @return - a JSONObject with all of the information for the specified email
* */
this.validate = function(email, ip_address){
var uri = baseUrl + "/validate" + "?api_key=" + apiKey + "&email=" + email + "&ip_address=" + ip_address;
get.open('GET', uri, false);
get.send();
if (get.readyState == 4 && get.status == 200) {
return get.responseText;
}
}
}
}