@zerobounce/zero-bounce-sdk 1.0.0 → 1.1.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 +30 -1
- package/documentation.md +333 -0
- package/documentation_es.md +309 -0
- package/jest.config.js +5 -4
- package/package.json +4 -2
- package/src/utils.js +6 -2
- package/src/zero-bounce.js +31 -0
- package/tests/zero-bounce.test.js +125 -79
- package/README_es.md +0 -317
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
[ZeroBounce](https://www.zerobounce.net>) JavaScript API v2
|
|
2
2
|
|
|
3
|
+
## WE DO NOT RECOMMEND USING THIS SDK ON A FRONT-END ENVIRONMENT AS THE API KEY WILL BE VISIBLE
|
|
4
|
+
|
|
3
5
|
This is a JavaScript wrapper class for the ZeroBounce API v2.
|
|
4
6
|
|
|
5
7
|
## INSTALLATION
|
|
@@ -250,6 +252,33 @@ try {
|
|
|
250
252
|
console.error(error);
|
|
251
253
|
}
|
|
252
254
|
```
|
|
255
|
+
- ##### Email finder - Test a variety of patterns and combinations in real time until it identifies a valid business email.
|
|
256
|
+
|
|
257
|
+
```javascript
|
|
258
|
+
// Parameters
|
|
259
|
+
// ----------
|
|
260
|
+
// domain: String
|
|
261
|
+
// The email domain for which to find the email format.
|
|
262
|
+
// first_name: String or null (Optional)
|
|
263
|
+
// The first name of the person whose email format is being searched.
|
|
264
|
+
// middle_name: String or null (Optional)
|
|
265
|
+
// The middle name of the person whose email format is being searched.
|
|
266
|
+
// last_name: String or null (Optional)
|
|
267
|
+
// The last name of the person whose email format is being searched.
|
|
268
|
+
|
|
269
|
+
const payload = {
|
|
270
|
+
domain: "<DOMAIN>",
|
|
271
|
+
first_name: "<FIRST_NAME>",
|
|
272
|
+
middle_name: "<MIDDLE_NAME>",
|
|
273
|
+
last_name: "<LAST_NAME>"
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
try {
|
|
277
|
+
const response = await zeroBounce.guessFormat(payload);
|
|
278
|
+
} catch (error) {
|
|
279
|
+
console.error(error);
|
|
280
|
+
}
|
|
281
|
+
```
|
|
253
282
|
|
|
254
283
|
**Any of the following email addresses can be used for testing the API, no credits are charged for these test email addresses:**
|
|
255
284
|
|
|
@@ -299,7 +328,7 @@ You should see an output like this
|
|
|
299
328
|
|
|
300
329
|
```bash
|
|
301
330
|
Test Suites: 1 passed, 1 total
|
|
302
|
-
Tests:
|
|
331
|
+
Tests: 58 passed, 58 total
|
|
303
332
|
Snapshots: 0 total
|
|
304
333
|
Time: 2.596 s, estimated 3 s
|
|
305
334
|
Ran all test suites.
|
package/documentation.md
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
|
|
2
|
+
WE DO NOT RECOMMEND USING THIS SDK ON A FRONT-END ENVIRONMENT AS THE API KEY WILL BE VISIBLE
|
|
3
|
+
|
|
4
|
+
#### INSTALLATION
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install @zerobounce/zero-bounce-sdk
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
#### USAGE
|
|
11
|
+
|
|
12
|
+
Add the script
|
|
13
|
+
|
|
14
|
+
```HTML
|
|
15
|
+
<script src="<PATH_TO_SCRIPT/zeroBounceSDK.js"></script>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```HTML
|
|
19
|
+
<script>
|
|
20
|
+
const zeroBounce = new ZeroBounceSDK();
|
|
21
|
+
</script>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
OR
|
|
25
|
+
|
|
26
|
+
Add npm module
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
const ZeroBounceSDK = require('@zerobounce/zero-bounce-sdk')
|
|
30
|
+
|
|
31
|
+
const zeroBounce = new ZeroBounceSDK();
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Initialize the sdk with your api key:
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
zeroBounce.init("<YOUR_API_KEY>");
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
NOTE: all the methods are asynchronous they have to be used with async / await or .then.catch
|
|
41
|
+
|
|
42
|
+
#### Examples
|
|
43
|
+
|
|
44
|
+
Then you can use any of the SDK methods, for example:
|
|
45
|
+
|
|
46
|
+
- ####### Check how many credits you have left on your account
|
|
47
|
+
|
|
48
|
+
```javascript
|
|
49
|
+
try {
|
|
50
|
+
const response = await zeroBounce.getCredits();
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error(error);
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
- ####### Validate an email address
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
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
|
+
|
|
62
|
+
try {
|
|
63
|
+
const response = await zeroBounce.validateEmail(email, ip_address);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error(error);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- ####### Get api usage from a start date to an end date
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
const startDate = "2018-01-01"; // The start date of when you want to view API usage
|
|
73
|
+
const endDate = "2023-12-12"; // The end date of when you want to view API usage
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
const response = await zeroBounce.getApiUsage(startDate, endDate);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.error(error);
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
- ####### Validate a list of emails
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
const emailBatch = [
|
|
86
|
+
{ email_address: "<EMAIL_ADDRESS>" },
|
|
87
|
+
{ email_address: "<EMAIL_ADDRESS>" },
|
|
88
|
+
]; // an array containing a list of email objects {email_address: "example@example.com"}
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
const response = await zeroBounce.validateBatch(emailBatch);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.error(error);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
- ####### Get data about an email activity
|
|
98
|
+
|
|
99
|
+
```javascript
|
|
100
|
+
const email = "<EMAIL_ADDRESS>"; // The email address you want to get the activity for
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
const response = await zeroBounce.getEmailActivity(email);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
console.error(error);
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
- ####### Send a csv file containing email addresses to be validated
|
|
110
|
+
|
|
111
|
+
```javascript
|
|
112
|
+
// Parameters
|
|
113
|
+
// ----------
|
|
114
|
+
// file: File
|
|
115
|
+
// The csv or txt file to be submitted.
|
|
116
|
+
// email_address_column: number
|
|
117
|
+
// The column index of the email address in the file. Index starts from 1.
|
|
118
|
+
// return_url: str or null (Optional)
|
|
119
|
+
// The URL will be used to call back when the validation is completed.
|
|
120
|
+
// first_name_column: number or null (Optional)
|
|
121
|
+
// The column index of the first name column.
|
|
122
|
+
// last_name_column: number or null (Optional)
|
|
123
|
+
// The column index of the last name column.
|
|
124
|
+
// gender_column: number or null (Optional)
|
|
125
|
+
// The column index of the gender column.
|
|
126
|
+
// ip_address_column: number or null (Optional)
|
|
127
|
+
// The IP Address the email signed up from.
|
|
128
|
+
// has_header_row: Boolean (Optional)
|
|
129
|
+
// If the first row from the submitted file is a header row.
|
|
130
|
+
// remove_duplicate: Boolean (Optional)
|
|
131
|
+
// If you want the system to remove duplicate emails.
|
|
132
|
+
const payload = {
|
|
133
|
+
file: "<FILE>",
|
|
134
|
+
email_address_column: "<NUMBER_OF_COLUMN>", //example 3
|
|
135
|
+
return_url: "<RETURN_URL>", // (Optional)
|
|
136
|
+
first_name_column: "<NUMBER_OF_COLUMN>", //example 3 (Optional)
|
|
137
|
+
last_name_column: "<NUMBER_OF_COLUMN>", //example 3 (Optional)
|
|
138
|
+
gender_column: "<NUMBER_OF_COLUMN>", //example 3 (Optional)
|
|
139
|
+
ip_address_column: "<NUMBER_OF_COLUMN>", //example 3 (Optional)
|
|
140
|
+
has_header_row: true / false, // (Optional)
|
|
141
|
+
remove_duplicate: true / false, // (Optional)
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
try {
|
|
145
|
+
const response = await zeroBounce.sendFile(payload);
|
|
146
|
+
} catch (error) {
|
|
147
|
+
console.error(error);
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
- ####### Send a csv file containing email addresses to get the scoring of the emails
|
|
152
|
+
|
|
153
|
+
```javascript
|
|
154
|
+
// Parameters
|
|
155
|
+
// ----------
|
|
156
|
+
// file: File
|
|
157
|
+
// The csv or txt file to be submitted.
|
|
158
|
+
// email_address_column: number
|
|
159
|
+
// The column index of the email address in the file. Index starts from 1.
|
|
160
|
+
// return_url: str or null (Optional)
|
|
161
|
+
// The URL will be used to call back when the validation is completed.
|
|
162
|
+
// has_header_row: Boolean (Optional)
|
|
163
|
+
// If the first row from the submitted file is a header row.
|
|
164
|
+
// remove_duplicate: Boolean (Optional)
|
|
165
|
+
// If you want the system to remove duplicate emails.
|
|
166
|
+
const payload = {
|
|
167
|
+
file: "<FILE>",
|
|
168
|
+
email_address_column: "<NUMBER_OF_COLUMN>", //example 3
|
|
169
|
+
return_url: "<RETURN_URL>", // (Optional)
|
|
170
|
+
has_header_row: true / false,
|
|
171
|
+
remove_duplicate: true / false, // (Optional)
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
try {
|
|
175
|
+
const response = await zeroBounce.sendScoringFile(payload);
|
|
176
|
+
} catch (error) {
|
|
177
|
+
console.error(error);
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
- ####### The completion status of a previously sent file
|
|
182
|
+
|
|
183
|
+
```javascript
|
|
184
|
+
const fileId = "<FILE_ID>"; // The id of a previously sent file
|
|
185
|
+
|
|
186
|
+
try {
|
|
187
|
+
const response = await zeroBounce.getFileStatus(fileId);
|
|
188
|
+
} catch (error) {
|
|
189
|
+
console.error(error);
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
- ####### The completion status of a previously sent scoring file
|
|
194
|
+
|
|
195
|
+
```javascript
|
|
196
|
+
const fileId = "<FILE_ID>"; // The id of a previously sent file
|
|
197
|
+
|
|
198
|
+
try {
|
|
199
|
+
const response = await zeroBounce.getScoringFileStatus(fileId);
|
|
200
|
+
} catch (error) {
|
|
201
|
+
console.error(error);
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
- ####### Get the file with the validated data
|
|
206
|
+
|
|
207
|
+
```javascript
|
|
208
|
+
const fileId = "<FILE_ID>"; // The id of a previously sent file
|
|
209
|
+
|
|
210
|
+
try {
|
|
211
|
+
const response = await zeroBounce.getFile(fileId);
|
|
212
|
+
} catch (error) {
|
|
213
|
+
console.error(error);
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
- ####### Get the file with the scoring data
|
|
218
|
+
|
|
219
|
+
```javascript
|
|
220
|
+
const fileId = "<FILE_ID>"; // The id of a previously sent file
|
|
221
|
+
|
|
222
|
+
try {
|
|
223
|
+
const response = await zeroBounce.getScoringFile(fileId);
|
|
224
|
+
} catch (error) {
|
|
225
|
+
console.error(error);
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
- ####### Delete the file with the validated data
|
|
230
|
+
|
|
231
|
+
```javascript
|
|
232
|
+
const fileId = "<FILE_ID>"; // The id of a previously sent file
|
|
233
|
+
|
|
234
|
+
try {
|
|
235
|
+
const response = await zeroBounce.deleteFile(fileId);
|
|
236
|
+
} catch (error) {
|
|
237
|
+
console.error(error);
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
- ####### Delete the file with the scoring data
|
|
242
|
+
|
|
243
|
+
```javascript
|
|
244
|
+
const fileId = "<FILE_ID>"; // The id of a previously sent file
|
|
245
|
+
|
|
246
|
+
try {
|
|
247
|
+
const response = await zeroBounce.deleteScoringFile(fileId);
|
|
248
|
+
} catch (error) {
|
|
249
|
+
console.error(error);
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
- ####### Email finder - Test a variety of patterns and combinations in real time until it identifies a valid business email.
|
|
254
|
+
|
|
255
|
+
```javascript
|
|
256
|
+
// Parameters
|
|
257
|
+
// ----------
|
|
258
|
+
// domain: String
|
|
259
|
+
// The email domain for which to find the email format.
|
|
260
|
+
// first_name: String or null (Optional)
|
|
261
|
+
// The first name of the person whose email format is being searched.
|
|
262
|
+
// middle_name: String or null (Optional)
|
|
263
|
+
// The middle name of the person whose email format is being searched.
|
|
264
|
+
// last_name: String or null (Optional)
|
|
265
|
+
// The last name of the person whose email format is being searched.
|
|
266
|
+
|
|
267
|
+
const payload = {
|
|
268
|
+
domain: "<DOMAIN>",
|
|
269
|
+
first_name: "<FIRST_NAME>",
|
|
270
|
+
middle_name: "<MIDDLE_NAME>",
|
|
271
|
+
last_name: "<LAST_NAME>"
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
try {
|
|
275
|
+
const response = await zeroBounce.guessFormat(payload);
|
|
276
|
+
} catch (error) {
|
|
277
|
+
console.error(error);
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
**Any of the following email addresses can be used for testing the API, no credits are charged for these test email addresses:**
|
|
282
|
+
|
|
283
|
+
- disposable@example.com
|
|
284
|
+
- invalid@example.com
|
|
285
|
+
- valid@example.com
|
|
286
|
+
- toxic@example.com
|
|
287
|
+
- donotmail@example.com
|
|
288
|
+
- spamtrap@example.com
|
|
289
|
+
- abuse@example.com
|
|
290
|
+
- unknown@example.com
|
|
291
|
+
- catch_all@example.com
|
|
292
|
+
- antispam_system@example.com
|
|
293
|
+
- does_not_accept_mail@example.com
|
|
294
|
+
- exception_occurred@example.com
|
|
295
|
+
- failed_smtp_connection@example.com
|
|
296
|
+
- failed_syntax_check@example.com
|
|
297
|
+
- forcible_disconnect@example.com
|
|
298
|
+
- global_suppression@example.com
|
|
299
|
+
- greylisted@example.com
|
|
300
|
+
- leading_period_removed@example.com
|
|
301
|
+
- mail_server_did_not_respond@example.com
|
|
302
|
+
- mail_server_temporary_error@example.com
|
|
303
|
+
- mailbox_quota_exceeded@example.com
|
|
304
|
+
- mailbox_not_found@example.com
|
|
305
|
+
- no_dns_entries@example.com
|
|
306
|
+
- possible_trap@example.com
|
|
307
|
+
- possible_typo@example.com
|
|
308
|
+
- role_based@example.com
|
|
309
|
+
- timeout_exceeded@example.com
|
|
310
|
+
- unroutable_ip_address@example.com
|
|
311
|
+
- free_email@example.com
|
|
312
|
+
|
|
313
|
+
**You can use this IP to test the GEO Location in the API.**
|
|
314
|
+
|
|
315
|
+
- 99.110.204.1
|
|
316
|
+
|
|
317
|
+
#### Development
|
|
318
|
+
|
|
319
|
+
After checking out the repo run tests
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
npm test
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
You should see an output like this
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
Test Suites: 1 passed, 1 total
|
|
329
|
+
Tests: 54 passed, 54 total
|
|
330
|
+
Snapshots: 0 total
|
|
331
|
+
Time: 2.596 s, estimated 3 s
|
|
332
|
+
Ran all test suites.
|
|
333
|
+
```
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
|
|
2
|
+
NO RECOMENDAMOS USAR ESTE KIT DE DESARROLLO EN UN ENTORNO DE FRONT-END, YA QUE LA CLAVE DE API SERÁ VISIBLE.
|
|
3
|
+
|
|
4
|
+
#### INSTALACIÓN
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install @zerobounce/zero-bounce-sdk
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
#### USO
|
|
11
|
+
|
|
12
|
+
Agregue el script
|
|
13
|
+
|
|
14
|
+
```HTML
|
|
15
|
+
<script src="<RUTA_AL_SCRIPT/zeroBounceSDK.js"></script>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```HTML
|
|
19
|
+
<script>
|
|
20
|
+
const zeroBounce = new ZeroBounceSDK();
|
|
21
|
+
</script>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
O
|
|
25
|
+
|
|
26
|
+
Agregue el módulo npm
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
const ZeroBounceSDK = require('zero-bounce-sdk')
|
|
30
|
+
|
|
31
|
+
const zeroBounce = new ZeroBounceSDK();
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Inicialice el SDK con su clave de API:
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
zeroBounce.init("<SU_CLAVE_DE_API>");
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
NOTA: todos los métodos son asíncronos y deben usarse con async / await o .then.catch.
|
|
41
|
+
|
|
42
|
+
#### Ejemplos
|
|
43
|
+
|
|
44
|
+
Luego puede utilizar cualquiera de los métodos del SDK, por ejemplo:
|
|
45
|
+
|
|
46
|
+
- ####### Verificar cuántos créditos le quedan en su cuenta
|
|
47
|
+
|
|
48
|
+
```javascript
|
|
49
|
+
try {
|
|
50
|
+
const response = await zeroBounce.getCredits();
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error(error);
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
- ####### Validar una dirección de correo electrónico
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
const email = "<DIRECCIÓN_DE_CORREO_ELECTRÓNICO>"; // La dirección de correo electrónico que desea validar
|
|
60
|
+
const ip_address = "127.0.0.1"; // La dirección IP desde la cual se registró el correo electrónico (opcional)
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
const response = await zeroBounce.validateEmail(email, ip_address);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error(error);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- ####### Obtener el uso de la API desde una fecha de inicio hasta una fecha de finalización
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
const startDate = "2018-01-01"; // La fecha de inicio de cuando desea ver el uso de la API
|
|
73
|
+
const endDate = "2023-12-12"; // La fecha de finalización de cuando desea ver el uso de la API
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
const response = await zeroBounce.getApiUsage(startDate, endDate);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.error(error);
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
- ####### Validar una lista de direcciones de correo electrónico
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
const emailBatch = [
|
|
86
|
+
{ email_address: "<DIRECCIÓN_DE_CORREO_ELECTRÓNICO>" },
|
|
87
|
+
{ email_address: "<DIRECCIÓN_DE_CORREO_ELECTRÓNICO>" },
|
|
88
|
+
]; // un array que contiene una lista de objetos de correo electrónico {email_address: "ejemplo@ejemplo.com"}
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
const response = await zeroBounce.validateBatch(emailBatch);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.error(error);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
- ####### Obtener datos sobre la actividad de un correo electrónico
|
|
98
|
+
|
|
99
|
+
```javascript
|
|
100
|
+
const email = "<DIRECCIÓN_DE_CORREO_ELECTRÓNICO>"; // La dirección de correo electrónico de la que desea obtener la actividad
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
const response = await zeroBounce.getEmailActivity(email);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
console.error(error);
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
- ####### Enviar un archivo CSV que contenga direcciones de correo electrónico para validar
|
|
110
|
+
|
|
111
|
+
```javascript
|
|
112
|
+
// Parámetros
|
|
113
|
+
// ----------
|
|
114
|
+
// file: File
|
|
115
|
+
// El archivo CSV o TXT que se enviará.
|
|
116
|
+
// email_address_column: number
|
|
117
|
+
// El índice de columna de la dirección de correo electrónico en el archivo. El índice comienza en 1.
|
|
118
|
+
// return_url: str o null (Opcional)
|
|
119
|
+
// La URL se utilizará para llamar de vuelta cuando
|
|
120
|
+
|
|
121
|
+
se complete la validación.
|
|
122
|
+
// first_name_column: number o null (Opcional)
|
|
123
|
+
// El índice de columna del nombre en el archivo.
|
|
124
|
+
// last_name_column: number o null (Opcional)
|
|
125
|
+
// El índice de columna del apellido en el archivo.
|
|
126
|
+
// gender_column: number o null (Opcional)
|
|
127
|
+
// El índice de columna del género en el archivo.
|
|
128
|
+
// ip_address_column: number o null (Opcional)
|
|
129
|
+
// La dirección IP desde la cual se registró el correo electrónico.
|
|
130
|
+
// has_header_row: Boolean (Opcional)
|
|
131
|
+
// Si la primera fila del archivo enviado es una fila de encabezado.
|
|
132
|
+
// remove_duplicate: Boolean (Opcional)
|
|
133
|
+
// Si desea que el sistema elimine los correos electrónicos duplicados.
|
|
134
|
+
const payload = {
|
|
135
|
+
file: "<ARCHIVO>",
|
|
136
|
+
email_address_column: "<NÚMERO_DE_COLUMNA>", // por ejemplo, 3
|
|
137
|
+
return_url: "<URL_DE_RETORNO>", // (Opcional)
|
|
138
|
+
first_name_column: "<NÚMERO_DE_COLUMNA>", // por ejemplo, 3 (Opcional)
|
|
139
|
+
last_name_column: "<NÚMERO_DE_COLUMNA>", // por ejemplo, 3 (Opcional)
|
|
140
|
+
gender_column: "<NÚMERO_DE_COLUMNA>", // por ejemplo, 3 (Opcional)
|
|
141
|
+
ip_address_column: "<NÚMERO_DE_COLUMNA>", // por ejemplo, 3 (Opcional)
|
|
142
|
+
has_header_row: true / false, // (Opcional)
|
|
143
|
+
remove_duplicate: true / false, // (Opcional)
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
try {
|
|
147
|
+
const response = await zeroBounce.sendFile(payload);
|
|
148
|
+
} catch (error) {
|
|
149
|
+
console.error(error);
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
- ####### Enviar un archivo CSV que contenga direcciones de correo electrónico para obtener la puntuación de los correos electrónicos
|
|
154
|
+
|
|
155
|
+
```javascript
|
|
156
|
+
// Parámetros
|
|
157
|
+
// ----------
|
|
158
|
+
// file: File
|
|
159
|
+
// El archivo CSV o TXT que se enviará.
|
|
160
|
+
// email_address_column: number
|
|
161
|
+
// El índice de columna de la dirección de correo electrónico en el archivo. El índice comienza en 1.
|
|
162
|
+
// return_url: str o null (Opcional)
|
|
163
|
+
// La URL se utilizará para llamar de vuelta cuando se complete la validación.
|
|
164
|
+
// has_header_row: Boolean (Opcional)
|
|
165
|
+
// Si la primera fila del archivo enviado es una fila de encabezado.
|
|
166
|
+
// remove_duplicate: Boolean (Opcional)
|
|
167
|
+
// Si desea que el sistema elimine los correos electrónicos duplicados.
|
|
168
|
+
const payload = {
|
|
169
|
+
file: "<ARCHIVO>",
|
|
170
|
+
email_address_column: "<NÚMERO_DE_COLUMNA>", // por ejemplo, 3
|
|
171
|
+
return_url: "<URL_DE_RETORNO>", // (Opcional)
|
|
172
|
+
has_header_row: true / false,
|
|
173
|
+
remove_duplicate: true / false, // (Opcional)
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
try {
|
|
177
|
+
const response = await zeroBounce.sendScoringFile(payload);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
console.error(error);
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
- ####### El estado de finalización de un archivo enviado anteriormente
|
|
184
|
+
|
|
185
|
+
```javascript
|
|
186
|
+
const fileId = "<ID_DE_ARCHIVO>"; // El ID de un archivo enviado anteriormente
|
|
187
|
+
|
|
188
|
+
try {
|
|
189
|
+
const response = await zeroBounce.getFileStatus(fileId);
|
|
190
|
+
} catch (error) {
|
|
191
|
+
console.error(error);
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
- ####### El estado de finalización de un archivo de puntuación enviado anteriormente
|
|
196
|
+
|
|
197
|
+
```javascript
|
|
198
|
+
const fileId = "<ID_DE_ARCHIVO>"; // El ID de un archivo enviado anteriormente
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
try {
|
|
203
|
+
const response = await zeroBounce.getScoringFileStatus(fileId);
|
|
204
|
+
} catch (error) {
|
|
205
|
+
console.error(error);
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
- ####### Obtener el archivo con los datos validados
|
|
210
|
+
|
|
211
|
+
```javascript
|
|
212
|
+
const fileId = "<ID_DE_ARCHIVO>"; // El ID de un archivo enviado anteriormente
|
|
213
|
+
|
|
214
|
+
try {
|
|
215
|
+
const response = await zeroBounce.getFile(fileId);
|
|
216
|
+
} catch (error) {
|
|
217
|
+
console.error(error);
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
- ####### Obtener el archivo con los datos de puntuación
|
|
222
|
+
|
|
223
|
+
```javascript
|
|
224
|
+
const fileId = "<ID_DE_ARCHIVO>"; // El ID de un archivo enviado anteriormente
|
|
225
|
+
|
|
226
|
+
try {
|
|
227
|
+
const response = await zeroBounce.getScoringFile(fileId);
|
|
228
|
+
} catch (error) {
|
|
229
|
+
console.error(error);
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
- ####### Eliminar el archivo con los datos validados
|
|
234
|
+
|
|
235
|
+
```javascript
|
|
236
|
+
const fileId = "<ID_DE_ARCHIVO>"; // El ID de un archivo enviado anteriormente
|
|
237
|
+
|
|
238
|
+
try {
|
|
239
|
+
const response = await zeroBounce.deleteFile(fileId);
|
|
240
|
+
} catch (error) {
|
|
241
|
+
console.error(error);
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
- ####### Eliminar el archivo con los datos de puntuación
|
|
246
|
+
|
|
247
|
+
```javascript
|
|
248
|
+
const fileId = "<ID_DE_ARCHIVO>"; // El ID de un archivo enviado anteriormente
|
|
249
|
+
|
|
250
|
+
try {
|
|
251
|
+
const response = await zeroBounce.deleteScoringFile(fileId);
|
|
252
|
+
} catch (error) {
|
|
253
|
+
console.error(error);
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**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
|
+
|
|
259
|
+
- disposable@example.com
|
|
260
|
+
- invalid@example.com
|
|
261
|
+
- valid@example.com
|
|
262
|
+
- toxic@example.com
|
|
263
|
+
- donotmail@example.com
|
|
264
|
+
- spamtrap@example.com
|
|
265
|
+
- abuse@example.com
|
|
266
|
+
- unknown@example.com
|
|
267
|
+
- catch_all@example.com
|
|
268
|
+
- antispam_system@example.com
|
|
269
|
+
- does_not_accept_mail@example.com
|
|
270
|
+
- exception_occurred@example.com
|
|
271
|
+
- failed_smtp_connection@example.com
|
|
272
|
+
- failed_syntax_check@example.com
|
|
273
|
+
- forcible_disconnect@example.com
|
|
274
|
+
- global_suppression@example.com
|
|
275
|
+
- greylisted@example.com
|
|
276
|
+
- leading_period_removed@example.com
|
|
277
|
+
- mail_server_did_not_respond@example.com
|
|
278
|
+
- mail_server_temporary_error@example.com
|
|
279
|
+
- mailbox_quota_exceeded@example.com
|
|
280
|
+
- mailbox_not_found@example.com
|
|
281
|
+
- no_dns_entries@example.com
|
|
282
|
+
- possible_trap@example.com
|
|
283
|
+
- possible_typo@example.com
|
|
284
|
+
- role_based@example.com
|
|
285
|
+
- timeout_exceeded@example.com
|
|
286
|
+
- unroutable_ip_address@example.com
|
|
287
|
+
- free_email@example.com
|
|
288
|
+
|
|
289
|
+
**Puede utilizar esta dirección IP para probar la ubicación geográfica en la API.**
|
|
290
|
+
|
|
291
|
+
- 99.110.204.1
|
|
292
|
+
|
|
293
|
+
#### Desarrollo
|
|
294
|
+
|
|
295
|
+
Después de verificar el repositorio, ejecute las pruebas
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
npm test
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
Debería ver una salida como esta
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
Test Suites: 1 passed, 1 total
|
|
305
|
+
Tests: 54 passed, 54 total
|
|
306
|
+
Snapshots: 0 total
|
|
307
|
+
Time: 2.596 s, estimated 3 s
|
|
308
|
+
Ran all test suites.
|
|
309
|
+
```
|
package/jest.config.js
CHANGED