zerobounceindia-sdk 1.0.1 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75dd87aa7657862fa0eb77010eb648e96d07f3914d3939d97048ab3abb1849d5
4
- data.tar.gz: 213eef658cf8f65081130288d0d6155b0cf31d7ab81e2da8110d3c05e739ae56
3
+ metadata.gz: 6fa7b16ed7f3d6433b147c71b8653f912ed92233e0a8886296f6dfc3119fa269
4
+ data.tar.gz: 52696da7f11e651bc6ddc6ab51979997fdaf9d4a181030add5477cec2d91d454
5
5
  SHA512:
6
- metadata.gz: e8e1324056738f08f809110de5768fdc2748ee79e03b59cf8c9812d1cad531e722615880cd418b7475f6b56ba7aaf5928a3781ee7232b5c0992676ff1f073103
7
- data.tar.gz: 267417eabc8f3c2b20f3fa22157a56d5388f7b40465bf84982a4f766b340cc312fde82938745a495596638217af7663a33834101ef44c362780f5916f5e32e30
6
+ metadata.gz: 34643b4ad277d00d32aced6f53e042d1801afc66a8ad7532e35203e6f653abc2551399e0b15d3843dae88925657e604c1493969b1eb4ed93711eef055ea7db32
7
+ data.tar.gz: 2add5c95922b48374dd211fa9167fc7c1f7cb48f416acb3ddbfc65e4a1141d26490ce976cdb54f6eccb8e6c16594095776b59c7d64170b6c2dab0234af5ad331
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zerobounce (0.4.0)
4
+ zerobounce-sdk (1.1.1)
5
+ dotenv (~> 2.8.1)
5
6
  rest-client (~> 2.1)
6
7
 
7
8
  GEM
@@ -17,15 +18,16 @@ GEM
17
18
  docile (1.4.0)
18
19
  domain_name (0.5.20190701)
19
20
  unf (>= 0.0.5, < 1.0.0)
21
+ dotenv (2.8.1)
20
22
  hashdiff (1.0.1)
21
23
  http-accept (1.7.0)
22
24
  http-cookie (1.0.5)
23
25
  domain_name (~> 0.5)
24
26
  json (2.6.3)
25
27
  method_source (1.0.0)
26
- mime-types (3.4.1)
28
+ mime-types (3.5.1)
27
29
  mime-types-data (~> 3.2015)
28
- mime-types-data (3.2023.0218.1)
30
+ mime-types-data (3.2023.0808)
29
31
  netrc (0.11.0)
30
32
  parallel (1.22.1)
31
33
  parser (3.2.2.0)
@@ -115,7 +117,7 @@ DEPENDENCIES
115
117
  vcr (~> 6.1.0)
116
118
  webmock (~> 3.18)
117
119
  yard (~> 0.9.26)
118
- zerobounce!
120
+ zerobounce-sdk!
119
121
 
120
122
  BUNDLED WITH
121
123
  2.4.6
data/README.md CHANGED
@@ -30,7 +30,7 @@ Zerobounce.configure do |config|
30
30
  ...
31
31
  end
32
32
  ```
33
- or
33
+ or
34
34
  ```
35
35
  Zerobounce.config.apikey = '<zerobounce-api-key>'
36
36
  ...
@@ -92,7 +92,7 @@ Zerobounce.api_usage(Date.today, Date.today)
92
92
 
93
93
  Validate single eMail
94
94
  ```ruby
95
- Zerobounce.validate('valid@example.com')
95
+ Zerobounce.validate('valid@example.com')
96
96
  # Zerobounce.validate('valid@example.com', '192.168.0.1') # optional IP address
97
97
  =>
98
98
  {"address"=>"valid@example.com",
@@ -126,11 +126,11 @@ emails
126
126
  "toxic@example.com",
127
127
  "donotmail@example.com",
128
128
  "spamtrap@example.com"]
129
-
130
- # ip_addresses
129
+
130
+ # ip_addresses
131
131
  => ["192.168.0.1", "192.168.0.1", "192.168.0.1", "192.168.0.1", "192.168.0.1", "192.168.0.1"]
132
132
  # Zerobounce.validate_batch(emails, ip_addresses) # optional ip_addresses parameter
133
-
133
+
134
134
  Zerobounce.validate_batch(emails)
135
135
  =>
136
136
  [{"address"=>"disposable@example.com",
@@ -263,14 +263,14 @@ Send file
263
263
  "file_name"=>"validation.csv",
264
264
  "file_id"=>"75d854a6-565c-49f9-b4c8-b3344480ec4c"}
265
265
  # file_id will be required for next steps
266
- # optional named parameters:
266
+ # optional named parameters:
267
267
  email_address_column: 1,
268
268
  first_name_column: 2,
269
269
  last_name_column: 3,
270
270
  gender_column: 4,
271
271
  has_header_row: true,
272
272
  return_url: nil # results callback url
273
- # Zerobounce.validate_file_send(validate_file_path, email_address_column: 1, gender_column: 4)
273
+ # Zerobounce.validate_file_send(validate_file_path, email_address_column: 1, gender_column: 4)
274
274
  ```
275
275
 
276
276
  Check file
@@ -361,6 +361,99 @@ Zerobounce.validate_file_delete(file_id)
361
361
  ```
362
362
 
363
363
 
364
+ ### More details on CSV file submission and CSV result retrieval
365
+
366
+ This applies for both 'Email validation' and 'AI Scoring' functionalities.
367
+
368
+ **The data** of the submitted CSV file **will be included** in the result CSV file. Therefore, the first columns of the result CSV file will consist of the submitted data and the following columns will provide information specific to each functionality.
369
+
370
+ #### 'Email validation'
371
+
372
+ The additional columns that would be included in result CSV file:
373
+ * ZB Status
374
+ * ZB Sub Status
375
+ * ZB Account
376
+ * ZB Domain
377
+ * ZB First Name
378
+ * ZB Last Name
379
+ * ZB Gender
380
+ * ZB Free Email
381
+ * ZB MX Found
382
+ * ZB MX Record
383
+ * ZB SMTP Provider
384
+ * ZB Did You Mean
385
+ * ZB City
386
+ * ZB Region/State
387
+ * ZB Zip Code
388
+ * ZB Country
389
+
390
+ When `has_header_row: true` is provided to `validate_file_send()` method, original columns of the submitted file will be retained.
391
+
392
+ When `has_header_row: false`, the columns that were explicitly specified in `validate_file_send()` will be given the following column title:
393
+ ```
394
+ email_address_column => "Email Address"
395
+ first_name_column => "First Name"
396
+ last_name_column => "Last Name"
397
+ gender_column => "Gender"
398
+ ```
399
+
400
+ Any additional that were not (or can not be) specified by parameters, will be given column title "Custom".
401
+
402
+
403
+ #### 'AI Scoring':
404
+ The additional _column_ that would be included in result CSV file:
405
+ * ZeroBounceQualityScore
406
+
407
+ When `has_header_row: true` is provided to `scoring_file_send()` method, original columns of the submitted file will be retained.
408
+
409
+
410
+ When `has_header_row: false` is provided to `scoring_file_send()` method, column title for the email column (as well as the other columns) will be _Email Address_.
411
+
412
+
413
+ ### Email Finder
414
+
415
+ Guess Format
416
+ ```ruby
417
+ Zerobounce.guessformat("zerobounce.net")
418
+ =>
419
+ {"email"=>"",
420
+ "domain"=>"zerobounce.net",
421
+ "format"=>"first.last",
422
+ "status"=>"",
423
+ "sub_status"=>"",
424
+ "confidence"=>"high",
425
+ "did_you_mean"=>"",
426
+ "failure_reason"=>"",
427
+ "other_domain_formats"=>
428
+ [{"format"=>"first", "confidence"=>"high"},
429
+ {"format"=>"last.first", "confidence"=>"high"},
430
+ {"format"=>"lfirst", "confidence"=>"high"},
431
+ {"format"=>"lastfirst", "confidence"=>"high"},
432
+ {"format"=>"firstl", "confidence"=>"high"},
433
+ {"format"=>"last", "confidence"=>"medium"},
434
+ {"format"=>"first.middle.last", "confidence"=>"medium"},
435
+ {"format"=>"first-last", "confidence"=>"medium"},
436
+ {"format"=>"l.first", "confidence"=>"medium"},
437
+ {"format"=>"f.last", "confidence"=>"medium"},
438
+ {"format"=>"f-last", "confidence"=>"medium"},
439
+ {"format"=>"first.l", "confidence"=>"medium"},
440
+ {"format"=>"first-l", "confidence"=>"medium"},
441
+ {"format"=>"firstlast", "confidence"=>"medium"},
442
+ {"format"=>"first_l", "confidence"=>"medium"},
443
+ {"format"=>"f_last", "confidence"=>"medium"},
444
+ {"format"=>"last.f", "confidence"=>"medium"},
445
+ {"format"=>"last-f", "confidence"=>"medium"},
446
+ {"format"=>"last-first", "confidence"=>"medium"},
447
+ {"format"=>"first_last", "confidence"=>"medium"},
448
+ {"format"=>"last_f", "confidence"=>"medium"},
449
+ {"format"=>"last_first", "confidence"=>"medium"},
450
+ {"format"=>"flast", "confidence"=>"medium"},
451
+ {"format"=>"lastf", "confidence"=>"medium"},
452
+ {"format"=>"l-first", "confidence"=>"low"},
453
+ {"format"=>"l_first", "confidence"=>"low"}]}
454
+ # Zerobounce.guessformat("zerobounce.net", first_name: "John", middle_name: 'Deere', last_name: "Doe")
455
+ ```
456
+
364
457
  ## Development
365
458
 
366
459
  After checking out the repo run tests
@@ -1,8 +1,4 @@
1
-
2
- # Zerobounce India
3
- Ruby client for Zerobounce.net API. Developed based on [this version](https://github.com/afrase/zerobounce) by Aaron Frase.
4
-
5
- ## Usage
1
+ #### Usage
6
2
  Add this line to your application's Gemfile:
7
3
  ```ruby
8
4
  gem 'zerobounceindia-sdk'
@@ -30,7 +26,7 @@ Zerobounce.configure do |config|
30
26
  ...
31
27
  end
32
28
  ```
33
- or
29
+ or
34
30
  ```
35
31
  Zerobounce.config.apikey = '<zerobounce-api-key>'
36
32
  ...
@@ -39,7 +35,7 @@ Zerobounce.config.apikey = '<zerobounce-api-key>'
39
35
  Credits
40
36
  ```ruby
41
37
  Zerobounce.credits
42
- => 79 # returns -1 for invalid key
38
+ => 79 ### returns -1 for invalid key
43
39
  ```
44
40
 
45
41
  Activity
@@ -88,12 +84,12 @@ Zerobounce.api_usage(Date.today, Date.today)
88
84
  "end_date"=>"4/28/2023"}
89
85
  ```
90
86
 
91
- ### Email Validation
87
+ ##### Email Validation
92
88
 
93
89
  Validate single eMail
94
90
  ```ruby
95
- Zerobounce.validate('valid@example.com')
96
- # Zerobounce.validate('valid@example.com', '192.168.0.1') # optional IP address
91
+ Zerobounce.validate('valid@example.com')
92
+ ### Zerobounce.validate('valid@example.com', '192.168.0.1') # optional IP address
97
93
  =>
98
94
  {"address"=>"valid@example.com",
99
95
  "status"=>"valid",
@@ -126,11 +122,11 @@ emails
126
122
  "toxic@example.com",
127
123
  "donotmail@example.com",
128
124
  "spamtrap@example.com"]
129
-
130
- # ip_addresses
125
+
126
+ ### ip_addresses
131
127
  => ["192.168.0.1", "192.168.0.1", "192.168.0.1", "192.168.0.1", "192.168.0.1", "192.168.0.1"]
132
- # Zerobounce.validate_batch(emails, ip_addresses) # optional ip_addresses parameter
133
-
128
+ ### Zerobounce.validate_batch(emails, ip_addresses) # optional ip_addresses parameter
129
+
134
130
  Zerobounce.validate_batch(emails)
135
131
  =>
136
132
  [{"address"=>"disposable@example.com",
@@ -249,11 +245,11 @@ Zerobounce.validate_batch(emails)
249
245
  "processed_at"=>"2023-04-28 15:21:44.340"}]
250
246
  ```
251
247
 
252
- #### Batch File Validation
248
+ ###### Batch File Validation
253
249
 
254
250
  Send file
255
251
  ```ruby
256
- # sample file can be found in the files folder of this repository
252
+ ### sample file can be found in the files folder of this repository
257
253
  validate_file_path = File.join(Dir.pwd, 'files', 'validation.csv')
258
254
  => "/home/zb/wrappers/ruby-test/files/validation.csv"
259
255
  Zerobounce.validate_file_send(validate_file_path)
@@ -262,15 +258,15 @@ Send file
262
258
  "message"=>"File Accepted",
263
259
  "file_name"=>"validation.csv",
264
260
  "file_id"=>"75d854a6-565c-49f9-b4c8-b3344480ec4c"}
265
- # file_id will be required for next steps
266
- # optional named parameters:
261
+ ### file_id will be required for next steps
262
+ ### optional named parameters:
267
263
  email_address_column: 1,
268
264
  first_name_column: 2,
269
265
  last_name_column: 3,
270
266
  gender_column: 4,
271
267
  has_header_row: true,
272
- return_url: nil # results callback url
273
- # Zerobounce.validate_file_send(validate_file_path, email_address_column: 1, gender_column: 4)
268
+ return_url: nil ### results callback url
269
+ ### Zerobounce.validate_file_send(validate_file_path, email_address_column: 1, gender_column: 4)
274
270
  ```
275
271
 
276
272
  Check file
@@ -309,7 +305,7 @@ Zerobounce.validate_file_delete(file_id)
309
305
  "file_id"=>"75d854a6-565c-49f9-b4c8-b3344480ec4c"}
310
306
  ```
311
307
 
312
- ### AI Scoring
308
+ ##### AI Scoring
313
309
 
314
310
  Send file
315
311
  ```ruby
@@ -321,12 +317,12 @@ Zerobounce.scoring_file_send(scoring_file_path)
321
317
  "message"=>"File Accepted",
322
318
  "file_name"=>"scoring.csv",
323
319
  "file_id"=>"89fb7262-b845-4fa1-aa25-e486347ec64e"}
324
- # file_id will be required for the next steps
325
- # optional named parameters
320
+ ### file_id will be required for the next steps
321
+ ### optional named parameters
326
322
  email_address_column: 1,
327
323
  has_header_row: true,
328
- return_url: nil # results callback url
329
- # Zerobounce.scoring_file_send(scoring_file_path, email_address_column: 1)
324
+ return_url: nil ### results callback url
325
+ ### Zerobounce.scoring_file_send(scoring_file_path, email_address_column: 1)
330
326
  ```
331
327
 
332
328
  File check
@@ -360,12 +356,56 @@ Zerobounce.validate_file_delete(file_id)
360
356
  => {"success"=>false, "message"=>"File cannot be found."}
361
357
  ```
362
358
 
359
+ ##### Email Finder
360
+
361
+ Guess Format
362
+ ```ruby
363
+ Zerobounce.guessformat("zerobounce.net")
364
+ =>
365
+ {"email"=>"",
366
+ "domain"=>"zerobounce.net",
367
+ "format"=>"first.last",
368
+ "status"=>"",
369
+ "sub_status"=>"",
370
+ "confidence"=>"high",
371
+ "did_you_mean"=>"",
372
+ "failure_reason"=>"",
373
+ "other_domain_formats"=>
374
+ [{"format"=>"first", "confidence"=>"high"},
375
+ {"format"=>"last.first", "confidence"=>"high"},
376
+ {"format"=>"lfirst", "confidence"=>"high"},
377
+ {"format"=>"lastfirst", "confidence"=>"high"},
378
+ {"format"=>"firstl", "confidence"=>"high"},
379
+ {"format"=>"last", "confidence"=>"medium"},
380
+ {"format"=>"first.middle.last", "confidence"=>"medium"},
381
+ {"format"=>"first-last", "confidence"=>"medium"},
382
+ {"format"=>"l.first", "confidence"=>"medium"},
383
+ {"format"=>"f.last", "confidence"=>"medium"},
384
+ {"format"=>"f-last", "confidence"=>"medium"},
385
+ {"format"=>"first.l", "confidence"=>"medium"},
386
+ {"format"=>"first-l", "confidence"=>"medium"},
387
+ {"format"=>"firstlast", "confidence"=>"medium"},
388
+ {"format"=>"first_l", "confidence"=>"medium"},
389
+ {"format"=>"f_last", "confidence"=>"medium"},
390
+ {"format"=>"last.f", "confidence"=>"medium"},
391
+ {"format"=>"last-f", "confidence"=>"medium"},
392
+ {"format"=>"last-first", "confidence"=>"medium"},
393
+ {"format"=>"first_last", "confidence"=>"medium"},
394
+ {"format"=>"last_f", "confidence"=>"medium"},
395
+ {"format"=>"last_first", "confidence"=>"medium"},
396
+ {"format"=>"flast", "confidence"=>"medium"},
397
+ {"format"=>"lastf", "confidence"=>"medium"},
398
+ {"format"=>"l-first", "confidence"=>"low"},
399
+ {"format"=>"l_first", "confidence"=>"low"}]}
400
+ # Zerobounce.guessformat("zerobounce.net", first_name: "John", middle_name: 'Deere', last_name: "Doe")
401
+ ```
402
+
363
403
 
364
- ## Development
404
+ #### Development
365
405
 
366
406
  After checking out the repo run tests
367
407
  ```bash
368
- rspec --init # if needed
408
+ rspec --init ### if needed
369
409
  bundle exec rspec
370
410
  ```
371
411
 
@@ -379,7 +419,7 @@ Finished in 6.81 seconds (files took 0.40587 seconds to load)
379
419
  53 examples, 0 failures
380
420
  ```
381
421
 
382
- ### Test parameters
422
+ ##### Test parameters
383
423
  The tests use the following environment parameters:
384
424
  TEST {unit|live} influences whether mocked unit tests are run or the live server is used (credits may be used if you choose to do this)
385
425
  ZEROBOUNCE_API_KEY {<zerobounce-api-key-value>} this key is used to make requests to the live server; it is also used in mock tests as a valid key sample (any value will work for mock tests)
@@ -0,0 +1,449 @@
1
+ #### Uso
2
+ Agrega esta línea a tu Gemfile de la aplicación:
3
+ ```ruby
4
+ gem 'zerobounce-sdk'
5
+ ```
6
+
7
+ Y luego ejecuta:
8
+ ```bash
9
+ $ bundle
10
+ ```
11
+
12
+ O instálalo directamente con:
13
+ ```bash
14
+ $ gem install zerobounce-sdk
15
+ ```
16
+
17
+ Importa:
18
+ ```ruby
19
+ require 'zerobounce'
20
+ ```
21
+
22
+ Configura una clave de API válida de ZeroBounce:
23
+ ```ruby
24
+ Zerobounce.configure do |config|
25
+ config.apikey = '<clave-de-api-de-zerobounce>'
26
+ ...
27
+ end
28
+ ```
29
+ o
30
+ ```ruby
31
+ Zerobounce.config.apikey = '<clave-de-api-de-zerobounce>'
32
+ ...
33
+ ```
34
+
35
+ Créditos
36
+ ```ruby
37
+ Zerobounce.credits
38
+ => 79 ### devuelve -1 si la clave es inválida
39
+ ```
40
+
41
+ Actividad
42
+ ```ruby
43
+ Zerobounce.activity('ss@gmail.com')
44
+ => {"found"=>true, "active_in_days"=>"180"}
45
+ ```
46
+
47
+ Estadísticas de uso
48
+ ```ruby
49
+ Zerobounce.api_usage(Date.today, Date.today)
50
+ =>
51
+ {"total"=>0,
52
+ "status_valid"=>0,
53
+ "status_invalid"=>0,
54
+ "status_catch_all"=>0,
55
+ "status_do_not_mail"=>0,
56
+ "status_spamtrap"=>0,
57
+ "status_unknown"=>0,
58
+ "sub_status_toxic"=>0,
59
+ "sub_status_disposable"=>0,
60
+ "sub_status_role_based"=>0,
61
+ "sub_status_possible_trap"=>0,
62
+ "sub_status_global_suppression"=>0,
63
+ "sub_status_timeout_exceeded"=>0,
64
+ "sub_status_mail_server_temporary_error"=>0,
65
+ "sub_status_mail_server_did_not_respond"=>0,
66
+ "sub_status_greylisted"=>0,
67
+ "sub_status_antispam_system"=>0,
68
+ "sub_status_does_not_accept_mail"=>0,
69
+ "sub_status_exception_occurred"=>0,
70
+ "sub_status_failed_syntax_check"=>0,
71
+ "sub_status_mailbox_not_found"=>0,
72
+ "sub_status_unroutable_ip_address"=>0,
73
+ "sub_status_possible_typo"=>0,
74
+ "sub_status_no_dns_entries"=>0,
75
+ "sub_status_role_based_catch_all"=>0,
76
+ "sub_status_mailbox_quota_exceeded"=>0,
77
+ "sub_status_forcible_disconnect"=>0,
78
+ "sub_status_failed_smtp_connection"=>0,
79
+ "sub_status_mx_forward"=>0,
80
+ "sub_status_alternate"=>0,
81
+ "sub_status_blocked"=>0,
82
+ "sub_status_allowed"=>0,
83
+ "start_date"=>"4/28/2023",
84
+ "end_date"=>"4/28/2023"}
85
+ ```
86
+
87
+ ##### Validación de correo electrónico
88
+
89
+ Validar un solo correo electrónico
90
+ ```ruby
91
+ Zerobounce.validate('valid@example.com')
92
+ ### Zerobounce.validate('valid@example.com', '192.168.0.1') # dirección IP opcional
93
+ =>
94
+ {"address"=>"valid@example.com",
95
+ "status"=>"valid",
96
+ "sub_status"=>"",
97
+ "free_email"=>false,
98
+ "did_you_mean"=>nil,
99
+ "account"=>nil,
100
+ "domain"=>nil,
101
+ "domain_age_days"=>"9692",
102
+ "smtp_provider"=>"example",
103
+ "mx_found"=>"true",
104
+ "mx_record"=>"mx.example.com",
105
+ "firstname"=>"zero",
106
+ "lastname"=>"bounce",
107
+ "gender"=>"male",
108
+ "country"=>nil,
109
+ "region"=>nil,
110
+ "city"=>nil,
111
+ "zipcode"=>nil,
112
+ "processed_at"=>"2023-04-28 15:18:45.631"}
113
+ ```
114
+
115
+ Validar
116
+
117
+ en lote
118
+ ```ruby
119
+ emails
120
+ =>
121
+ ["disposable@example.com",
122
+ "invalid@example.com",
123
+ "valid@example.com",
124
+ "toxic@example.com",
125
+ "donotmail@example.com",
126
+ "spamtrap@example.com"]
127
+
128
+ ### ip_addresses
129
+ => ["192.168.0.1", "192.168.0.1", "192.168.0.1", "192.168.0.1", "192.168.0.1", "192.168.0.1"]
130
+ ### Zerobounce.validate_batch(emails, ip_addresses) # parámetro ip_addresses opcional
131
+
132
+ Zerobounce.validate_batch(emails)
133
+ =>
134
+ [{"address"=>"disposable@example.com",
135
+ "status"=>"do_not_mail",
136
+ "sub_status"=>"disposable",
137
+ "free_email"=>false,
138
+ "did_you_mean"=>nil,
139
+ "account"=>nil,
140
+ "domain"=>nil,
141
+ "domain_age_days"=>"9692",
142
+ "smtp_provider"=>"example",
143
+ "mx_found"=>"true",
144
+ "mx_record"=>"mx.example.com",
145
+ "firstname"=>"zero",
146
+ "lastname"=>"bounce",
147
+ "gender"=>"male",
148
+ "country"=>nil,
149
+ "region"=>nil,
150
+ "city"=>nil,
151
+ "zipcode"=>nil,
152
+ "processed_at"=>"2023-04-28 15:21:44.340"},
153
+ {"address"=>"invalid@example.com",
154
+ "status"=>"invalid",
155
+ "sub_status"=>"mailbox_not_found",
156
+ "free_email"=>false,
157
+ "did_you_mean"=>nil,
158
+ "account"=>nil,
159
+ "domain"=>nil,
160
+ "domain_age_days"=>"9692",
161
+ "smtp_provider"=>"example",
162
+ "mx_found"=>"true",
163
+ "mx_record"=>"mx.example.com",
164
+ "firstname"=>"zero",
165
+ "lastname"=>"bounce",
166
+ "gender"=>"male",
167
+ "country"=>nil,
168
+ "region"=>nil,
169
+ "city"=>nil,
170
+ "zipcode"=>nil,
171
+ "processed_at"=>"2023-04-28 15:21:44.340"},
172
+ {"address"=>"valid@example.com",
173
+ "status"=>"valid",
174
+ "sub_status"=>"",
175
+ "free_email"=>false,
176
+ "did_you_mean"=>nil,
177
+ "account"=>nil,
178
+ "domain"=>nil,
179
+ "domain_age_days"=>"9692",
180
+ "smtp_provider"=>"example",
181
+ "mx_found"=>"true",
182
+ "mx_record"=>"mx.example.com",
183
+ "firstname"=>"zero",
184
+ "lastname"=>"bounce",
185
+ "gender"=>"male",
186
+ "country"=>nil,
187
+ "region"=>nil,
188
+ "city"=>nil,
189
+ "zipcode"=>nil,
190
+ "processed_at"=>"2023-04-28 15:21:44.340"},
191
+ {"address"=>"toxic@example.com",
192
+ "status"=>"do_not_mail",
193
+ "sub_status"=>"toxic",
194
+ "free_email"=>false,
195
+ "did_you_mean"=>nil,
196
+ "account"=>nil,
197
+ "domain"=>nil,
198
+ "domain_age_days"=>"9692",
199
+ "smtp_provider"=>"example",
200
+ "mx_found"=>"true",
201
+ "mx_record"=>"mx.example.com",
202
+ "firstname"=>"zero",
203
+ "lastname"=>"bounce",
204
+ "gender"=>"male",
205
+ "country"=>nil,
206
+ "region"=>nil,
207
+ "city"=>nil,
208
+ "zipcode"=>nil,
209
+ "processed_at"=>"2023-04-28 15:21:44.340"},
210
+ {"address"=>"donotmail@example.com",
211
+ "status"=>"do_not_mail",
212
+ "sub_status"=>"role_based",
213
+ "free_email"=>false,
214
+ "did_you_mean"=>nil,
215
+ "account"=>nil,
216
+ "domain"=>nil,
217
+ "domain
218
+
219
+ _age_days"=>"9692",
220
+ "smtp_provider"=>"example",
221
+ "mx_found"=>"true",
222
+ "mx_record"=>"mx.example.com",
223
+ "firstname"=>"zero",
224
+ "lastname"=>"bounce",
225
+ "gender"=>"male",
226
+ "country"=>nil,
227
+ "region"=>nil,
228
+ "city"=>nil,
229
+ "zipcode"=>nil,
230
+ "processed_at"=>"2023-04-28 15:21:44.340"},
231
+ {"address"=>"spamtrap@example.com",
232
+ "status"=>"spamtrap",
233
+ "sub_status"=>"",
234
+ "free_email"=>false,
235
+ "did_you_mean"=>nil,
236
+ "account"=>nil,
237
+ "domain"=>nil,
238
+ "domain_age_days"=>"9692",
239
+ "smtp_provider"=>"example",
240
+ "mx_found"=>"true",
241
+ "mx_record"=>"mx.example.com",
242
+ "firstname"=>"zero",
243
+ "lastname"=>"bounce",
244
+ "gender"=>"male",
245
+ "country"=>nil,
246
+ "region"=>nil,
247
+ "city"=>nil,
248
+ "zipcode"=>nil,
249
+ "processed_at"=>"2023-04-28 15:21:44.340"}]
250
+ ```
251
+
252
+ ###### Validación de archivo en lote
253
+
254
+ Enviar archivo
255
+ ```ruby
256
+ ### puedes encontrar un archivo de muestra en la carpeta files de este repositorio
257
+ validate_file_path = File.join(Dir.pwd, 'files', 'validation.csv')
258
+ => "/home/zb/wrappers/ruby-test/files/validation.csv"
259
+ Zerobounce.validate_file_send(validate_file_path)
260
+ =>
261
+ {"success"=>true,
262
+ "message"=>"File Accepted",
263
+ "file_name"=>"validation.csv",
264
+ "file_id"=>"75d854a6-565c-49f9-b4c8-b3344480ec4c"}
265
+ ### se requerirá el file_id para los próximos pasos
266
+ ### parámetros opcionales:
267
+ email_address_column: 1,
268
+ first_name_column: 2,
269
+ last_name_column: 3,
270
+ gender_column: 4,
271
+ has_header_row: true,
272
+ return_url: nil ### URL de devolución de resultados
273
+ ### Zerobounce.validate_file_send(validate_file_path, email_address_column: 1, gender_column: 4)
274
+ ```
275
+
276
+ Verificar archivo
277
+ ```ruby
278
+ file_id = "75d854a6-565c-49f9-b4c8-b3344480ec4c"
279
+ => "75d854a6-565c-49f9-b4c8-b3344480ec4c"
280
+ Zerobounce.validate_file_check(file_id)
281
+ =>
282
+ {"success"=>true,
283
+ "file_id"=>"75d854a6-565c-49f9-b4c8-b3344480ec4c",
284
+ "file_name"=>"validation.csv",
285
+ "upload_date"=>"2023-04-28T15:25:41Z",
286
+ "file_status"=>"Greylisted",
287
+ "complete_percentage"=>"0%",
288
+ "error_reason"=>nil,
289
+ "return_url"=>nil}
290
+ ```
291
+
292
+ Obtener archivo
293
+ ```ruby
294
+ file_id = "75d854a6-565c-49f9-b4c8-b3344480ec4c"
295
+ => "75d854a6-565c-49f9-b4c8-b3344480ec4c"
296
+ Zerobounce.validate_file_get(file_id)
297
+ => "\"email\",\"first\",\"last\",\"gender\",\"ip\",\"ZB Status\",\"ZB Sub Status\",\"ZB Account\",\"ZB Domain\",\"ZB First Name\",\"ZB Last Name\",\"ZB Gender\",\"ZB Free Email\",\"ZB MX Found\",\"ZB MX Record\",\"ZB SMTP Provider\",\"ZB Did You Mean\"\n\"disposable@example.com\",\"
298
+
299
+ First\",\"Last\",\"male\",\"127.0.0.1\",\"do_not_mail\",\"disposable\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"invalid@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"invalid\",\"mailbox_not_found\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"valid@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"valid\",\"\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"toxic@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"do_not_mail\",\"toxic\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"donotmail@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"do_not_mail\",\"role_based\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"spamtrap@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"spamtrap\",\"\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"abuse@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"abuse\",\"\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"unknown@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"unknown\",\"mail_server_temporary_error\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"catch_all@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"catch-all\",\"\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"antispam_system@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"unknown\",\"antispam_system\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"does_not_accept_mail@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"invalid\",\"does_not_accept_mail\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"exception_occurred@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"unknown\",\"exception_occurred\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"failed_smtp_connection@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"unknown\",\"failed_smtp_connection\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"failed_syntax_check@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"invalid\",\"failed_syntax_check\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"forcible_disconnect@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"unknown\",\"forcible_disconnect\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"global_suppression@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"do_not_mail\",\"global_suppression\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"greylisted@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"unknown\",\"greylisted\",\"\",\"\",\"zero\",\"
300
+
301
+ bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"leading_period_removed@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"valid\",\"leading_period_removed\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"mail_server_did_not_respond@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"unknown\",\"mail_server_did_not_respond\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"mail_server_temporary_error@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"unknown\",\"mail_server_temporary_error\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"mailbox_quota_exceeded@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"invalid\",\"mailbox_quota_exceeded\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"mailbox_not_found@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"invalid\",\"mailbox_not_found\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"no_dns_entries@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"invalid\",\"no_dns_entries\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"possible_trap@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"do_not_mail\",\"possible_trap\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"possible_typo@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"invalid\",\"possible_typo\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"role_based@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"do_not_mail\",\"role_based\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"timeout_exceeded@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"unknown\",\"timeout_exceeded\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"unroutable_ip_address@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"invalid\",\"unroutable_ip_address\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"free_email@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"valid\",\"\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"True\",\"true\",\"mx.example.com\",\"example\",\"\"\n\"role_based_catch_all@example.com\",\"First\",\"Last\",\"male\",\"127.0.0.1\",\"do_not_mail\",\"role_based_catch_all\",\"\",\"\",\"zero\",\"bounce\",\"male\",\"False\",\"true\",\"mx.example.com\",\"example\",\"\"\n"
302
+ ```
303
+
304
+ Eliminar archivo
305
+ ```ruby
306
+ file_id = "75d854a6-565c-49f9-b4c8-b3344480ec4c"
307
+ => "75d854a6-565c-49f9-b4c8-b3344480ec4c"
308
+ Zerobounce.validate_file_delete(file_id)
309
+ =>
310
+ {"success"=>true,
311
+ "message"=>"File Deleted",
312
+ "file_name"=>"validation.csv",
313
+ "file_id"=>"75d854a6-565c-49f9-b4c8-b3344480ec4
314
+
315
+ c"}
316
+ ```
317
+
318
+ ##### Puntuación de IA
319
+
320
+ Enviar archivo
321
+ ```ruby
322
+ scoring_file_path = File.join(Dir.pwd, 'files', 'scoring.csv')
323
+ => "/home/odin/zb/wrappers/ruby-test/files/scoring.csv"
324
+ Zerobounce.scoring_file_send(scoring_file_path)
325
+ =>
326
+ {"success"=>true,
327
+ "message"=>"File Accepted",
328
+ "file_name"=>"scoring.csv",
329
+ "file_id"=>"89fb7262-b845-4fa1-aa25-e486347ec64e"}
330
+ ### se requerirá el file_id para los próximos pasos
331
+ ### parámetros opcionales
332
+ email_address_column: 1,
333
+ has_header_row: true,
334
+ return_url: nil ### URL de devolución de resultados
335
+ ### Zerobounce.scoring_file_send(scoring_file_path, email_address_column: 1)
336
+ ```
337
+
338
+ Verificar archivo
339
+ ```ruby
340
+ file_id = "89fb7262-b845-4fa1-aa25-e486347ec64e"
341
+ => "89fb7262-b845-4fa1-aa25-e486347ec64e"
342
+ Zerobounce.scoring_file_check(file_id)
343
+ =>
344
+ {"success"=>true,
345
+ "file_id"=>"89fb7262-b845-4fa1-aa25-e486347ec64e",
346
+ "file_name"=>"scoring.csv",
347
+ "upload_date"=>"2023-04-28T16:57:18Z",
348
+ "file_status"=>"Complete",
349
+ "complete_percentage"=>"100% Complete.",
350
+ "return_url"=>nil}
351
+ ```
352
+
353
+ Obtener archivo
354
+ ```ruby
355
+ file_id = "89fb7262-b845-4fa1-aa25-e486347ec64e"
356
+ => "89fb7262-b845-4fa1-aa25-e486347ec64e"
357
+ Zerobounce.scoring_file_get(file_id)
358
+ => "\"email\",\"ZeroBounceQualityScore\"\r\n\"disposable@example.com\",\"0\"\r\n\"invalid@example.com\",\"10\"\r\n\"valid@example.com\",\"10\"\r\n\"toxic@example.com\",\"2\"\r\n\"donotmail@example.com\",\"0\"\r\n\"spamtrap@example.com\",\"0\"\r\n\"abuse@example.com\",\"10\"\r\n\"unknown@example.com\",\"10\"\r\n\"catch_all@example.com\",\"10\"\r\n\"antispam_system@example.com\",\"0\"\r\n\"does_not_accept_mail@example.com\",\"0\"\r\n\"exception_occurred@example.com\",\"0\"\r\n\"failed_smtp_connection@example.com\",\"0\"\r\n\"failed_syntax_check@example.com\",\"0\"\r\n\"forcible_disconnect@example.com\",\"0\"\r\n\"global_suppression@example.com\",\"0\"\r\n\"greylisted@example.com\",\"0\"\r\n\"leading_period_removed@example.com\",\"0\"\r\n\"mail_server_did_not_respond@example.com\",\"0\"\r\n\"mail_server_temporary_error@example.com\",\"0\"\r\n\"mailbox_quota_exceeded@example.com\",\"0\"\r\n\"mailbox_not_found@example.com\",\"0\"\r\n\"no_dns_entries@example.com\",\"0\"\r\n\"possible_trap@example.com\",\"0\"\r\n\"possible_typo@example.com\",\"0\"\r\n\"role_based@example.com\",\"0\"\r\n\"timeout_exceeded@example.com\",\"0\"\r\n\"unroutable_ip_address@example.com\",\"0\"\r\n\"free_email@example.com\",\"0\"\r\n\"role_based_catch_all@example.com\",\"0\""
359
+ ```
360
+
361
+ Eliminar archivo
362
+ ```ruby
363
+ file_id = "89fb7262-b845-4fa1-aa25-e486347ec64e"
364
+
365
+
366
+ => "89fb7262-b845-4fa1-aa25-e486347ec64e"
367
+ Zerobounce.validate_file_delete(file_id)
368
+ => {"success"=>false, "message"=>"File cannot be found."}
369
+ ```
370
+
371
+ ### Email Finder
372
+
373
+ Guess Format
374
+ ```ruby
375
+ Zerobounce.guessformat("zerobounce.net")
376
+ =>
377
+ {"email"=>"",
378
+ "domain"=>"zerobounce.net",
379
+ "format"=>"first.last",
380
+ "status"=>"",
381
+ "sub_status"=>"",
382
+ "confidence"=>"high",
383
+ "did_you_mean"=>"",
384
+ "failure_reason"=>"",
385
+ "other_domain_formats"=>
386
+ [{"format"=>"first", "confidence"=>"high"},
387
+ {"format"=>"last.first", "confidence"=>"high"},
388
+ {"format"=>"lfirst", "confidence"=>"high"},
389
+ {"format"=>"lastfirst", "confidence"=>"high"},
390
+ {"format"=>"firstl", "confidence"=>"high"},
391
+ {"format"=>"last", "confidence"=>"medium"},
392
+ {"format"=>"first.middle.last", "confidence"=>"medium"},
393
+ {"format"=>"first-last", "confidence"=>"medium"},
394
+ {"format"=>"l.first", "confidence"=>"medium"},
395
+ {"format"=>"f.last", "confidence"=>"medium"},
396
+ {"format"=>"f-last", "confidence"=>"medium"},
397
+ {"format"=>"first.l", "confidence"=>"medium"},
398
+ {"format"=>"first-l", "confidence"=>"medium"},
399
+ {"format"=>"firstlast", "confidence"=>"medium"},
400
+ {"format"=>"first_l", "confidence"=>"medium"},
401
+ {"format"=>"f_last", "confidence"=>"medium"},
402
+ {"format"=>"last.f", "confidence"=>"medium"},
403
+ {"format"=>"last-f", "confidence"=>"medium"},
404
+ {"format"=>"last-first", "confidence"=>"medium"},
405
+ {"format"=>"first_last", "confidence"=>"medium"},
406
+ {"format"=>"last_f", "confidence"=>"medium"},
407
+ {"format"=>"last_first", "confidence"=>"medium"},
408
+ {"format"=>"flast", "confidence"=>"medium"},
409
+ {"format"=>"lastf", "confidence"=>"medium"},
410
+ {"format"=>"l-first", "confidence"=>"low"},
411
+ {"format"=>"l_first", "confidence"=>"low"}]}
412
+ # Zerobounce.guessformat("zerobounce.net", first_name: "John", middle_name: 'Deere', last_name: "Doe")
413
+ ```
414
+
415
+
416
+ #### Desarrollo
417
+
418
+ Después de revisar el repositorio, ejecuta las pruebas:
419
+ ```bash
420
+ rspec --init ### si es necesario
421
+ bundle exec rspec
422
+ ```
423
+
424
+ Deberías ver una salida como esta:
425
+ ```bash
426
+ Run options: include {:focus=>true}
427
+ running live tests
428
+ .....................................................
429
+
430
+ Finished in 6.81 seconds (files took 0.40587 seconds to load)
431
+ 53 examples, 0 failures
432
+ ```
433
+
434
+ ##### Parámetros de prueba
435
+ Las pruebas utilizan los siguientes parámetros de entorno:
436
+ TEST {unit|live} influye en si se ejecutan las pruebas simuladas de unidad o se utiliza el servidor en vivo (se pueden utilizar créditos si eliges hacer esto)
437
+ ZEROBOUNCE_API_KEY {<zerobounce-api-key-value>} esta clave se utiliza para realizar solicitudes al servidor en vivo; también se utiliza en las pruebas simuladas como un ejemplo de clave válida (cualquier valor funcionará para las pruebas simuladas)
438
+ INCORRECT_API_KEY {cualquier cadena sin espacios en blanco que no sea una clave válida} se utiliza para pruebas en las que las solicitudes deben fallar debido al valor de la clave de la API.
439
+
440
+ Para configurarlos:
441
+ ```bash
442
+ export ZEROBOUNCE_API_KEY=99e7ef20ceea4480a173b07b1be75371
443
+ export INCORRECT_API_KEY=thiskeyisinvalidorotherwiseincorrect
444
+ export TEST=unit
445
+ ```
446
+
447
+ Se proporciona un archivo .env.sample.
448
+
449
+ Las pruebas simuladas se generaron utilizando webmock y vcr. Esto significa que se realizaron solicitudes reales y se grabaron en los archivos .yml bajo spec/cassettes con una clave API válida en ese momento utilizada con fines de prueba. Sin embargo, esta clave se ha invalidado en el ínterin, pero se proporciona en el archivo .env.sample para que las pruebas simuladas funcionen. Si no desea utilizar esta clave para simulaciones, puede reemplazarla con cualquier valor en los archivos .yml bajo spec/cassettes o eliminarlos todos y volver a ejecutar las pruebas para que vcr los grabe con una nueva clave.
@@ -7,11 +7,11 @@ require 'rest-client'
7
7
 
8
8
 
9
9
  module Zerobounce
10
-
10
+
11
11
  # Sends the HTTP request.
12
12
  class BaseRequest
13
13
 
14
- protected
14
+ protected
15
15
 
16
16
  def self._get(root, path, params, content_type='application/json')
17
17
 
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rest-client'
4
+ require 'dotenv'
4
5
 
5
6
  module Zerobounce
6
7
  # Configuration object for Zerobounce.
@@ -26,7 +27,8 @@ module Zerobounce
26
27
  attr_accessor :mock
27
28
 
28
29
  def initialize(mock=false)
29
- self.host = 'https://api.zerobounce.net'
30
+ if File.file?(".env") then Dotenv.load(".env") else Dotenv.load end
31
+ self.host = 'https://api.zerobounce.in'
30
32
  self.apikey = ENV['ZEROBOUNCE_API_KEY']
31
33
  self.valid_statuses = %i[valid catch_all]
32
34
  self.headers = { user_agent: "ZerobounceRubyGem/#{Zerobounce::VERSION}" }
@@ -3,15 +3,15 @@
3
3
  require 'zerobounce/base_request'
4
4
 
5
5
  module Zerobounce
6
-
6
+
7
7
  # Sends the HTTP request.
8
8
  class MockRequest < BaseRequest
9
-
9
+
10
10
  def self.get(path, params, content_type='application/json')
11
11
  response = self._get(Zerobounce::API_ROOT_URL, path, params, content_type)
12
12
  if response.headers[:content_type] == 'application/json'
13
13
  response_body = response.body
14
- response_body_json = JSON.parse(response_body)
14
+ response_body_json = JSON.parse(response_body)
15
15
 
16
16
  raise (response_body_json['error']) if response_body_json.key?('error')
17
17
  raise (response_body_json['errors'][0]['error']) \
@@ -19,7 +19,7 @@ module Zerobounce
19
19
  response_body_json['errors'].length > 0
20
20
 
21
21
  return response_body_json
22
- else
22
+ else
23
23
  return response
24
24
  end
25
25
  end
@@ -46,7 +46,7 @@ module Zerobounce
46
46
  content_type, filepath)
47
47
  if response.headers[:content_type] == 'application/json'
48
48
  response_body = response.body
49
- response_body_json = JSON.parse(response_body)
49
+ response_body_json = JSON.parse(response_body)
50
50
 
51
51
  raise (response_body_json['error']) if response_body_json.key?('error')
52
52
  raise (response_body_json['errors'][0]['error']) \
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'stringio'
3
4
  require 'zerobounce/base_request'
4
5
 
5
6
  module Zerobounce
6
-
7
+
7
8
  # Sends the HTTP request.
8
9
  class Request < BaseRequest
9
10
 
@@ -11,15 +12,18 @@ module Zerobounce
11
12
  response = self._get(Zerobounce::API_ROOT_URL, path, params, content_type)
12
13
  if response.headers[:content_type] == 'application/json'
13
14
  response_body = response.body
14
- response_body_json = JSON.parse(response_body)
15
+ response_body_json = JSON.parse(response_body)
15
16
 
16
17
  raise (response_body_json['error']) if response_body_json.key?('error')
18
+ raise (response_body_json['Message']) \
19
+ if response_body_json.key?('Message') and \
20
+ response_body_json.length == 1
17
21
  raise (response_body_json['errors'][0]['error']) \
18
22
  if response_body_json.key?('errors') and \
19
23
  response_body_json['errors'].length > 0
20
24
 
21
25
  return response_body_json
22
- else
26
+ else
23
27
  return response
24
28
  end
25
29
  end
@@ -37,7 +41,9 @@ module Zerobounce
37
41
 
38
42
  return response_body_json
39
43
  else
40
- return response.body
44
+ content = StringIO.new(response.body)
45
+ content.set_encoding_by_bom
46
+ return content.string
41
47
  end
42
48
  end
43
49
 
@@ -46,7 +52,7 @@ module Zerobounce
46
52
  content_type, filepath)
47
53
  if response.headers[:content_type] == 'application/json'
48
54
  response_body = response.body
49
- response_body_json = JSON.parse(response_body)
55
+ response_body_json = JSON.parse(response_body)
50
56
 
51
57
  raise (response_body_json['error']) if response_body_json.key?('error')
52
58
  raise (response_body_json['errors'][0]['error']) \
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Zerobounce
4
4
  # The version of the gem.
5
- VERSION = '1.0.1'
5
+ VERSION = '1.1.1'
6
6
  end
data/lib/zerobounce.rb CHANGED
@@ -11,7 +11,7 @@ require 'zerobounce/configuration'
11
11
 
12
12
  # Validate an email address with Zerobounce.net
13
13
  module Zerobounce
14
-
14
+
15
15
  API_ROOT_URL = 'https://api.zerobounce.in/v2'
16
16
  BULK_API_ROOT_URL = 'https://bulkapi.zerobounce.in/v2'
17
17
 
@@ -44,7 +44,7 @@ module Zerobounce
44
44
  #
45
45
  # @param [String] :email The email address to validate.
46
46
  # @option [String] :ip_address IP address corresponding to the email.
47
- #
47
+ #
48
48
  # @return [Hash]
49
49
  # {
50
50
  # "address": "valid@example.com",
@@ -96,16 +96,16 @@ module Zerobounce
96
96
  # @param [String] email
97
97
  # @return [Boolean]
98
98
  # def invalid?(email)
99
- # # todo:
99
+ # # todo:
100
100
  # validate(email: email).invalid?
101
101
  # end
102
102
 
103
- # Get API usage
104
- #
103
+ # Get API usage
104
+ #
105
105
  # @param [Date] start_date
106
106
  # @param [Date] end_date
107
- #
108
- # @return [Hash]
107
+ #
108
+ # @return [Hash]
109
109
  # {
110
110
  # "total": 5,
111
111
  # "status_valid": 4,
@@ -156,8 +156,8 @@ module Zerobounce
156
156
  # Get Activty for email
157
157
  #
158
158
  # @param [String] :email Email to get activity for
159
- #
160
- # @return [Hash]
159
+ #
160
+ # @return [Hash]
161
161
  # {
162
162
  # "found": true,
163
163
  # "active_in_days": "180"
@@ -168,10 +168,10 @@ module Zerobounce
168
168
  end
169
169
 
170
170
  # Validate email batch
171
- #
171
+ #
172
172
  # @param [Array] :emails List of email addresses to validate.
173
173
  # @option [Array] :ip_addresses Corresponding list of IP addresses.
174
- #
174
+ #
175
175
  # @return [Array] list of validate result for each element
176
176
  # [
177
177
  # {
@@ -220,7 +220,7 @@ module Zerobounce
220
220
  end
221
221
 
222
222
  # Validate CSV file
223
- #
223
+ #
224
224
  # @param [String] :filepath Path to the file to be uploaded
225
225
  # @option [Int] :email_address_column Specify which column the email address is on
226
226
  # @option [Int] :first_name_column Specify which column the first name is on
@@ -228,7 +228,7 @@ module Zerobounce
228
228
  # @option [Int] :gender_column Specify which column the gender is on
229
229
  # @option [Int] :has_header_row Specify whether the file includes a header row or not
230
230
  # @option [Int] :return_url Specify a callback URL (if nil, no callback will be performed)
231
- #
231
+ #
232
232
  # @return [Hash]
233
233
  # {
234
234
  # "success": true,
@@ -247,19 +247,19 @@ module Zerobounce
247
247
  )
248
248
  params = {
249
249
  email_address_column: email_address_column,
250
- first_name_column: first_name_column,
251
- last_name_column: last_name_column,
252
- gender_column: gender_column,
253
250
  has_header_row: has_header_row,
254
251
  }
252
+ params[:first_name_column] = first_name_column if first_name_column
253
+ params[:last_name_column] = last_name_column if last_name_column
254
+ params[:gender_column] = gender_column if gender_column
255
255
  params[:return_url] = return_url if return_url
256
256
  @@request.bulk_post('sendfile', params, 'multipart/form-data', filepath)
257
257
  end
258
258
 
259
259
  # Get validate file status
260
- #
260
+ #
261
261
  # @param [String] :file_id Id of the file.
262
- #
262
+ #
263
263
  # @return [Hash]
264
264
  # {
265
265
  # "success": true,
@@ -270,28 +270,28 @@ module Zerobounce
270
270
  # "complete_percentage": "100%",
271
271
  # "error_reason": null,
272
272
  # "return_url": null
273
- # }
273
+ # }
274
274
  def validate_file_check(file_id)
275
275
  # todo:
276
276
  params = {file_id: file_id}
277
277
  @@request.bulk_get('filestatus', params)
278
278
  end
279
279
 
280
- # Get validate results file
281
- #
280
+ # Get validate results file
281
+ #
282
282
  # @param [String] :file_id Id of the file.
283
- #
284
- # @return [String/File?]
283
+ #
284
+ # @return [String/File?]
285
285
  def validate_file_get(file_id)
286
286
  # todo:
287
287
  params = {file_id: file_id}
288
288
  @@request.bulk_get('getfile', params)
289
289
  end
290
290
 
291
- # Delete validate file
292
- #
291
+ # Delete validate file
292
+ #
293
293
  # @param file_id Id of the file.
294
- #
294
+ #
295
295
  # @return [Hash]
296
296
  # {
297
297
  # "success": true,
@@ -306,12 +306,12 @@ module Zerobounce
306
306
  end
307
307
 
308
308
  # Score CSV file
309
- #
309
+ #
310
310
  # @param [String] :filepath Path to the file to be uploaded
311
311
  # @option [Int] :email_address_column Specify which column the email address is on
312
312
  # @option [Int] :has_header_row Specify whether the file includes a header row or not
313
313
  # @option [Int] :return_url Specify a callback URL (if nil, no callback will be performed)
314
- #
314
+ #
315
315
  # @return [Hash]
316
316
  # {
317
317
  # "success": true,
@@ -333,11 +333,11 @@ module Zerobounce
333
333
  @@request.bulk_post('scoring/sendfile', params, 'multipart/form-data', filepath)
334
334
  end
335
335
 
336
- # Get validate results file
337
- #
336
+ # Get validate results file
337
+ #
338
338
  # @param [String] :file_id Id of the file.
339
- #
340
- # @return [String/File?]
339
+ #
340
+ # @return [String/File?]
341
341
  def scoring_file_get(file_id)
342
342
  # todo:
343
343
  params = {file_id: file_id}
@@ -345,9 +345,9 @@ module Zerobounce
345
345
  end
346
346
 
347
347
  # Get validate file status
348
- #
348
+ #
349
349
  # @param [String] :file_id Id of the file.
350
- #
350
+ #
351
351
  # @return [Hash]
352
352
  # {
353
353
  # "success": true,
@@ -357,16 +357,16 @@ module Zerobounce
357
357
  # "file_status": "Complete",
358
358
  # "complete_percentage": "100% Complete.",
359
359
  # "return_url": null
360
- # }
360
+ # }
361
361
  def scoring_file_check(file_id)
362
362
  params = {file_id: file_id}
363
363
  @@request.bulk_get('scoring/filestatus', params)
364
364
  end
365
365
 
366
- # Delete validate file
367
- #
366
+ # Delete validate file
367
+ #
368
368
  # @param file_id Id of the file.
369
- #
369
+ #
370
370
  # @return [Hash]
371
371
  # {
372
372
  # "success": true,
@@ -375,10 +375,73 @@ module Zerobounce
375
375
  # "file_id": "6d44a908-7283-42a9-aa5f-9e57b16f84bd"
376
376
  # }
377
377
  def scoring_file_delete(file_id)
378
- # todo:
379
378
  params = {file_id: file_id}
380
379
  @@request.bulk_get('scoring/deletefile', params)
381
380
  end
382
381
 
382
+ # Guess email formatDomain to guess format for
383
+ #
384
+ # @param [String] domain Domain to guess format for
385
+ #
386
+ # @option [String] first_name First name of target.
387
+ # @option [String] middle_name Middle name of target.
388
+ # @option [String] last_name Last name of target.
389
+ #
390
+ # @return [Hash]
391
+ # {
392
+ # "email"=>"",
393
+ # "domain"=>"zerobounce.net",
394
+ # "format"=>"first.last",
395
+ # "status"=>"",
396
+ # "sub_status"=>"",
397
+ # "confidence"=>"high",
398
+ # "did_you_mean"=>"",
399
+ # "failure_reason"=>"",
400
+ # "other_domain_formats"=> [
401
+ # {"format"=>"first", "confidence"=>"high"},
402
+ # {"format"=>"last.first", "confidence"=>"high"},
403
+ # {"format"=>"lfirst", "confidence"=>"high"},
404
+ # {"format"=>"lastfirst", "confidence"=>"high"},
405
+ # {"format"=>"firstl", "confidence"=>"high"},
406
+ # {"format"=>"last", "confidence"=>"medium"},
407
+ # {"format"=>"first.middle.last", "confidence"=>"medium"},
408
+ # {"format"=>"first-last", "confidence"=>"medium"},
409
+ # {"format"=>"l.first", "confidence"=>"medium"},
410
+ # {"format"=>"f.last", "confidence"=>"medium"},
411
+ # {"format"=>"f-last", "confidence"=>"medium"},
412
+ # {"format"=>"first.l", "confidence"=>"medium"},
413
+ # {"format"=>"first-l", "confidence"=>"medium"},
414
+ # {"format"=>"firstlast", "confidence"=>"medium"},
415
+ # {"format"=>"first_l", "confidence"=>"medium"},
416
+ # {"format"=>"f_last", "confidence"=>"medium"},
417
+ # {"format"=>"last.f", "confidence"=>"medium"},
418
+ # {"format"=>"last-f", "confidence"=>"medium"},
419
+ # {"format"=>"last-first", "confidence"=>"medium"},
420
+ # {"format"=>"first_last", "confidence"=>"medium"},
421
+ # {"format"=>"last_f", "confidence"=>"medium"},
422
+ # {"format"=>"last_first", "confidence"=>"medium"},
423
+ # {"format"=>"flast", "confidence"=>"medium"},
424
+ # {"format"=>"lastf", "confidence"=>"medium"},
425
+ # {"format"=>"l-first", "confidence"=>"low"},
426
+ # {"format"=>"l_first", "confidence"=>"low"}
427
+ # ]
428
+ # }
429
+ def guessformat(domain, first_name: '', middle_name: '', last_name: '')
430
+ params = {
431
+ domain: domain
432
+ }
433
+ unless first_name.empty?
434
+ params['first_name'] = first_name
435
+ end
436
+ unless middle_name.empty?
437
+ params['middle_name'] = middle_name
438
+ end
439
+ unless last_name.empty?
440
+ params['last_name'] = last_name
441
+ end
442
+
443
+ @@request.get('guessformat', params)
444
+ end
445
+
383
446
  end
384
447
  end
data/zerobounce.gemspec CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
27
27
  spec.required_ruby_version = '>= 2.5'
28
28
 
29
29
  spec.add_dependency 'rest-client', '~>2.1'
30
+ spec.add_dependency 'dotenv', '~> 2.8.1'
30
31
 
31
32
  spec.add_development_dependency 'bundler', '~> 2.4.6'
32
33
  spec.add_development_dependency 'pry', '~> 0.14.1'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zerobounceindia-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zero Bounce India
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-13 00:00:00.000000000 Z
11
+ date: 2024-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: dotenv
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.8.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.8.1
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -231,13 +245,14 @@ files:
231
245
  - LICENSE
232
246
  - LICENSE.txt
233
247
  - README.md
234
- - README_es.md
235
248
  - Rakefile
236
249
  - bin/bundle
237
250
  - bin/console
238
251
  - bin/setup
239
252
  - data/zerobounce-ai-scoring.csv
240
253
  - data/zerobounce-batch-validation.csv
254
+ - documentation.md
255
+ - documentation_es.md
241
256
  - files/scoring.csv
242
257
  - files/validation.csv
243
258
  - files/zerobounce-ai-scoring.csv