@zerobounce/zero-bounce-sdk 1.0.0

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 ADDED
@@ -0,0 +1,306 @@
1
+ [ZeroBounce](https://www.zerobounce.net>) JavaScript API v2
2
+
3
+ This is a JavaScript wrapper class for the ZeroBounce API v2.
4
+
5
+ ## INSTALLATION
6
+
7
+ ```bash
8
+ npm install @zerobounce/zero-bounce-sdk
9
+ ```
10
+
11
+ ## USAGE
12
+
13
+ Add the script
14
+
15
+ ```HTML
16
+ <script src="<PATH_TO_SCRIPT/zeroBounceSDK.js"></script>
17
+ ```
18
+
19
+ ```HTML
20
+ <script>
21
+ const zeroBounce = new ZeroBounceSDK();
22
+ </script>
23
+ ```
24
+
25
+ OR
26
+
27
+ Add npm module
28
+
29
+ ```javascript
30
+ const ZeroBounceSDK = require('@zerobounce/zero-bounce-sdk')
31
+
32
+ const zeroBounce = new ZeroBounceSDK();
33
+ ```
34
+
35
+ Initialize the sdk with your api key:
36
+
37
+ ```javascript
38
+ zeroBounce.init("<YOUR_API_KEY>");
39
+ ```
40
+
41
+ NOTE: all the methods are asynchronous they have to be used with async / await or .then.catch
42
+
43
+ ## Examples
44
+
45
+ Then you can use any of the SDK methods, for example:
46
+
47
+ - ##### Check how many credits you have left on your account
48
+
49
+ ```javascript
50
+ try {
51
+ const response = await zeroBounce.getCredits();
52
+ } catch (error) {
53
+ console.error(error);
54
+ }
55
+ ```
56
+
57
+ - ##### Validate an email address
58
+
59
+ ```javascript
60
+ const email = "<EMAIL_ADDRESS>"; // The email address you want to validate
61
+ const ip_address = "127.0.0.1"; // The IP Address the email signed up from (Optional)
62
+
63
+ try {
64
+ const response = await zeroBounce.validateEmail(email, ip_address);
65
+ } catch (error) {
66
+ console.error(error);
67
+ }
68
+ ```
69
+
70
+ - ##### Get api usage from a start date to an end date
71
+
72
+ ```javascript
73
+ const startDate = "2018-01-01"; // The start date of when you want to view API usage
74
+ const endDate = "2023-12-12"; // The end date of when you want to view API usage
75
+
76
+ try {
77
+ const response = await zeroBounce.getApiUsage(startDate, endDate);
78
+ } catch (error) {
79
+ console.error(error);
80
+ }
81
+ ```
82
+
83
+ - ##### Validate a list of emails
84
+
85
+ ```javascript
86
+ const emailBatch = [
87
+ { email_address: "<EMAIL_ADDRESS>" },
88
+ { email_address: "<EMAIL_ADDRESS>" },
89
+ ]; // an array containing a list of email objects {email_address: "example@example.com"}
90
+
91
+ try {
92
+ const response = await zeroBounce.validateBatch(emailBatch);
93
+ } catch (error) {
94
+ console.error(error);
95
+ }
96
+ ```
97
+
98
+ - ##### Get data about an email activity
99
+
100
+ ```javascript
101
+ const email = "<EMAIL_ADDRESS>"; // The email address you want to get the activity for
102
+
103
+ try {
104
+ const response = await zeroBounce.getEmailActivity(email);
105
+ } catch (error) {
106
+ console.error(error);
107
+ }
108
+ ```
109
+
110
+ - ##### Send a csv file containing email addresses to be validated
111
+
112
+ ```javascript
113
+ // Parameters
114
+ // ----------
115
+ // file: File
116
+ // The csv or txt file to be submitted.
117
+ // email_address_column: number
118
+ // The column index of the email address in the file. Index starts from 1.
119
+ // return_url: str or null (Optional)
120
+ // The URL will be used to call back when the validation is completed.
121
+ // first_name_column: number or null (Optional)
122
+ // The column index of the first name column.
123
+ // last_name_column: number or null (Optional)
124
+ // The column index of the last name column.
125
+ // gender_column: number or null (Optional)
126
+ // The column index of the gender column.
127
+ // ip_address_column: number or null (Optional)
128
+ // The IP Address the email signed up from.
129
+ // has_header_row: Boolean (Optional)
130
+ // If the first row from the submitted file is a header row.
131
+ // remove_duplicate: Boolean (Optional)
132
+ // If you want the system to remove duplicate emails.
133
+ const payload = {
134
+ file: "<FILE>",
135
+ email_address_column: "<NUMBER_OF_COLUMN>", //example 3
136
+ return_url: "<RETURN_URL>", // (Optional)
137
+ first_name_column: "<NUMBER_OF_COLUMN>", //example 3 (Optional)
138
+ last_name_column: "<NUMBER_OF_COLUMN>", //example 3 (Optional)
139
+ gender_column: "<NUMBER_OF_COLUMN>", //example 3 (Optional)
140
+ ip_address_column: "<NUMBER_OF_COLUMN>", //example 3 (Optional)
141
+ has_header_row: true / false, // (Optional)
142
+ remove_duplicate: true / false, // (Optional)
143
+ };
144
+
145
+ try {
146
+ const response = await zeroBounce.sendFile(payload);
147
+ } catch (error) {
148
+ console.error(error);
149
+ }
150
+ ```
151
+
152
+ - ##### Send a csv file containing email addresses to get the scoring of the emails
153
+
154
+ ```javascript
155
+ // Parameters
156
+ // ----------
157
+ // file: File
158
+ // The csv or txt file to be submitted.
159
+ // email_address_column: number
160
+ // The column index of the email address in the file. Index starts from 1.
161
+ // return_url: str or null (Optional)
162
+ // The URL will be used to call back when the validation is completed.
163
+ // has_header_row: Boolean (Optional)
164
+ // If the first row from the submitted file is a header row.
165
+ // remove_duplicate: Boolean (Optional)
166
+ // If you want the system to remove duplicate emails.
167
+ const payload = {
168
+ file: "<FILE>",
169
+ email_address_column: "<NUMBER_OF_COLUMN>", //example 3
170
+ return_url: "<RETURN_URL>", // (Optional)
171
+ has_header_row: true / false,
172
+ remove_duplicate: true / false, // (Optional)
173
+ };
174
+
175
+ try {
176
+ const response = await zeroBounce.sendScoringFile(payload);
177
+ } catch (error) {
178
+ console.error(error);
179
+ }
180
+ ```
181
+
182
+ - ##### The completion status of a previously sent file
183
+
184
+ ```javascript
185
+ const fileId = "<FILE_ID>"; // The id of a previously sent file
186
+
187
+ try {
188
+ const response = await zeroBounce.getFileStatus(fileId);
189
+ } catch (error) {
190
+ console.error(error);
191
+ }
192
+ ```
193
+
194
+ - ##### The completion status of a previously sent scoring file
195
+
196
+ ```javascript
197
+ const fileId = "<FILE_ID>"; // The id of a previously sent file
198
+
199
+ try {
200
+ const response = await zeroBounce.getScoringFileStatus(fileId);
201
+ } catch (error) {
202
+ console.error(error);
203
+ }
204
+ ```
205
+
206
+ - ##### Get the file with the validated data
207
+
208
+ ```javascript
209
+ const fileId = "<FILE_ID>"; // The id of a previously sent file
210
+
211
+ try {
212
+ const response = await zeroBounce.getFile(fileId);
213
+ } catch (error) {
214
+ console.error(error);
215
+ }
216
+ ```
217
+
218
+ - ##### Get the file with the scoring data
219
+
220
+ ```javascript
221
+ const fileId = "<FILE_ID>"; // The id of a previously sent file
222
+
223
+ try {
224
+ const response = await zeroBounce.getScoringFile(fileId);
225
+ } catch (error) {
226
+ console.error(error);
227
+ }
228
+ ```
229
+
230
+ - ##### Delete the file with the validated data
231
+
232
+ ```javascript
233
+ const fileId = "<FILE_ID>"; // The id of a previously sent file
234
+
235
+ try {
236
+ const response = await zeroBounce.deleteFile(fileId);
237
+ } catch (error) {
238
+ console.error(error);
239
+ }
240
+ ```
241
+
242
+ - ##### Delete the file with the scoring data
243
+
244
+ ```javascript
245
+ const fileId = "<FILE_ID>"; // The id of a previously sent file
246
+
247
+ try {
248
+ const response = await zeroBounce.deleteScoringFile(fileId);
249
+ } catch (error) {
250
+ console.error(error);
251
+ }
252
+ ```
253
+
254
+ **Any of the following email addresses can be used for testing the API, no credits are charged for these test email addresses:**
255
+
256
+ - disposable@example.com
257
+ - invalid@example.com
258
+ - valid@example.com
259
+ - toxic@example.com
260
+ - donotmail@example.com
261
+ - spamtrap@example.com
262
+ - abuse@example.com
263
+ - unknown@example.com
264
+ - catch_all@example.com
265
+ - antispam_system@example.com
266
+ - does_not_accept_mail@example.com
267
+ - exception_occurred@example.com
268
+ - failed_smtp_connection@example.com
269
+ - failed_syntax_check@example.com
270
+ - forcible_disconnect@example.com
271
+ - global_suppression@example.com
272
+ - greylisted@example.com
273
+ - leading_period_removed@example.com
274
+ - mail_server_did_not_respond@example.com
275
+ - mail_server_temporary_error@example.com
276
+ - mailbox_quota_exceeded@example.com
277
+ - mailbox_not_found@example.com
278
+ - no_dns_entries@example.com
279
+ - possible_trap@example.com
280
+ - possible_typo@example.com
281
+ - role_based@example.com
282
+ - timeout_exceeded@example.com
283
+ - unroutable_ip_address@example.com
284
+ - free_email@example.com
285
+
286
+ **You can use this IP to test the GEO Location in the API.**
287
+
288
+ - 99.110.204.1
289
+
290
+ ## Development
291
+
292
+ After checking out the repo run tests
293
+
294
+ ```bash
295
+ npm test
296
+ ```
297
+
298
+ You should see an output like this
299
+
300
+ ```bash
301
+ Test Suites: 1 passed, 1 total
302
+ Tests: 54 passed, 54 total
303
+ Snapshots: 0 total
304
+ Time: 2.596 s, estimated 3 s
305
+ Ran all test suites.
306
+ ```
package/README_es.md ADDED
@@ -0,0 +1,317 @@
1
+ {\rtf1\ansi\ansicpg1252\cocoartf2709
2
+ \cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
3
+ {\colortbl;\red255\green255\blue255;}
4
+ {\*\expandedcolortbl;;}
5
+ \paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0
6
+ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0
7
+
8
+ \f0\fs24 \cf0 ## ZeroBounce API de JavaScript v2\
9
+ \
10
+ Esta es una clase envoltorio en JavaScript para la API v2 de ZeroBounce.\
11
+ \
12
+ ## INSTALACI\'d3N\
13
+ \
14
+ ```bash\
15
+ npm install @zerobounce/zero-bounce-sdk\
16
+ ```\
17
+ \
18
+ ## USO\
19
+ \
20
+ Agregue el script\
21
+ \
22
+ ```HTML\
23
+ <script src="<RUTA_AL_SCRIPT/zeroBounceSDK.js"></script>\
24
+ ```\
25
+ \
26
+ ```HTML\
27
+ <script>\
28
+ const zeroBounce = new ZeroBounceSDK();\
29
+ </script>\
30
+ ```\
31
+ \
32
+ O\
33
+ \
34
+ Agregue el m\'f3dulo npm\
35
+ \
36
+ ```javascript\
37
+ const ZeroBounceSDK = require('@zerobounce/zero-bounce-sdk')\
38
+ \
39
+ const zeroBounce = new ZeroBounceSDK();\
40
+ ```\
41
+ \
42
+ Inicialice el SDK con su clave de API:\
43
+ \
44
+ ```javascript\
45
+ zeroBounce.init("<SU_CLAVE_DE_API>");\
46
+ ```\
47
+ \
48
+ NOTA: todos los m\'e9todos son as\'edncronos y deben usarse con async / await o .then.catch.\
49
+ \
50
+ ## Ejemplos\
51
+ \
52
+ Luego puede utilizar cualquiera de los m\'e9todos del SDK, por ejemplo:\
53
+ \
54
+ - ##### Verificar cu\'e1ntos cr\'e9ditos le quedan en su cuenta\
55
+ \
56
+ ```javascript\
57
+ try \{\
58
+ const response = await zeroBounce.getCredits();\
59
+ \} catch (error) \{\
60
+ console.error(error);\
61
+ \}\
62
+ ```\
63
+ \
64
+ - ##### Validar una direcci\'f3n de correo electr\'f3nico\
65
+ \
66
+ ```javascript\
67
+ const email = "<DIRECCI\'d3N_DE_CORREO_ELECTR\'d3NICO>"; // La direcci\'f3n de correo electr\'f3nico que desea validar\
68
+ const ip_address = "127.0.0.1"; // La direcci\'f3n IP desde la cual se registr\'f3 el correo electr\'f3nico (opcional)\
69
+ \
70
+ try \{\
71
+ const response = await zeroBounce.validateEmail(email, ip_address);\
72
+ \} catch (error) \{\
73
+ console.error(error);\
74
+ \}\
75
+ ```\
76
+ \
77
+ - ##### Obtener el uso de la API desde una fecha de inicio hasta una fecha de finalizaci\'f3n\
78
+ \
79
+ ```javascript\
80
+ const startDate = "2018-01-01"; // La fecha de inicio de cuando desea ver el uso de la API\
81
+ const endDate = "2023-12-12"; // La fecha de finalizaci\'f3n de cuando desea ver el uso de la API\
82
+ \
83
+ try \{\
84
+ const response = await zeroBounce.getApiUsage(startDate, endDate);\
85
+ \} catch (error) \{\
86
+ console.error(error);\
87
+ \}\
88
+ ```\
89
+ \
90
+ - ##### Validar una lista de direcciones de correo electr\'f3nico\
91
+ \
92
+ ```javascript\
93
+ const emailBatch = [\
94
+ \{ email_address: "<DIRECCI\'d3N_DE_CORREO_ELECTR\'d3NICO>" \},\
95
+ \{ email_address: "<DIRECCI\'d3N_DE_CORREO_ELECTR\'d3NICO>" \},\
96
+ ]; // un array que contiene una lista de objetos de correo electr\'f3nico \{email_address: "ejemplo@ejemplo.com"\}\
97
+ \
98
+ try \{\
99
+ const response = await zeroBounce.validateBatch(emailBatch);\
100
+ \} catch (error) \{\
101
+ console.error(error);\
102
+ \}\
103
+ ```\
104
+ \
105
+ - ##### Obtener datos sobre la actividad de un correo electr\'f3nico\
106
+ \
107
+ ```javascript\
108
+ const email = "<DIRECCI\'d3N_DE_CORREO_ELECTR\'d3NICO>"; // La direcci\'f3n de correo electr\'f3nico de la que desea obtener la actividad\
109
+ \
110
+ try \{\
111
+ const response = await zeroBounce.getEmailActivity(email);\
112
+ \} catch (error) \{\
113
+ console.error(error);\
114
+ \}\
115
+ ```\
116
+ \
117
+ - ##### Enviar un archivo CSV que contenga direcciones de correo electr\'f3nico para validar\
118
+ \
119
+ ```javascript\
120
+ // Par\'e1metros\
121
+ // ----------\
122
+ // file: File\
123
+ // El archivo CSV o TXT que se enviar\'e1.\
124
+ // email_address_column: number\
125
+ // El \'edndice de columna de la direcci\'f3n de correo electr\'f3nico en el archivo. El \'edndice comienza en 1.\
126
+ // return_url: str o null (Opcional)\
127
+ // La URL se utilizar\'e1 para llamar de vuelta cuando\
128
+ \
129
+ se complete la validaci\'f3n.\
130
+ // first_name_column: number o null (Opcional)\
131
+ // El \'edndice de columna del nombre en el archivo.\
132
+ // last_name_column: number o null (Opcional)\
133
+ // El \'edndice de columna del apellido en el archivo.\
134
+ // gender_column: number o null (Opcional)\
135
+ // El \'edndice de columna del g\'e9nero en el archivo.\
136
+ // ip_address_column: number o null (Opcional)\
137
+ // La direcci\'f3n IP desde la cual se registr\'f3 el correo electr\'f3nico.\
138
+ // has_header_row: Boolean (Opcional)\
139
+ // Si la primera fila del archivo enviado es una fila de encabezado.\
140
+ // remove_duplicate: Boolean (Opcional)\
141
+ // Si desea que el sistema elimine los correos electr\'f3nicos duplicados.\
142
+ const payload = \{\
143
+ file: "<ARCHIVO>",\
144
+ email_address_column: "<N\'daMERO_DE_COLUMNA>", // por ejemplo, 3\
145
+ return_url: "<URL_DE_RETORNO>", // (Opcional)\
146
+ first_name_column: "<N\'daMERO_DE_COLUMNA>", // por ejemplo, 3 (Opcional)\
147
+ last_name_column: "<N\'daMERO_DE_COLUMNA>", // por ejemplo, 3 (Opcional)\
148
+ gender_column: "<N\'daMERO_DE_COLUMNA>", // por ejemplo, 3 (Opcional)\
149
+ ip_address_column: "<N\'daMERO_DE_COLUMNA>", // por ejemplo, 3 (Opcional)\
150
+ has_header_row: true / false, // (Opcional)\
151
+ remove_duplicate: true / false, // (Opcional)\
152
+ \};\
153
+ \
154
+ try \{\
155
+ const response = await zeroBounce.sendFile(payload);\
156
+ \} catch (error) \{\
157
+ console.error(error);\
158
+ \}\
159
+ ```\
160
+ \
161
+ - ##### Enviar un archivo CSV que contenga direcciones de correo electr\'f3nico para obtener la puntuaci\'f3n de los correos electr\'f3nicos\
162
+ \
163
+ ```javascript\
164
+ // Par\'e1metros\
165
+ // ----------\
166
+ // file: File\
167
+ // El archivo CSV o TXT que se enviar\'e1.\
168
+ // email_address_column: number\
169
+ // El \'edndice de columna de la direcci\'f3n de correo electr\'f3nico en el archivo. El \'edndice comienza en 1.\
170
+ // return_url: str o null (Opcional)\
171
+ // La URL se utilizar\'e1 para llamar de vuelta cuando se complete la validaci\'f3n.\
172
+ // has_header_row: Boolean (Opcional)\
173
+ // Si la primera fila del archivo enviado es una fila de encabezado.\
174
+ // remove_duplicate: Boolean (Opcional)\
175
+ // Si desea que el sistema elimine los correos electr\'f3nicos duplicados.\
176
+ const payload = \{\
177
+ file: "<ARCHIVO>",\
178
+ email_address_column: "<N\'daMERO_DE_COLUMNA>", // por ejemplo, 3\
179
+ return_url: "<URL_DE_RETORNO>", // (Opcional)\
180
+ has_header_row: true / false,\
181
+ remove_duplicate: true / false, // (Opcional)\
182
+ \};\
183
+ \
184
+ try \{\
185
+ const response = await zeroBounce.sendScoringFile(payload);\
186
+ \} catch (error) \{\
187
+ console.error(error);\
188
+ \}\
189
+ ```\
190
+ \
191
+ - ##### El estado de finalizaci\'f3n de un archivo enviado anteriormente\
192
+ \
193
+ ```javascript\
194
+ const fileId = "<ID_DE_ARCHIVO>"; // El ID de un archivo enviado anteriormente\
195
+ \
196
+ try \{\
197
+ const response = await zeroBounce.getFileStatus(fileId);\
198
+ \} catch (error) \{\
199
+ console.error(error);\
200
+ \}\
201
+ ```\
202
+ \
203
+ - ##### El estado de finalizaci\'f3n de un archivo de puntuaci\'f3n enviado anteriormente\
204
+ \
205
+ ```javascript\
206
+ const fileId = "<ID_DE_ARCHIVO>"; // El ID de un archivo enviado anteriormente\
207
+ \
208
+ \
209
+ \
210
+ try \{\
211
+ const response = await zeroBounce.getScoringFileStatus(fileId);\
212
+ \} catch (error) \{\
213
+ console.error(error);\
214
+ \}\
215
+ ```\
216
+ \
217
+ - ##### Obtener el archivo con los datos validados\
218
+ \
219
+ ```javascript\
220
+ const fileId = "<ID_DE_ARCHIVO>"; // El ID de un archivo enviado anteriormente\
221
+ \
222
+ try \{\
223
+ const response = await zeroBounce.getFile(fileId);\
224
+ \} catch (error) \{\
225
+ console.error(error);\
226
+ \}\
227
+ ```\
228
+ \
229
+ - ##### Obtener el archivo con los datos de puntuaci\'f3n\
230
+ \
231
+ ```javascript\
232
+ const fileId = "<ID_DE_ARCHIVO>"; // El ID de un archivo enviado anteriormente\
233
+ \
234
+ try \{\
235
+ const response = await zeroBounce.getScoringFile(fileId);\
236
+ \} catch (error) \{\
237
+ console.error(error);\
238
+ \}\
239
+ ```\
240
+ \
241
+ - ##### Eliminar el archivo con los datos validados\
242
+ \
243
+ ```javascript\
244
+ const fileId = "<ID_DE_ARCHIVO>"; // El ID de un archivo enviado anteriormente\
245
+ \
246
+ try \{\
247
+ const response = await zeroBounce.deleteFile(fileId);\
248
+ \} catch (error) \{\
249
+ console.error(error);\
250
+ \}\
251
+ ```\
252
+ \
253
+ - ##### Eliminar el archivo con los datos de puntuaci\'f3n\
254
+ \
255
+ ```javascript\
256
+ const fileId = "<ID_DE_ARCHIVO>"; // El ID de un archivo enviado anteriormente\
257
+ \
258
+ try \{\
259
+ const response = await zeroBounce.deleteScoringFile(fileId);\
260
+ \} catch (error) \{\
261
+ console.error(error);\
262
+ \}\
263
+ ```\
264
+ \
265
+ **Puede utilizar cualquiera de las siguientes direcciones de correo electr\'f3nico para probar la API, no se cobran cr\'e9ditos por estas direcciones de correo electr\'f3nico de prueba:**\
266
+ \
267
+ - disposable@example.com\
268
+ - invalid@example.com\
269
+ - valid@example.com\
270
+ - toxic@example.com\
271
+ - donotmail@example.com\
272
+ - spamtrap@example.com\
273
+ - abuse@example.com\
274
+ - unknown@example.com\
275
+ - catch_all@example.com\
276
+ - antispam_system@example.com\
277
+ - does_not_accept_mail@example.com\
278
+ - exception_occurred@example.com\
279
+ - failed_smtp_connection@example.com\
280
+ - failed_syntax_check@example.com\
281
+ - forcible_disconnect@example.com\
282
+ - global_suppression@example.com\
283
+ - greylisted@example.com\
284
+ - leading_period_removed@example.com\
285
+ - mail_server_did_not_respond@example.com\
286
+ - mail_server_temporary_error@example.com\
287
+ - mailbox_quota_exceeded@example.com\
288
+ - mailbox_not_found@example.com\
289
+ - no_dns_entries@example.com\
290
+ - possible_trap@example.com\
291
+ - possible_typo@example.com\
292
+ - role_based@example.com\
293
+ - timeout_exceeded@example.com\
294
+ - unroutable_ip_address@example.com\
295
+ - free_email@example.com\
296
+ \
297
+ **Puede utilizar esta direcci\'f3n IP para probar la ubicaci\'f3n geogr\'e1fica en la API.**\
298
+ \
299
+ - 99.110.204.1\
300
+ \
301
+ ## Desarrollo\
302
+ \
303
+ Despu\'e9s de verificar el repositorio, ejecute las pruebas\
304
+ \
305
+ ```bash\
306
+ npm test\
307
+ ```\
308
+ \
309
+ Deber\'eda ver una salida como esta\
310
+ \
311
+ ```bash\
312
+ Test Suites: 1 passed, 1 total\
313
+ Tests: 54 passed, 54 total\
314
+ Snapshots: 0 total\
315
+ Time: 2.596 s, estimated 3 s\
316
+ Ran all test suites.\
317
+ ```}
@@ -0,0 +1 @@
1
+ module.exports = {presets: ['@babel/preset-env']}
@@ -0,0 +1 @@
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`)}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)}};return i.default})()));
package/jest.config.js ADDED
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ transform: {
3
+ "^.+\\.(js|jsx)$": "babel-jest",
4
+ }
5
+ };
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@zerobounce/zero-bounce-sdk",
3
+ "version": "1.0.0",
4
+ "description": "This SDK contains methods for interacting easily with ZeroBounce API. More information about ZeroBounce you can find in the official documentation.",
5
+ "main": "dist/zeroBounceSDK.js",
6
+ "scripts": {
7
+ "test": "jest",
8
+ "build": "webpack --mode=production"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/zerobounce/zero-bounce-javascript.git"
13
+ },
14
+ "author": "",
15
+ "license": "ISC",
16
+ "bugs": {
17
+ "url": "https://github.com/zerobounce/zero-bounce-javascript/issues"
18
+ },
19
+ "homepage": "https://github.com/zerobounce/zero-bounce-javascript#readme",
20
+ "devDependencies": {
21
+ "@babel/core": "^7.21.4",
22
+ "@babel/preset-env": "^7.21.4",
23
+ "babel-jest": "^29.5.0",
24
+ "jest": "^29.5.0",
25
+ "webpack": "^5.78.0",
26
+ "webpack-cli": "^5.0.1"
27
+ }
28
+ }
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import { ZeroBounceSDK } from "./zero-bounce.js";
2
+ export default ZeroBounceSDK;