@zerobounce/zero-bounce-sdk 1.1.2 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -5
- package/documentation.md +49 -7
- package/documentation_es.md +67 -2
- package/package.json +1 -1
- package/src/utils.js +8 -2
- package/src/zero-bounce.js +192 -16
- package/tests/zero-bounce.test.js +179 -51
- package/dist/zeroBounceSDK.js +0 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ const zeroBounce = new ZeroBounceSDK();
|
|
|
37
37
|
Initialize the sdk with your api key:
|
|
38
38
|
|
|
39
39
|
```javascript
|
|
40
|
-
zeroBounce.init("<YOUR_API_KEY>");
|
|
40
|
+
zeroBounce.init("<YOUR_API_KEY>", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
NOTE: all the methods are asynchronous they have to be used with async / await or .then.catch
|
|
@@ -252,29 +252,66 @@ try {
|
|
|
252
252
|
console.error(error);
|
|
253
253
|
}
|
|
254
254
|
```
|
|
255
|
-
|
|
255
|
+
|
|
256
|
+
- ####### Email finder - Test a variety of patterns and combinations in real time until it identifies a valid business email.
|
|
256
257
|
|
|
257
258
|
```javascript
|
|
258
259
|
// Parameters
|
|
259
260
|
// ----------
|
|
260
261
|
// domain: String
|
|
261
262
|
// The email domain for which to find the email format.
|
|
262
|
-
//
|
|
263
|
+
// company_name: String
|
|
264
|
+
// The company name for which to find the email format.
|
|
265
|
+
// first_name: String
|
|
263
266
|
// The first name of the person whose email format is being searched.
|
|
264
267
|
// middle_name: String or null (Optional)
|
|
265
268
|
// The middle name of the person whose email format is being searched.
|
|
266
269
|
// last_name: String or null (Optional)
|
|
267
270
|
// The last name of the person whose email format is being searched.
|
|
268
271
|
|
|
269
|
-
const
|
|
272
|
+
const domainPayload = {
|
|
270
273
|
domain: "<DOMAIN>",
|
|
271
274
|
first_name: "<FIRST_NAME>",
|
|
272
275
|
middle_name: "<MIDDLE_NAME>",
|
|
273
276
|
last_name: "<LAST_NAME>"
|
|
274
277
|
}
|
|
275
278
|
|
|
279
|
+
const companyNamePayload = {
|
|
280
|
+
company_name: "<COMPANY_NAME>",
|
|
281
|
+
first_name: "<FIRST_NAME>",
|
|
282
|
+
middle_name: "<MIDDLE_NAME>",
|
|
283
|
+
last_name: "<LAST_NAME>"
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
try {
|
|
287
|
+
const domainResponse = await zeroBounce.findEmailByDomain(domainPayload);
|
|
288
|
+
const companyNameResponse = await zeroBounce.findEmailByCompanyName(companyNamePayload);
|
|
289
|
+
} catch (error) {
|
|
290
|
+
console.error(error);
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
- ####### Domain Search - Find the domain based on a given domain name or company name
|
|
295
|
+
|
|
296
|
+
```javascript
|
|
297
|
+
// Parameters
|
|
298
|
+
// ----------
|
|
299
|
+
// domain: String
|
|
300
|
+
// The domain name for which to find the email format.
|
|
301
|
+
// company_name: String
|
|
302
|
+
// The company name for which to find the email format.
|
|
303
|
+
|
|
304
|
+
const domainPayload = {
|
|
305
|
+
domain: "<DOMAIN>"
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const companyNamePayload = {
|
|
309
|
+
company_name: "<COMPANY_NAME>"
|
|
310
|
+
}
|
|
311
|
+
|
|
276
312
|
try {
|
|
277
|
-
const
|
|
313
|
+
const domainResponse = await zeroBounce.findEmailFormatByDomain(domainPayload);
|
|
314
|
+
const companyNameResponse = await zeroBounce.findEmailFormatByCompanyName(companyNamePayload);
|
|
278
315
|
} catch (error) {
|
|
279
316
|
console.error(error);
|
|
280
317
|
}
|
package/documentation.md
CHANGED
|
@@ -31,10 +31,10 @@ const ZeroBounceSDK = require('@zerobounce/zero-bounce-sdk')
|
|
|
31
31
|
const zeroBounce = new ZeroBounceSDK();
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
Initialize the sdk with your api key:
|
|
34
|
+
Initialize the sdk with your api key and your preferred api:
|
|
35
35
|
|
|
36
36
|
```javascript
|
|
37
|
-
zeroBounce.init("<YOUR_API_KEY>");
|
|
37
|
+
zeroBounce.init("<YOUR_API_KEY>", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
NOTE: all the methods are asynchronous they have to be used with async / await or .then.catch
|
|
@@ -57,13 +57,19 @@ try {
|
|
|
57
57
|
|
|
58
58
|
```javascript
|
|
59
59
|
const email = "<EMAIL_ADDRESS>"; // The email address you want to validate
|
|
60
|
-
const ip_address = "127.0.0.1"; // The IP Address the email signed up from (Optional)
|
|
61
60
|
|
|
61
|
+
// Using options object (recommended)
|
|
62
62
|
try {
|
|
63
|
-
const response = await zeroBounce.validateEmail(email,
|
|
63
|
+
const response = await zeroBounce.validateEmail(email, {
|
|
64
|
+
ip_address: "127.0.0.1", // The IP Address the email signed up from (Optional)
|
|
65
|
+
timeout: 10, // Validation timeout in seconds, 3-60 (Optional)
|
|
66
|
+
});
|
|
64
67
|
} catch (error) {
|
|
65
68
|
console.error(error);
|
|
66
69
|
}
|
|
70
|
+
|
|
71
|
+
// Legacy syntax (still supported for backwards compatibility)
|
|
72
|
+
// const response = await zeroBounce.validateEmail(email, "127.0.0.1");
|
|
67
73
|
```
|
|
68
74
|
|
|
69
75
|
- ####### Get api usage from a start date to an end date
|
|
@@ -257,22 +263,58 @@ try {
|
|
|
257
263
|
// ----------
|
|
258
264
|
// domain: String
|
|
259
265
|
// The email domain for which to find the email format.
|
|
260
|
-
//
|
|
266
|
+
// company_name: String
|
|
267
|
+
// The company name for which to find the email format.
|
|
268
|
+
// first_name: String
|
|
261
269
|
// The first name of the person whose email format is being searched.
|
|
262
270
|
// middle_name: String or null (Optional)
|
|
263
271
|
// The middle name of the person whose email format is being searched.
|
|
264
272
|
// last_name: String or null (Optional)
|
|
265
273
|
// The last name of the person whose email format is being searched.
|
|
266
274
|
|
|
267
|
-
const
|
|
275
|
+
const domainPayload = {
|
|
268
276
|
domain: "<DOMAIN>",
|
|
269
277
|
first_name: "<FIRST_NAME>",
|
|
270
278
|
middle_name: "<MIDDLE_NAME>",
|
|
271
279
|
last_name: "<LAST_NAME>"
|
|
272
280
|
}
|
|
273
281
|
|
|
282
|
+
const companyNamePayload = {
|
|
283
|
+
company_name: "<COMPANY_NAME>",
|
|
284
|
+
first_name: "<FIRST_NAME>",
|
|
285
|
+
middle_name: "<MIDDLE_NAME>",
|
|
286
|
+
last_name: "<LAST_NAME>"
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
try {
|
|
290
|
+
const domainResponse = await zeroBounce.findEmailByDomain(domainPayload);
|
|
291
|
+
const companyNameResponse = await zeroBounce.findEmailByCompanyName(companyNamePayload);
|
|
292
|
+
} catch (error) {
|
|
293
|
+
console.error(error);
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
- ####### Domain Search - Find the domain based on a given domain name or company name
|
|
298
|
+
|
|
299
|
+
```javascript
|
|
300
|
+
// Parameters
|
|
301
|
+
// ----------
|
|
302
|
+
// domain: String
|
|
303
|
+
// The domain name for which to find the email format.
|
|
304
|
+
// company_name: String
|
|
305
|
+
// The company name for which to find the email format.
|
|
306
|
+
|
|
307
|
+
const domainPayload = {
|
|
308
|
+
domain: "<DOMAIN>"
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const companyNamePayload = {
|
|
312
|
+
company_name: "<COMPANY_NAME>"
|
|
313
|
+
}
|
|
314
|
+
|
|
274
315
|
try {
|
|
275
|
-
const
|
|
316
|
+
const domainResponse = await zeroBounce.findEmailFormatByDomain(domainPayload);
|
|
317
|
+
const companyNameResponse = await zeroBounce.findEmailFormatByCompanyName(companyNamePayload);
|
|
276
318
|
} catch (error) {
|
|
277
319
|
console.error(error);
|
|
278
320
|
}
|
package/documentation_es.md
CHANGED
|
@@ -31,10 +31,10 @@ const ZeroBounceSDK = require('zero-bounce-sdk')
|
|
|
31
31
|
const zeroBounce = new ZeroBounceSDK();
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
Inicialice el SDK con su clave de API:
|
|
34
|
+
Inicialice el SDK con su clave de API y tu API preferida:
|
|
35
35
|
|
|
36
36
|
```javascript
|
|
37
|
-
zeroBounce.init("<SU_CLAVE_DE_API>");
|
|
37
|
+
zeroBounce.init("<SU_CLAVE_DE_API>", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
NOTA: todos los métodos son asíncronos y deben usarse con async / await o .then.catch.
|
|
@@ -254,6 +254,71 @@ try {
|
|
|
254
254
|
}
|
|
255
255
|
```
|
|
256
256
|
|
|
257
|
+
- ####### Buscador de correos electrónicos: prueba una variedad de patrones y combinaciones en tiempo real hasta que identifique un correo electrónico comercial válido.
|
|
258
|
+
|
|
259
|
+
```javascript
|
|
260
|
+
// Parameters
|
|
261
|
+
// ----------
|
|
262
|
+
// domain: String
|
|
263
|
+
// El dominio de correo electrónico para el que se debe buscar el formato de correo electrónico.
|
|
264
|
+
// company_name: String
|
|
265
|
+
// El nombre de la empresa para la que se busca el formato de correo electrónico.
|
|
266
|
+
// first_name: String
|
|
267
|
+
// El nombre de la persona cuyo formato de correo electrónico se está buscando.
|
|
268
|
+
// middle_name: String or null (Optional)
|
|
269
|
+
// El segundo nombre de la persona cuyo formato de correo electrónico se está buscando.
|
|
270
|
+
// last_name: String or null (Optional)
|
|
271
|
+
// El apellido de la persona cuyo formato de correo electrónico se está buscando.
|
|
272
|
+
|
|
273
|
+
const domainPayload = {
|
|
274
|
+
domain: "<DOMAIN>",
|
|
275
|
+
first_name: "<FIRST_NAME>",
|
|
276
|
+
middle_name: "<MIDDLE_NAME>",
|
|
277
|
+
last_name: "<LAST_NAME>"
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const companyNamePayload = {
|
|
281
|
+
company_name: "<COMPANY_NAME>",
|
|
282
|
+
first_name: "<FIRST_NAME>",
|
|
283
|
+
middle_name: "<MIDDLE_NAME>",
|
|
284
|
+
last_name: "<LAST_NAME>"
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
try {
|
|
288
|
+
const domainResponse = await zeroBounce.findEmailByDomain(domainPayload);
|
|
289
|
+
const companyNameResponse = await zeroBounce.findEmailByCompanyName(companyNamePayload);
|
|
290
|
+
} catch (error) {
|
|
291
|
+
console.error(error);
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
- ####### Búsqueda de dominios: encuentre el dominio basado en un nombre de dominio o nombre de empresa determinados.
|
|
296
|
+
|
|
297
|
+
```javascript
|
|
298
|
+
// Parameters
|
|
299
|
+
// ----------
|
|
300
|
+
// domain: String
|
|
301
|
+
// El nombre de dominio para el que se busca el formato de correo electrónico.
|
|
302
|
+
// company_name: String
|
|
303
|
+
// El nombre de la empresa para la que se debe buscar el formato de correo electrónico.
|
|
304
|
+
|
|
305
|
+
const domainPayload = {
|
|
306
|
+
domain: "<DOMAIN>"
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
const companyNamePayload = {
|
|
310
|
+
company_name: "<COMPANY_NAME>"
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
try {
|
|
314
|
+
const domainResponse = await zeroBounce.findEmailFormatByDomain(domainPayload);
|
|
315
|
+
const companyNameResponse = await zeroBounce.findEmailFormatByCompanyName(companyNamePayload);
|
|
316
|
+
} catch (error) {
|
|
317
|
+
console.error(error);
|
|
318
|
+
}
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
|
|
257
322
|
**Puede utilizar cualquiera de las siguientes direcciones de correo electrónico para probar la API, no se cobran créditos por estas direcciones de correo electrónico de prueba:**
|
|
258
323
|
|
|
259
324
|
- disposable@example.com
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerobounce/zero-bounce-sdk",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "This SDK contains methods for interacting easily with ZeroBounce API. More information about ZeroBounce you can find in the official documentation.",
|
|
5
5
|
"main": "dist/zeroBounceSDK.js",
|
|
6
6
|
"scripts": {
|
package/src/utils.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// Constants
|
|
2
|
-
export const API_BASE_URL = "https://api.zerobounce.net/v2";
|
|
3
2
|
export const API_BULK_BASE_URL = "https://bulkapi.zerobounce.net/v2";
|
|
4
3
|
export const HEADERS = {
|
|
5
4
|
Accept: "*/*",
|
|
@@ -15,9 +14,10 @@ export async function createRequest({
|
|
|
15
14
|
batch = false,
|
|
16
15
|
returnText = false,
|
|
17
16
|
scoring = false,
|
|
17
|
+
apiBaseURL
|
|
18
18
|
}) {
|
|
19
19
|
const url = `${
|
|
20
|
-
batch ? API_BULK_BASE_URL :
|
|
20
|
+
batch ? API_BULK_BASE_URL : apiBaseURL
|
|
21
21
|
}${path}?${new URLSearchParams(params)}`;
|
|
22
22
|
|
|
23
23
|
try {
|
|
@@ -74,3 +74,9 @@ export function parameterIsMissing(parameter, aditionalInfo = "") {
|
|
|
74
74
|
`ZeroBounce: ${parameter} parameter is missing. ${aditionalInfo}`
|
|
75
75
|
);
|
|
76
76
|
}
|
|
77
|
+
|
|
78
|
+
export function parameterIsInvalid(parameter, aditionalInfo = "") {
|
|
79
|
+
console.error(
|
|
80
|
+
`ZeroBounce: ${parameter} parameter is invalid. ${aditionalInfo}`
|
|
81
|
+
);
|
|
82
|
+
}
|
package/src/zero-bounce.js
CHANGED
|
@@ -1,19 +1,28 @@
|
|
|
1
|
-
import { createRequest, notInitialized, parameterIsMissing } from "./utils.js";
|
|
1
|
+
import { createRequest, notInitialized, parameterIsMissing, parameterIsInvalid } from "./utils.js";
|
|
2
2
|
|
|
3
3
|
export class ZeroBounceSDK {
|
|
4
|
+
static ApiURL = Object.freeze({
|
|
5
|
+
DEFAULT_API_URL: "https://api.zerobounce.net/v2",
|
|
6
|
+
USA_API_URL: "https://api-us.zerobounce.net/v2",
|
|
7
|
+
EU_API_URL: "https://api-eu.zerobounce.net/v2"
|
|
8
|
+
});
|
|
9
|
+
|
|
4
10
|
constructor() {
|
|
5
11
|
this._initialized = false;
|
|
6
12
|
this._api_key = null;
|
|
13
|
+
this._api_base_url = ZeroBounceSDK.ApiURL.DEFAULT_API_URL;
|
|
7
14
|
}
|
|
8
15
|
|
|
9
16
|
/**
|
|
10
17
|
* @param apiKey - your private API key
|
|
18
|
+
* @param apiBaseURL - your preferred API, possible values being ApiURL.DEFAULT_API_URL, ApiURL.USAAPIURL, ApiURL.EUAPIURL
|
|
11
19
|
* */
|
|
12
|
-
init(apiKey) {
|
|
20
|
+
init(apiKey, apiBaseURL = ZeroBounceSDK.ApiURL.DEFAULT_API_URL) {
|
|
13
21
|
if (!apiKey) {
|
|
14
22
|
parameterIsMissing("Api key", "Please provide a valid API key.");
|
|
15
23
|
} else {
|
|
16
24
|
this._api_key = apiKey;
|
|
25
|
+
this._api_base_url = apiBaseURL;
|
|
17
26
|
this._initialized = true;
|
|
18
27
|
}
|
|
19
28
|
}
|
|
@@ -26,14 +35,16 @@ export class ZeroBounceSDK {
|
|
|
26
35
|
const params = {
|
|
27
36
|
api_key: this._api_key,
|
|
28
37
|
};
|
|
29
|
-
return createRequest({ requestType: "GET", params, path: "/getcredits" });
|
|
38
|
+
return createRequest({ requestType: "GET", params, path: "/getcredits", apiBaseURL: this._api_base_url });
|
|
30
39
|
}
|
|
31
40
|
|
|
32
41
|
/**
|
|
33
42
|
* @param email - email to be validated
|
|
34
|
-
* @param ip_address
|
|
43
|
+
* @param options - options object or ip_address string for backwards compatibility
|
|
44
|
+
* @param options.ip_address - IP address (optional)
|
|
45
|
+
* @param options.timeout - validation timeout in seconds, 3-60 (optional). If met, the API will return unknown/greylisted.
|
|
35
46
|
* */
|
|
36
|
-
validateEmail(email,
|
|
47
|
+
validateEmail(email, options = null) {
|
|
37
48
|
if (!this._initialized) {
|
|
38
49
|
notInitialized();
|
|
39
50
|
return;
|
|
@@ -41,12 +52,29 @@ export class ZeroBounceSDK {
|
|
|
41
52
|
parameterIsMissing("Email");
|
|
42
53
|
return;
|
|
43
54
|
}
|
|
55
|
+
|
|
56
|
+
let ip_address;
|
|
57
|
+
let timeout;
|
|
58
|
+
if (typeof options === "string") {
|
|
59
|
+
ip_address = options;
|
|
60
|
+
} else if (options && typeof options === "object") {
|
|
61
|
+
ip_address = options.ip_address;
|
|
62
|
+
timeout = options.timeout;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (timeout != null && (timeout < 3 || timeout > 60)) {
|
|
66
|
+
parameterIsInvalid("timeout", "Must be between 3 and 60 seconds.");
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
44
70
|
const params = {
|
|
45
71
|
api_key: this._api_key,
|
|
46
|
-
email
|
|
47
|
-
ip_address,
|
|
72
|
+
email,
|
|
48
73
|
};
|
|
49
|
-
|
|
74
|
+
if (ip_address != null) params.ip_address = ip_address;
|
|
75
|
+
if (timeout != null) params.timeout = timeout;
|
|
76
|
+
|
|
77
|
+
return createRequest({ requestType: "GET", params, path: "/validate", apiBaseURL: this._api_base_url });
|
|
50
78
|
}
|
|
51
79
|
|
|
52
80
|
/**
|
|
@@ -73,7 +101,8 @@ export class ZeroBounceSDK {
|
|
|
73
101
|
return createRequest({
|
|
74
102
|
requestType: "GET",
|
|
75
103
|
params,
|
|
76
|
-
path: "/getapiusage",
|
|
104
|
+
path: "/getapiusage",
|
|
105
|
+
apiBaseURL: this._api_base_url
|
|
77
106
|
});
|
|
78
107
|
}
|
|
79
108
|
|
|
@@ -98,7 +127,8 @@ export class ZeroBounceSDK {
|
|
|
98
127
|
requestType: "POST",
|
|
99
128
|
path: "/validatebatch",
|
|
100
129
|
body: JSON.stringify(body),
|
|
101
|
-
batch: true,
|
|
130
|
+
batch: true,
|
|
131
|
+
apiBaseURL: this._api_base_url
|
|
102
132
|
});
|
|
103
133
|
}
|
|
104
134
|
|
|
@@ -120,7 +150,8 @@ export class ZeroBounceSDK {
|
|
|
120
150
|
return createRequest({
|
|
121
151
|
requestType: "GET",
|
|
122
152
|
params,
|
|
123
|
-
path: "/activity",
|
|
153
|
+
path: "/activity",
|
|
154
|
+
apiBaseURL: this._api_base_url
|
|
124
155
|
});
|
|
125
156
|
}
|
|
126
157
|
|
|
@@ -184,7 +215,8 @@ export class ZeroBounceSDK {
|
|
|
184
215
|
requestType: "POST",
|
|
185
216
|
path: "/sendfile",
|
|
186
217
|
body,
|
|
187
|
-
batch: true,
|
|
218
|
+
batch: true,
|
|
219
|
+
apiBaseURL: this._api_base_url
|
|
188
220
|
});
|
|
189
221
|
}
|
|
190
222
|
|
|
@@ -229,7 +261,8 @@ export class ZeroBounceSDK {
|
|
|
229
261
|
requestType: "POST",
|
|
230
262
|
path: "/scoring/sendfile",
|
|
231
263
|
body,
|
|
232
|
-
batch: true,
|
|
264
|
+
batch: true,
|
|
265
|
+
apiBaseURL: this._api_base_url
|
|
233
266
|
});
|
|
234
267
|
}
|
|
235
268
|
|
|
@@ -251,6 +284,7 @@ export class ZeroBounceSDK {
|
|
|
251
284
|
params,
|
|
252
285
|
path,
|
|
253
286
|
batch: true,
|
|
287
|
+
apiBaseURL: this._api_base_url
|
|
254
288
|
});
|
|
255
289
|
}
|
|
256
290
|
|
|
@@ -286,7 +320,8 @@ export class ZeroBounceSDK {
|
|
|
286
320
|
path,
|
|
287
321
|
batch: true,
|
|
288
322
|
returnText: true,
|
|
289
|
-
scoring,
|
|
323
|
+
scoring,
|
|
324
|
+
apiBaseURL: this._api_base_url
|
|
290
325
|
});
|
|
291
326
|
}
|
|
292
327
|
|
|
@@ -321,7 +356,8 @@ export class ZeroBounceSDK {
|
|
|
321
356
|
params,
|
|
322
357
|
path,
|
|
323
358
|
batch: true,
|
|
324
|
-
scoring,
|
|
359
|
+
scoring,
|
|
360
|
+
apiBaseURL: this._api_base_url
|
|
325
361
|
});
|
|
326
362
|
}
|
|
327
363
|
|
|
@@ -342,6 +378,144 @@ export class ZeroBounceSDK {
|
|
|
342
378
|
// EMAIL FINDER
|
|
343
379
|
|
|
344
380
|
/**
|
|
381
|
+
* @param domain str - domain of the email address
|
|
382
|
+
* @param first_name str - first name
|
|
383
|
+
* @param middle_name str or null - middle name
|
|
384
|
+
* @param last_name str or null - last name
|
|
385
|
+
* */
|
|
386
|
+
findEmailByDomain({
|
|
387
|
+
domain,
|
|
388
|
+
first_name,
|
|
389
|
+
middle_name = null,
|
|
390
|
+
last_name = null
|
|
391
|
+
}) {
|
|
392
|
+
return this._findEmail({
|
|
393
|
+
domain: domain,
|
|
394
|
+
first_name: first_name,
|
|
395
|
+
middle_name: middle_name,
|
|
396
|
+
last_name: last_name
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* @param company_name str - company name of the email address
|
|
402
|
+
* @param first_name str - first name
|
|
403
|
+
* @param middle_name str or null - middle name
|
|
404
|
+
* @param last_name str or null - last name
|
|
405
|
+
* */
|
|
406
|
+
findEmailByCompanyName({
|
|
407
|
+
company_name,
|
|
408
|
+
first_name,
|
|
409
|
+
middle_name = null,
|
|
410
|
+
last_name = null
|
|
411
|
+
}) {
|
|
412
|
+
return this._findEmail({
|
|
413
|
+
company_name: company_name,
|
|
414
|
+
first_name: first_name,
|
|
415
|
+
middle_name: middle_name,
|
|
416
|
+
last_name: last_name
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
_findEmail({
|
|
421
|
+
domain = null,
|
|
422
|
+
company_name = null,
|
|
423
|
+
first_name,
|
|
424
|
+
middle_name = null,
|
|
425
|
+
last_name = null
|
|
426
|
+
}) {
|
|
427
|
+
if (!this._initialized) {
|
|
428
|
+
notInitialized();
|
|
429
|
+
return;
|
|
430
|
+
} else if (!domain && !company_name) {
|
|
431
|
+
parameterIsMissing("domain");
|
|
432
|
+
parameterIsMissing("company_name");
|
|
433
|
+
return;
|
|
434
|
+
} else if (!first_name) {
|
|
435
|
+
parameterIsMissing("first_name");
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
const params = {
|
|
440
|
+
api_key: this._api_key,
|
|
441
|
+
first_name: first_name,
|
|
442
|
+
middle_name: middle_name,
|
|
443
|
+
last_name: last_name,
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
if (domain != null) {
|
|
447
|
+
params["domain"] = domain;
|
|
448
|
+
} else if (company_name != null) {
|
|
449
|
+
params["company_name"] = company_name;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
return createRequest({
|
|
453
|
+
requestType: "GET",
|
|
454
|
+
params,
|
|
455
|
+
path: "/guessformat",
|
|
456
|
+
apiBaseURL: this._api_base_url
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
// DOMAIN SEARCH
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* @param domain str - domain name
|
|
465
|
+
* */
|
|
466
|
+
findEmailFormatByDomain({
|
|
467
|
+
domain
|
|
468
|
+
}) {
|
|
469
|
+
return this._findEmailFormat({
|
|
470
|
+
domain: domain
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* @param company_name str - company name
|
|
476
|
+
* */
|
|
477
|
+
findEmailFormatByCompanyName({
|
|
478
|
+
company_name
|
|
479
|
+
}) {
|
|
480
|
+
return this._findEmailFormat({
|
|
481
|
+
company_name: company_name
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
_findEmailFormat({
|
|
486
|
+
domain = null,
|
|
487
|
+
company_name = null
|
|
488
|
+
}) {
|
|
489
|
+
if (!this._initialized) {
|
|
490
|
+
notInitialized();
|
|
491
|
+
return;
|
|
492
|
+
} else if (!domain && !company_name) {
|
|
493
|
+
parameterIsMissing("domain");
|
|
494
|
+
parameterIsMissing("company_name");
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
const params = {
|
|
499
|
+
api_key: this._api_key
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
if (domain != null) {
|
|
503
|
+
params["domain"] = domain;
|
|
504
|
+
} else if (company_name != null) {
|
|
505
|
+
params["company_name"] = company_name;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
return createRequest({
|
|
509
|
+
requestType: "GET",
|
|
510
|
+
params,
|
|
511
|
+
path: "/guessformat",
|
|
512
|
+
apiBaseURL: this._api_base_url
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* @deprecated Use findEmail for Email Finder API, or findEmailFormat for Domain Search API.
|
|
345
519
|
* @param domain str - domain of the email address
|
|
346
520
|
* @param first_name str or null - first name
|
|
347
521
|
* @param middle_name str or null - middle name
|
|
@@ -353,6 +527,7 @@ export class ZeroBounceSDK {
|
|
|
353
527
|
middle_name = null,
|
|
354
528
|
last_name = null
|
|
355
529
|
}) {
|
|
530
|
+
console.warn("guessFormat() is deprecated. Use findEmail for Email Finder API, or findEmailFormat for Domain Search API.");
|
|
356
531
|
if (!this._initialized) {
|
|
357
532
|
notInitialized();
|
|
358
533
|
return;
|
|
@@ -372,7 +547,8 @@ export class ZeroBounceSDK {
|
|
|
372
547
|
return createRequest({
|
|
373
548
|
requestType: "GET",
|
|
374
549
|
params,
|
|
375
|
-
path: "/guessformat",
|
|
550
|
+
path: "/guessformat",
|
|
551
|
+
apiBaseURL: this._api_base_url
|
|
376
552
|
});
|
|
377
553
|
}
|
|
378
554
|
}
|
|
@@ -31,7 +31,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
it("should return error response with invalid API key", async () => {
|
|
34
|
-
zeroBounceSDK.init("invalid-api-key");
|
|
34
|
+
zeroBounceSDK.init("invalid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
35
35
|
try {
|
|
36
36
|
await zeroBounceSDK.getCredits();
|
|
37
37
|
} catch (error) {
|
|
@@ -49,7 +49,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
49
49
|
text: () => Promise.resolve(JSON.stringify(expectedResponse)),
|
|
50
50
|
}));
|
|
51
51
|
|
|
52
|
-
zeroBounceSDK.init("valid-api-key");
|
|
52
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
53
53
|
const response = await zeroBounceSDK.getCredits();
|
|
54
54
|
expect(response).toEqual(expectedResponse);
|
|
55
55
|
});
|
|
@@ -66,7 +66,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
it("should throw an error if stardDate is missing", async () => {
|
|
69
|
-
zeroBounceSDK.init("valid-api-key");
|
|
69
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
70
70
|
await zeroBounceSDK.getApiUsage(null, endDate);
|
|
71
71
|
expect(console.error).toHaveBeenCalledWith(
|
|
72
72
|
expect.stringContaining(missingParamMessage)
|
|
@@ -74,7 +74,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
it("should throw an error if endDate is missing", async () => {
|
|
77
|
-
zeroBounceSDK.init("valid-api-key");
|
|
77
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
78
78
|
await zeroBounceSDK.getApiUsage(startDate, null);
|
|
79
79
|
expect(console.error).toHaveBeenCalledWith(
|
|
80
80
|
expect.stringContaining(missingParamMessage)
|
|
@@ -82,7 +82,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
it("should return error response with invalid API key", async () => {
|
|
85
|
-
zeroBounceSDK.init("invalid-api-key");
|
|
85
|
+
zeroBounceSDK.init("invalid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
86
86
|
try {
|
|
87
87
|
await zeroBounceSDK.getApiUsage(startDate, endDate);
|
|
88
88
|
} catch (error) {
|
|
@@ -120,6 +120,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
120
120
|
"sub_status_mailbox_quota_exceeded": 0,
|
|
121
121
|
"sub_status_forcible_disconnect": 0,
|
|
122
122
|
"sub_status_failed_smtp_connection": 0,
|
|
123
|
+
"sub_status_accept_all": 0,
|
|
123
124
|
"sub_status_mx_forward": 0,
|
|
124
125
|
"sub_status_alternate": 0,
|
|
125
126
|
"sub_status_blocked": 0,
|
|
@@ -133,7 +134,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
133
134
|
text: () => Promise.resolve(JSON.stringify(expectedResponse)),
|
|
134
135
|
}));
|
|
135
136
|
|
|
136
|
-
zeroBounceSDK.init("valid-api-key");
|
|
137
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
137
138
|
const response = await zeroBounceSDK.getApiUsage(startDate, endDate);
|
|
138
139
|
expect(response).toEqual(expectedResponse);
|
|
139
140
|
});
|
|
@@ -150,7 +151,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
150
151
|
});
|
|
151
152
|
|
|
152
153
|
it("should throw an error if email is missing", async () => {
|
|
153
|
-
zeroBounceSDK.init("valid-api-key");
|
|
154
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
154
155
|
await zeroBounceSDK.validateEmail(null);
|
|
155
156
|
expect(console.error).toHaveBeenCalledWith(
|
|
156
157
|
expect.stringContaining(missingParamMessage)
|
|
@@ -158,7 +159,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
158
159
|
});
|
|
159
160
|
|
|
160
161
|
it("should return error response with invalid API key", async () => {
|
|
161
|
-
zeroBounceSDK.init("invalid-api-key");
|
|
162
|
+
zeroBounceSDK.init("invalid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
162
163
|
try {
|
|
163
164
|
await zeroBounceSDK.validateEmail(email, ip_address);
|
|
164
165
|
} catch (error) {
|
|
@@ -194,10 +195,88 @@ describe("ZeroBounceSDK", () => {
|
|
|
194
195
|
text: () => Promise.resolve(JSON.stringify(expectedResponse)),
|
|
195
196
|
}));
|
|
196
197
|
|
|
197
|
-
zeroBounceSDK.init("valid-api-key");
|
|
198
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
198
199
|
const response = await zeroBounceSDK.validateEmail(email, ip_address);
|
|
199
200
|
expect(response).toEqual(expectedResponse);
|
|
200
201
|
});
|
|
202
|
+
|
|
203
|
+
it("should pass options object to the API", async () => {
|
|
204
|
+
const expectedResponse = {
|
|
205
|
+
"address": "valid@example.com",
|
|
206
|
+
"status": "valid",
|
|
207
|
+
"sub_status": "",
|
|
208
|
+
"free_email": false,
|
|
209
|
+
"did_you_mean": null,
|
|
210
|
+
"account": null,
|
|
211
|
+
"domain": null,
|
|
212
|
+
"domain_age_days": "9692",
|
|
213
|
+
"smtp_provider": "example",
|
|
214
|
+
"mx_found": "true",
|
|
215
|
+
"mx_record": "mx.example.com",
|
|
216
|
+
"firstname": "zero",
|
|
217
|
+
"lastname": "bounce",
|
|
218
|
+
"gender": "male",
|
|
219
|
+
"country": null,
|
|
220
|
+
"region": null,
|
|
221
|
+
"city": null,
|
|
222
|
+
"zipcode": null,
|
|
223
|
+
"processed_at": "2023-04-27 13:47:23.980"
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const fetchSpy = jest.spyOn(global, "fetch").mockImplementationOnce(() => Promise.resolve({
|
|
227
|
+
json: () => Promise.resolve(expectedResponse),
|
|
228
|
+
text: () => Promise.resolve(JSON.stringify(expectedResponse)),
|
|
229
|
+
}));
|
|
230
|
+
|
|
231
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
232
|
+
await zeroBounceSDK.validateEmail(email, { ip_address: ip_address, timeout: 10 });
|
|
233
|
+
|
|
234
|
+
expect(fetchSpy).toHaveBeenCalledWith(
|
|
235
|
+
expect.stringContaining("ip_address=127.0.0.1"),
|
|
236
|
+
expect.any(Object)
|
|
237
|
+
);
|
|
238
|
+
expect(fetchSpy).toHaveBeenCalledWith(
|
|
239
|
+
expect.stringContaining("timeout=10"),
|
|
240
|
+
expect.any(Object)
|
|
241
|
+
);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it("should pass timeout only via options object", async () => {
|
|
245
|
+
const expectedResponse = {
|
|
246
|
+
"address": "valid@example.com",
|
|
247
|
+
"status": "valid",
|
|
248
|
+
"sub_status": "",
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const fetchSpy = jest.spyOn(global, "fetch").mockImplementationOnce(() => Promise.resolve({
|
|
252
|
+
json: () => Promise.resolve(expectedResponse),
|
|
253
|
+
text: () => Promise.resolve(JSON.stringify(expectedResponse)),
|
|
254
|
+
}));
|
|
255
|
+
|
|
256
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
257
|
+
await zeroBounceSDK.validateEmail(email, { timeout: 30 });
|
|
258
|
+
|
|
259
|
+
expect(fetchSpy).toHaveBeenCalledWith(
|
|
260
|
+
expect.stringContaining("timeout=30"),
|
|
261
|
+
expect.any(Object)
|
|
262
|
+
);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it("should throw an error if timeout is less than 3", async () => {
|
|
266
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
267
|
+
await zeroBounceSDK.validateEmail(email, { timeout: 2 });
|
|
268
|
+
expect(console.error).toHaveBeenCalledWith(
|
|
269
|
+
expect.stringContaining("timeout parameter is invalid")
|
|
270
|
+
);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it("should throw an error if timeout is greater than 60", async () => {
|
|
274
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
275
|
+
await zeroBounceSDK.validateEmail(email, { timeout: 61 });
|
|
276
|
+
expect(console.error).toHaveBeenCalledWith(
|
|
277
|
+
expect.stringContaining("timeout parameter is invalid")
|
|
278
|
+
);
|
|
279
|
+
});
|
|
201
280
|
});
|
|
202
281
|
|
|
203
282
|
|
|
@@ -213,7 +292,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
213
292
|
});
|
|
214
293
|
|
|
215
294
|
it("should throw an error if email list is missing", async () => {
|
|
216
|
-
zeroBounceSDK.init("valid-api-key");
|
|
295
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
217
296
|
await zeroBounceSDK.validateBatch(null);
|
|
218
297
|
expect(console.error).toHaveBeenCalledWith(
|
|
219
298
|
expect.stringContaining(missingParamMessage)
|
|
@@ -221,7 +300,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
221
300
|
});
|
|
222
301
|
|
|
223
302
|
it("should return error response with invalid API key", async () => {
|
|
224
|
-
zeroBounceSDK.init("invalid-api-key");
|
|
303
|
+
zeroBounceSDK.init("invalid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
225
304
|
try {
|
|
226
305
|
await zeroBounceSDK.validateBatch(emailBatch);
|
|
227
306
|
} catch (error) {
|
|
@@ -283,7 +362,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
283
362
|
text: () => Promise.resolve(JSON.stringify(expectedResponse)),
|
|
284
363
|
}));
|
|
285
364
|
|
|
286
|
-
zeroBounceSDK.init("valid-api-key");
|
|
365
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
287
366
|
const response = await zeroBounceSDK.validateBatch(emailBatch);
|
|
288
367
|
expect(response).toEqual(expectedResponse);
|
|
289
368
|
});
|
|
@@ -299,7 +378,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
299
378
|
});
|
|
300
379
|
|
|
301
380
|
it("should throw an error if email is missing", async () => {
|
|
302
|
-
zeroBounceSDK.init("valid-api-key");
|
|
381
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
303
382
|
await zeroBounceSDK.getEmailActivity(null);
|
|
304
383
|
expect(console.error).toHaveBeenCalledWith(
|
|
305
384
|
expect.stringContaining(missingParamMessage)
|
|
@@ -307,7 +386,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
307
386
|
});
|
|
308
387
|
|
|
309
388
|
it("should return error response with invalid API key", async () => {
|
|
310
|
-
zeroBounceSDK.init("invalid-api-key");
|
|
389
|
+
zeroBounceSDK.init("invalid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
311
390
|
try {
|
|
312
391
|
await zeroBounceSDK.getEmailActivity(email);
|
|
313
392
|
} catch (error) {
|
|
@@ -326,7 +405,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
326
405
|
text: () => Promise.resolve(JSON.stringify(expectedResponse)),
|
|
327
406
|
}));
|
|
328
407
|
|
|
329
|
-
zeroBounceSDK.init("valid-api-key");
|
|
408
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
330
409
|
const response = await zeroBounceSDK.getEmailActivity(email);
|
|
331
410
|
expect(response).toEqual(expectedResponse);
|
|
332
411
|
});
|
|
@@ -352,7 +431,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
352
431
|
email_address_column: 1,
|
|
353
432
|
};
|
|
354
433
|
|
|
355
|
-
zeroBounceSDK.init("valid-api-key");
|
|
434
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
356
435
|
await zeroBounceSDK.sendFile(payload);
|
|
357
436
|
expect(console.error).toHaveBeenCalledWith(
|
|
358
437
|
expect.stringContaining(missingParamMessage)
|
|
@@ -364,7 +443,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
364
443
|
file: file,
|
|
365
444
|
};
|
|
366
445
|
|
|
367
|
-
zeroBounceSDK.init("valid-api-key");
|
|
446
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
368
447
|
await zeroBounceSDK.sendFile(payload);
|
|
369
448
|
expect(console.error).toHaveBeenCalledWith(
|
|
370
449
|
expect.stringContaining(missingParamMessage)
|
|
@@ -372,7 +451,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
372
451
|
});
|
|
373
452
|
|
|
374
453
|
it("should return error response with invalid API key", async () => {
|
|
375
|
-
zeroBounceSDK.init("invalid-api-key");
|
|
454
|
+
zeroBounceSDK.init("invalid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
376
455
|
const response = await zeroBounceSDK.sendFile(payload);
|
|
377
456
|
expect(response).toEqual({
|
|
378
457
|
"success": "False",
|
|
@@ -395,7 +474,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
395
474
|
text: () => Promise.resolve(JSON.stringify(expectedResponse)),
|
|
396
475
|
}));
|
|
397
476
|
|
|
398
|
-
zeroBounceSDK.init("valid-api-key");
|
|
477
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
399
478
|
const response = await zeroBounceSDK.sendFile(payload);
|
|
400
479
|
expect(response).toEqual(expectedResponse);
|
|
401
480
|
});
|
|
@@ -421,7 +500,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
421
500
|
email_address_column: 1,
|
|
422
501
|
};
|
|
423
502
|
|
|
424
|
-
zeroBounceSDK.init("valid-api-key");
|
|
503
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
425
504
|
await zeroBounceSDK.sendScoringFile(payload);
|
|
426
505
|
expect(console.error).toHaveBeenCalledWith(
|
|
427
506
|
expect.stringContaining(missingParamMessage)
|
|
@@ -433,7 +512,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
433
512
|
file: file,
|
|
434
513
|
};
|
|
435
514
|
|
|
436
|
-
zeroBounceSDK.init("valid-api-key");
|
|
515
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
437
516
|
await zeroBounceSDK.sendScoringFile(payload);
|
|
438
517
|
expect(console.error).toHaveBeenCalledWith(
|
|
439
518
|
expect.stringContaining(missingParamMessage)
|
|
@@ -441,7 +520,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
441
520
|
});
|
|
442
521
|
|
|
443
522
|
it("should return error response with invalid API key", async () => {
|
|
444
|
-
zeroBounceSDK.init("invalid-api-key");
|
|
523
|
+
zeroBounceSDK.init("invalid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
445
524
|
const response = await zeroBounceSDK.sendScoringFile(payload);
|
|
446
525
|
expect(response).toEqual({
|
|
447
526
|
"success": "False",
|
|
@@ -464,7 +543,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
464
543
|
text: () => Promise.resolve(JSON.stringify(expectedResponse)),
|
|
465
544
|
}));
|
|
466
545
|
|
|
467
|
-
zeroBounceSDK.init("valid-api-key");
|
|
546
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
468
547
|
const response = await zeroBounceSDK.sendScoringFile(payload);
|
|
469
548
|
expect(response).toEqual(expectedResponse);
|
|
470
549
|
});
|
|
@@ -480,7 +559,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
480
559
|
});
|
|
481
560
|
|
|
482
561
|
it("should throw an error if file id is missing", async () => {
|
|
483
|
-
zeroBounceSDK.init("valid-api-key");
|
|
562
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
484
563
|
await zeroBounceSDK.getFileStatus(null);
|
|
485
564
|
expect(console.error).toHaveBeenCalledWith(
|
|
486
565
|
expect.stringContaining(missingParamMessage)
|
|
@@ -488,7 +567,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
488
567
|
});
|
|
489
568
|
|
|
490
569
|
it("should return error response with invalid API key", async () => {
|
|
491
|
-
zeroBounceSDK.init("invalid-api-key");
|
|
570
|
+
zeroBounceSDK.init("invalid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
492
571
|
try {
|
|
493
572
|
await zeroBounceSDK.getFileStatus(fileId);
|
|
494
573
|
} catch (error) {
|
|
@@ -513,7 +592,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
513
592
|
text: () => Promise.resolve(JSON.stringify(expectedResponse)),
|
|
514
593
|
}));
|
|
515
594
|
|
|
516
|
-
zeroBounceSDK.init("valid-api-key");
|
|
595
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
517
596
|
const response = await zeroBounceSDK.getFileStatus(fileId);
|
|
518
597
|
expect(response).toEqual(expectedResponse);
|
|
519
598
|
});
|
|
@@ -529,7 +608,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
529
608
|
});
|
|
530
609
|
|
|
531
610
|
it("should throw an error if file id is missing", async () => {
|
|
532
|
-
zeroBounceSDK.init("valid-api-key");
|
|
611
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
533
612
|
await zeroBounceSDK.getScoringFileStatus(null);
|
|
534
613
|
expect(console.error).toHaveBeenCalledWith(
|
|
535
614
|
expect.stringContaining(missingParamMessage)
|
|
@@ -537,7 +616,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
537
616
|
});
|
|
538
617
|
|
|
539
618
|
it("should return error response with invalid API key", async () => {
|
|
540
|
-
zeroBounceSDK.init("invalid-api-key");
|
|
619
|
+
zeroBounceSDK.init("invalid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
541
620
|
try {
|
|
542
621
|
await zeroBounceSDK.getScoringFileStatus(fileId);
|
|
543
622
|
} catch (error) {
|
|
@@ -561,7 +640,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
561
640
|
text: () => Promise.resolve(JSON.stringify(expectedResponse)),
|
|
562
641
|
}));
|
|
563
642
|
|
|
564
|
-
zeroBounceSDK.init("valid-api-key");
|
|
643
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
565
644
|
const response = await zeroBounceSDK.getScoringFileStatus(fileId);
|
|
566
645
|
expect(response).toEqual(expectedResponse);
|
|
567
646
|
});
|
|
@@ -577,7 +656,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
577
656
|
});
|
|
578
657
|
|
|
579
658
|
it("should throw an error if file id is missing", async () => {
|
|
580
|
-
zeroBounceSDK.init("valid-api-key");
|
|
659
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
581
660
|
await zeroBounceSDK.getFile(null);
|
|
582
661
|
expect(console.error).toHaveBeenCalledWith(
|
|
583
662
|
expect.stringContaining(missingParamMessage)
|
|
@@ -585,7 +664,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
585
664
|
});
|
|
586
665
|
|
|
587
666
|
it("should return error response with invalid API key", async () => {
|
|
588
|
-
zeroBounceSDK.init("invalid-api-key");
|
|
667
|
+
zeroBounceSDK.init("invalid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
589
668
|
try {
|
|
590
669
|
await zeroBounceSDK.getFile(fileId);
|
|
591
670
|
} catch (error) {
|
|
@@ -600,7 +679,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
600
679
|
return Promise.resolve(expectedResponse);
|
|
601
680
|
});
|
|
602
681
|
|
|
603
|
-
zeroBounceSDK.init("valid-api-key");
|
|
682
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
604
683
|
const response = await zeroBounceSDK.getFile(fileId);
|
|
605
684
|
expect(createRequestSpy.mock.calls[0][0]["returnText"]).toEqual(true);
|
|
606
685
|
expect(response).toEqual(expectedResponse);
|
|
@@ -617,7 +696,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
617
696
|
});
|
|
618
697
|
|
|
619
698
|
it("should throw an error if file id is missing", async () => {
|
|
620
|
-
zeroBounceSDK.init("valid-api-key");
|
|
699
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
621
700
|
await zeroBounceSDK.getScoringFile(null);
|
|
622
701
|
expect(console.error).toHaveBeenCalledWith(
|
|
623
702
|
expect.stringContaining(missingParamMessage)
|
|
@@ -625,7 +704,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
625
704
|
});
|
|
626
705
|
|
|
627
706
|
it("should return error response with invalid API key", async () => {
|
|
628
|
-
zeroBounceSDK.init("invalid-api-key");
|
|
707
|
+
zeroBounceSDK.init("invalid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
629
708
|
try {
|
|
630
709
|
await zeroBounceSDK.getScoringFile(fileId);
|
|
631
710
|
} catch (error) {
|
|
@@ -640,7 +719,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
640
719
|
return Promise.resolve(expectedResponse);
|
|
641
720
|
});
|
|
642
721
|
|
|
643
|
-
zeroBounceSDK.init("valid-api-key");
|
|
722
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
644
723
|
const response = await zeroBounceSDK.getScoringFile(fileId);
|
|
645
724
|
expect(createRequestSpy.mock.calls[0][0]["returnText"]).toEqual(true);
|
|
646
725
|
expect(response).toEqual(expectedResponse);
|
|
@@ -657,7 +736,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
657
736
|
});
|
|
658
737
|
|
|
659
738
|
it("should throw an error if file id is missing", async () => {
|
|
660
|
-
zeroBounceSDK.init("valid-api-key");
|
|
739
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
661
740
|
await zeroBounceSDK.deleteFile(null);
|
|
662
741
|
expect(console.error).toHaveBeenCalledWith(
|
|
663
742
|
expect.stringContaining(missingParamMessage)
|
|
@@ -665,7 +744,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
665
744
|
});
|
|
666
745
|
|
|
667
746
|
it("should return error response with invalid API key", async () => {
|
|
668
|
-
zeroBounceSDK.init("invalid-api-key");
|
|
747
|
+
zeroBounceSDK.init("invalid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
669
748
|
try {
|
|
670
749
|
await zeroBounceSDK.deleteFile(fileId);
|
|
671
750
|
} catch (error) {
|
|
@@ -686,7 +765,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
686
765
|
text: () => Promise.resolve(JSON.stringify(expectedResponse)),
|
|
687
766
|
}));
|
|
688
767
|
|
|
689
|
-
zeroBounceSDK.init("valid-api-key");
|
|
768
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
690
769
|
const response = await zeroBounceSDK.deleteFile(fileId);
|
|
691
770
|
expect(response).toEqual(expectedResponse);
|
|
692
771
|
});
|
|
@@ -702,7 +781,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
702
781
|
});
|
|
703
782
|
|
|
704
783
|
it("should throw an error if file id is missing", async () => {
|
|
705
|
-
zeroBounceSDK.init("valid-api-key");
|
|
784
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
706
785
|
await zeroBounceSDK.deleteScoringFile(null);
|
|
707
786
|
expect(console.error).toHaveBeenCalledWith(
|
|
708
787
|
expect.stringContaining(missingParamMessage)
|
|
@@ -710,7 +789,7 @@ describe("ZeroBounceSDK", () => {
|
|
|
710
789
|
});
|
|
711
790
|
|
|
712
791
|
it("should return error response with invalid API key", async () => {
|
|
713
|
-
zeroBounceSDK.init("invalid-api-key");
|
|
792
|
+
zeroBounceSDK.init("invalid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
714
793
|
try {
|
|
715
794
|
await zeroBounceSDK.deleteScoringFile(fileId);
|
|
716
795
|
} catch (error) {
|
|
@@ -731,14 +810,14 @@ describe("ZeroBounceSDK", () => {
|
|
|
731
810
|
text: () => Promise.resolve(JSON.stringify(expectedResponse)),
|
|
732
811
|
}));
|
|
733
812
|
|
|
734
|
-
zeroBounceSDK.init("valid-api-key");
|
|
813
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
735
814
|
const response = await zeroBounceSDK.deleteScoringFile(fileId);
|
|
736
815
|
expect(response).toEqual(expectedResponse);
|
|
737
816
|
});
|
|
738
817
|
});
|
|
739
818
|
|
|
740
819
|
// EMAIL FINDER
|
|
741
|
-
describe("
|
|
820
|
+
describe("findEmail", () => {
|
|
742
821
|
const payload = {
|
|
743
822
|
domain: "example.com",
|
|
744
823
|
first_name: "John",
|
|
@@ -746,22 +825,22 @@ describe("ZeroBounceSDK", () => {
|
|
|
746
825
|
}
|
|
747
826
|
|
|
748
827
|
it("should throw an error if not initialized", async () => {
|
|
749
|
-
await zeroBounceSDK.
|
|
828
|
+
await zeroBounceSDK.findEmailByDomain(payload);
|
|
750
829
|
expect(console.error).toHaveBeenCalledWith(initErrorMessage);
|
|
751
830
|
});
|
|
752
831
|
|
|
753
832
|
it("should throw an error if domain is missing", async () => {
|
|
754
|
-
zeroBounceSDK.init("valid-api-key");
|
|
755
|
-
await zeroBounceSDK.
|
|
833
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
834
|
+
await zeroBounceSDK.findEmailByDomain({domain: null});
|
|
756
835
|
expect(console.error).toHaveBeenCalledWith(
|
|
757
836
|
expect.stringContaining(missingParamMessage)
|
|
758
837
|
);
|
|
759
838
|
});
|
|
760
839
|
|
|
761
840
|
it("should return error response with invalid API key", async () => {
|
|
762
|
-
zeroBounceSDK.init("invalid-api-key");
|
|
841
|
+
zeroBounceSDK.init("invalid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
763
842
|
try {
|
|
764
|
-
await zeroBounceSDK.
|
|
843
|
+
await zeroBounceSDK.findEmailByDomain(payload);
|
|
765
844
|
} catch (error) {
|
|
766
845
|
expect(error.message).toEqual('TypeError: Network request failed');
|
|
767
846
|
}
|
|
@@ -770,10 +849,59 @@ describe("ZeroBounceSDK", () => {
|
|
|
770
849
|
it("should return the validated format data", async () => {
|
|
771
850
|
const expectedResponse = {
|
|
772
851
|
"email": "john.doe@example.com",
|
|
852
|
+
"email_confidence": "high",
|
|
853
|
+
"domain": "",
|
|
854
|
+
"company_name": "",
|
|
855
|
+
"did_you_mean": "",
|
|
856
|
+
"failure_reason": ""
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
jest.spyOn(global, "fetch").mockImplementationOnce(() => Promise.resolve({
|
|
860
|
+
json: () => Promise.resolve(expectedResponse),
|
|
861
|
+
text: () => Promise.resolve(JSON.stringify(expectedResponse)),
|
|
862
|
+
}));
|
|
863
|
+
|
|
864
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
865
|
+
const response = await zeroBounceSDK.findEmailByDomain(payload);
|
|
866
|
+
expect(response).toEqual(expectedResponse);
|
|
867
|
+
});
|
|
868
|
+
});
|
|
869
|
+
|
|
870
|
+
// DOMAIN SEARCH
|
|
871
|
+
describe("findEmailFormat", () => {
|
|
872
|
+
const payload = {
|
|
873
|
+
domain: "example.com",
|
|
874
|
+
first_name: "John",
|
|
875
|
+
last_name: "Doe",
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
it("should throw an error if not initialized", async () => {
|
|
879
|
+
await zeroBounceSDK.findEmailFormatByDomain(payload);
|
|
880
|
+
expect(console.error).toHaveBeenCalledWith(initErrorMessage);
|
|
881
|
+
});
|
|
882
|
+
|
|
883
|
+
it("should throw an error if domain is missing", async () => {
|
|
884
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
885
|
+
await zeroBounceSDK.findEmailFormatByDomain({domain: null});
|
|
886
|
+
expect(console.error).toHaveBeenCalledWith(
|
|
887
|
+
expect.stringContaining(missingParamMessage)
|
|
888
|
+
);
|
|
889
|
+
});
|
|
890
|
+
|
|
891
|
+
it("should return error response with invalid API key", async () => {
|
|
892
|
+
zeroBounceSDK.init("invalid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
893
|
+
try {
|
|
894
|
+
await zeroBounceSDK.findEmailFormatByDomain(payload);
|
|
895
|
+
} catch (error) {
|
|
896
|
+
expect(error.message).toEqual('TypeError: Network request failed');
|
|
897
|
+
}
|
|
898
|
+
});
|
|
899
|
+
|
|
900
|
+
it("should return the validated format data", async () => {
|
|
901
|
+
const expectedResponse = {
|
|
773
902
|
"domain": "",
|
|
903
|
+
"company_name": "",
|
|
774
904
|
"format": "first.last",
|
|
775
|
-
"status": "valid",
|
|
776
|
-
"sub_status": "",
|
|
777
905
|
"confidence": "high",
|
|
778
906
|
"did_you_mean": "",
|
|
779
907
|
"failure_reason": "",
|
|
@@ -785,8 +913,8 @@ describe("ZeroBounceSDK", () => {
|
|
|
785
913
|
text: () => Promise.resolve(JSON.stringify(expectedResponse)),
|
|
786
914
|
}));
|
|
787
915
|
|
|
788
|
-
zeroBounceSDK.init("valid-api-key");
|
|
789
|
-
const response = await zeroBounceSDK.
|
|
916
|
+
zeroBounceSDK.init("valid-api-key", ZeroBounceSDK.ApiURL.DEFAULT_API_URL);
|
|
917
|
+
const response = await zeroBounceSDK.findEmailFormatByDomain(payload);
|
|
790
918
|
expect(response).toEqual(expectedResponse);
|
|
791
919
|
});
|
|
792
920
|
});
|
package/dist/zeroBounceSDK.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(e,i){"object"==typeof exports&&"object"==typeof module?module.exports=i():"function"==typeof define&&define.amd?define([],i):"object"==typeof exports?exports.ZeroBounceSDK=i():e.ZeroBounceSDK=i()}(this,(()=>(()=>{"use strict";var e={d:(i,t)=>{for(var a in t)e.o(t,a)&&!e.o(i,a)&&Object.defineProperty(i,a,{enumerable:!0,get:t[a]})},o:(e,i)=>Object.prototype.hasOwnProperty.call(e,i)},i={};e.d(i,{default:()=>s});const t={Accept:"*/*","Accept-Encoding":"gzip, deflate, br",Connection:"keep-alive"};async function a({requestType:e,body:i=null,params:a=null,path:r,batch:n=!1,returnText:s=!1,scoring:l=!1}){const o=`${n?"https://bulkapi.zerobounce.net/v2":"https://api.zerobounce.net/v2"}${r}?${new URLSearchParams(a)}`;try{const a=await fetch(o,{method:e,headers:t,body:i});if(s){const e=await a.text();return e.includes('"success":"False"')?JSON.parse(e):function(e,i){if(!window.navigator.msSaveOrOpenBlob){const t=document.createElement("a");document.body.appendChild(t);const a=window.URL.createObjectURL(e);return t.href=a,t.download=i,t.click(),setTimeout((()=>{window.URL.revokeObjectURL(a),document.body.removeChild(t)}),0),i}window.navigator.msSaveOrOpenBlob(e,i)}(new Blob([e],{type:"application/json"}),`result${l?"-scoring":""}.csv`)}if(403===a.status)throw new Error("[Error]: api_key is invalid");return await a.json()}catch(e){throw new Error(e)}}function r(){console.error("ZeroBounce: Call init function first with a valid api key.")}function n(e,i=""){console.error(`ZeroBounce: ${e} parameter is missing. ${i}`)}const s=class{constructor(){this._initialized=!1,this._api_key=null}init(e){e?(this._api_key=e,this._initialized=!0):n("Api key","Please provide a valid API key.")}getCredits(){if(this._initialized)return a({requestType:"GET",params:{api_key:this._api_key},path:"/getcredits"});r()}validateEmail(e,i=null){if(this._initialized){if(e)return a({requestType:"GET",params:{api_key:this._api_key,email:e,ip_address:i},path:"/validate"});n("Email")}else r()}getApiUsage(e,i){if(this._initialized)if(e){if(i)return a({requestType:"GET",params:{api_key:this._api_key,start_date:e,end_date:i},path:"/getapiusage"});n("End date","Format: YYYY-MM-DD")}else n("Start date","Format: YYYY-MM-DD");else r()}validateBatch(e){if(!this._initialized)return void r();if(!e)return void n("Email list");const i={api_key:this._api_key,email_batch:e};return a({requestType:"POST",path:"/validatebatch",body:JSON.stringify(i),batch:!0})}getEmailActivity(e){if(this._initialized){if(e)return a({requestType:"GET",params:{api_key:this._api_key,email:e},path:"/activity"});n("Email")}else r()}sendFile({file:e,email_address_column:i,first_name_column:t=!1,return_url:s=!1,last_name_column:l=!1,gender_column:o=!1,ip_address_column:d=!1,has_header_row:p=!1,remove_duplicate:u=!1}){if(!this._initialized)return void r();if(!e)return void n("file");if(!i)return void n("email_address_column");const _=new FormData;return s&&_.append("return_url",s),t&&_.append("first_name_column",t),l&&_.append("last_name_column",l),o&&_.append("gender_column",o),d&&_.append("ip_address_column",d),_.append("email_address_column",i),_.append("file",e),_.append("has_header_row",p),_.append("remove_duplicate",u),_.append("api_key",this._api_key),a({requestType:"POST",path:"/sendfile",body:_,batch:!0})}sendScoringFile({file:e,email_address_column:i,return_url:t=!1,has_header_row:s=!1,remove_duplicate:l=!1}){if(!this._initialized)return void r();if(!e)return void n("file: File");if(!i)return void n("email_address_column: number");const o=new FormData;return t&&o.append("return_url",t),o.append("file",e),o.append("email_address_column",i),o.append("has_header_row",s),o.append("api_key",this._api_key),o.append("remove_duplicate",l),a({requestType:"POST",path:"/scoring/sendfile",body:o,batch:!0})}_getStatusUtil(e,i){if(this._initialized){if(e)return a({requestType:"GET",params:{api_key:this._api_key,file_id:e},path:i,batch:!0});n("File id")}else r()}getFileStatus(e){return this._getStatusUtil(e,"/filestatus")}getScoringFileStatus(e){return this._getStatusUtil(e,"/scoring/filestatus")}_getFileUtil(e,i,t=!1){if(this._initialized){if(e)return a({requestType:"GET",params:{api_key:this._api_key,file_id:e},path:i,batch:!0,returnText:!0,scoring:t});n("File id")}else r()}getFile(e){return this._getFileUtil(e,"/getfile")}getScoringFile(e){return this._getFileUtil(e,"/scoring/getfile",!0)}_deleteFileUtil(e,i,t=!1){if(this._initialized){if(e)return a({requestType:"GET",params:{api_key:this._api_key,file_id:e},path:i,batch:!0,scoring:t});n("File id")}else r()}deleteFile(e){return this._deleteFileUtil(e,"/deletefile")}deleteScoringFile(e){return this._deleteFileUtil(e,"/scoring/deletefile",!0)}guessFormat({domain:e,first_name:i=null,middle_name:t=null,last_name:s=null}){if(this._initialized){if(e)return a({requestType:"GET",params:{api_key:this._api_key,domain:e,first_name:i,middle_name:t,last_name:s},path:"/guessformat"});n("domain")}else r()}};return i.default})()));
|