zerobounce-sdk 1.1.0 → 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: f187873eefae835fa3cf0d83ee742ecac903880e67162f81b553e1a288170d2c
4
- data.tar.gz: d169d4722b1fbfef58486a6495e144164fc5d1e2ca25d3c7d40ac691627cd39e
3
+ metadata.gz: 804ff0380f6e305c6b80ceaec623ed06f014927074ebef93598b9dab3d23c988
4
+ data.tar.gz: 64ff74c48f382f6cb50d29c1d9f6e95d149929289e3971f27c2e1cfcc7088706
5
5
  SHA512:
6
- metadata.gz: cf05baf952979ea120118261ff907528188e6d50677ad40390159338db8d830918d9064399443ad0d3d08cd2f174bed769466965660e4b8c11e568aaa3f2a6d8
7
- data.tar.gz: 689c70548c2b6b700ebc9b48cc8326ff8f7bd0e61713f48ad73c1fda9cbb003e448117678161a5a8dcb320da05343263945cb58ca2cb767b1e3a11d1311c1b65
6
+ metadata.gz: 8c4b82770126e3f7f0ef3699688ad11bf526163df669d3a6d637ff87d183955b1876e99e2a9e953eebb5b4102863ab8ff5204417a77d7e47722fe3b14977abcf
7
+ data.tar.gz: a9ebe2bd4422d96e85ffd5331456cb0669090a1ade71f828249b32a44730e843b05ffa24148673b353130b4e896075acf035d59c9963bc83ad60dcb841c56f4f
data/.gitignore CHANGED
@@ -57,3 +57,8 @@ build-iPhoneSimulator/
57
57
 
58
58
  # Used by RSpec
59
59
  .rspec_status
60
+
61
+
62
+ # Log files
63
+ output.err
64
+ output.log
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zerobounce-sdk (1.1.0)
4
+ zerobounce-sdk (1.1.1)
5
+ dotenv (~> 2.8.1)
5
6
  rest-client (~> 2.1)
6
7
 
7
8
  GEM
@@ -17,6 +18,7 @@ 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)
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
data/documentation.md CHANGED
@@ -26,7 +26,7 @@ Zerobounce.configure do |config|
26
26
  ...
27
27
  end
28
28
  ```
29
- or
29
+ or
30
30
  ```
31
31
  Zerobounce.config.apikey = '<zerobounce-api-key>'
32
32
  ...
@@ -88,7 +88,7 @@ Zerobounce.api_usage(Date.today, Date.today)
88
88
 
89
89
  Validate single eMail
90
90
  ```ruby
91
- Zerobounce.validate('valid@example.com')
91
+ Zerobounce.validate('valid@example.com')
92
92
  ### Zerobounce.validate('valid@example.com', '192.168.0.1') # optional IP address
93
93
  =>
94
94
  {"address"=>"valid@example.com",
@@ -122,11 +122,11 @@ emails
122
122
  "toxic@example.com",
123
123
  "donotmail@example.com",
124
124
  "spamtrap@example.com"]
125
-
126
- ### ip_addresses
125
+
126
+ ### ip_addresses
127
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"]
128
128
  ### Zerobounce.validate_batch(emails, ip_addresses) # optional ip_addresses parameter
129
-
129
+
130
130
  Zerobounce.validate_batch(emails)
131
131
  =>
132
132
  [{"address"=>"disposable@example.com",
@@ -259,14 +259,14 @@ Send file
259
259
  "file_name"=>"validation.csv",
260
260
  "file_id"=>"75d854a6-565c-49f9-b4c8-b3344480ec4c"}
261
261
  ### file_id will be required for next steps
262
- ### optional named parameters:
262
+ ### optional named parameters:
263
263
  email_address_column: 1,
264
264
  first_name_column: 2,
265
265
  last_name_column: 3,
266
266
  gender_column: 4,
267
267
  has_header_row: true,
268
268
  return_url: nil ### results callback url
269
- ### Zerobounce.validate_file_send(validate_file_path, email_address_column: 1, gender_column: 4)
269
+ ### Zerobounce.validate_file_send(validate_file_path, email_address_column: 1, gender_column: 4)
270
270
  ```
271
271
 
272
272
  Check file
@@ -356,6 +356,50 @@ Zerobounce.validate_file_delete(file_id)
356
356
  => {"success"=>false, "message"=>"File cannot be found."}
357
357
  ```
358
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
+
359
403
 
360
404
  #### Development
361
405
 
data/documentation_es.md CHANGED
@@ -88,7 +88,7 @@ Zerobounce.api_usage(Date.today, Date.today)
88
88
 
89
89
  Validar un solo correo electrónico
90
90
  ```ruby
91
- Zerobounce.validate('valid@example.com')
91
+ Zerobounce.validate('valid@example.com')
92
92
  ### Zerobounce.validate('valid@example.com', '192.168.0.1') # dirección IP opcional
93
93
  =>
94
94
  {"address"=>"valid@example.com",
@@ -124,11 +124,11 @@ emails
124
124
  "toxic@example.com",
125
125
  "donotmail@example.com",
126
126
  "spamtrap@example.com"]
127
-
128
- ### ip_addresses
127
+
128
+ ### ip_addresses
129
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
130
  ### Zerobounce.validate_batch(emails, ip_addresses) # parámetro ip_addresses opcional
131
-
131
+
132
132
  Zerobounce.validate_batch(emails)
133
133
  =>
134
134
  [{"address"=>"disposable@example.com",
@@ -263,14 +263,14 @@ Zerobounce.validate_file_send(validate_file_path)
263
263
  "file_name"=>"validation.csv",
264
264
  "file_id"=>"75d854a6-565c-49f9-b4c8-b3344480ec4c"}
265
265
  ### se requerirá el file_id para los próximos pasos
266
- ### parámetros opcionales:
266
+ ### parámetros opcionales:
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 ### URL de devolución de resultados
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
  Verificar archivo
@@ -368,6 +368,50 @@ Zerobounce.validate_file_delete(file_id)
368
368
  => {"success"=>false, "message"=>"File cannot be found."}
369
369
  ```
370
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
+
371
415
 
372
416
  #### Desarrollo
373
417
 
@@ -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,6 +27,7 @@ module Zerobounce
26
27
  attr_accessor :mock
27
28
 
28
29
  def initialize(mock=false)
30
+ if File.file?(".env") then Dotenv.load(".env") else Dotenv.load end
29
31
  self.host = 'https://api.zerobounce.net'
30
32
  self.apikey = ENV['ZEROBOUNCE_API_KEY']
31
33
  self.valid_statuses = %i[valid catch_all]
@@ -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.1.0'
5
+ VERSION = '1.1.1'
6
6
  end