emailhunter 0.9.0 → 1.0.0

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: d9cca816b859af71470e2f574c274e195f40957e90a2824874f6f674a39d0198
4
- data.tar.gz: a77dff70b14ff58e51da7ba5593aa6b224dcfed6f15da4781a77c0e77ed4ff49
3
+ metadata.gz: aa2d9e9cc40ed470a2704f6cb875ade4b23bfb3f256ea535fc9ec772aa6d36f7
4
+ data.tar.gz: b16e0822b7b5362ac3ce01435467db482dd867d97abd9a394b40394c7f67989a
5
5
  SHA512:
6
- metadata.gz: 9b890e80434096d88af8414aaa387a28d1ff0afbbdc177eddd8284e191092d8335b06c50d874bbc48c23e5d80271b289db98ad85c63c5664e0819f90e3545227
7
- data.tar.gz: fab3c8de09ef1c3ae7ad59c82519422123982e3f996d9b53b5f65bd6b7cb15e98139542d5541b2f6e289f394772b996a141bf89e01528c46a9934bb10ad42200
6
+ metadata.gz: 119c49c0e20229684a533a5bd000c33b5ba7470d2bc0ddcb075bfab48b705b1f0fe84e59227e2ed621c4ec27b335328189d7920b9db80037a5ad674864f94c22
7
+ data.tar.gz: 1de4508d1b3289004fe3a5603e48c2f03ce1b5cd4334c6a2b2efcf846e52a4f9966a2224639a342d790f0bd05b1adbcb5e322358567cae8d979930e526d7f6f4
data/emailhunter.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
18
  spec.require_paths = ['lib']
19
19
 
20
- spec.add_development_dependency 'bundler', '~> 1.8'
20
+ spec.add_development_dependency 'bundler', '~> 2.1'
21
21
  spec.add_development_dependency 'rake', '~> 10.0'
22
22
  spec.add_development_dependency 'rspec'
23
23
  spec.add_development_dependency 'typhoeus'
@@ -7,7 +7,8 @@ API_ACCOUNT_URL = 'https://api.hunter.io/v2/account?'
7
7
 
8
8
  module EmailHunter
9
9
  class Account
10
- attr_reader :result, :first_name, :last_name, :email, :plan_name, :plan_level, :reset_date, :team_id, :calls, :requests
10
+ attr_reader :result, :first_name, :last_name, :email, :plan_name, :plan_level, :reset_date, :team_id, :calls,
11
+ :requests
11
12
 
12
13
  def initialize(key)
13
14
  @key = key
@@ -5,22 +5,24 @@ API_COUNT_URL = 'https://api.hunter.io/v2/email-count?'.freeze
5
5
 
6
6
  module EmailHunter
7
7
  class Count
8
- attr_reader :data, :meta
8
+ attr_reader :data, :meta, :domain
9
9
 
10
10
  def initialize(domain)
11
11
  @domain = domain
12
12
  end
13
13
 
14
14
  def hunt
15
- response = apiresponse
16
- Struct.new(*response.keys).new(*response.values) unless response.empty?
15
+ Struct.new(*data.keys).new(*data.values)
17
16
  end
18
17
 
19
- private
20
-
21
18
  def apiresponse
22
- response = Faraday.new("#{API_COUNT_URL}domain=#{@domain}").get
23
- response.success? ? JSON.parse(response.body, { symbolize_names: true }) : []
19
+ @data ||= begin
20
+ response = Faraday.new("#{API_COUNT_URL}domain=#{domain}").get
21
+
22
+ return [] unless response.success?
23
+
24
+ JSON.parse(response.body, { symbolize_names: true })
25
+ end
24
26
  end
25
27
  end
26
28
  end
@@ -7,7 +7,7 @@ API_EXIST_URL = 'https://api.emailhunter.co/v1/exist?'
7
7
 
8
8
  module EmailHunter
9
9
  class Exist
10
- attr_reader :status, :email, :exist, :sources
10
+ attr_reader :status, :email, :exist, :sources, :key
11
11
 
12
12
  def initialize(email, key)
13
13
  @email = email
@@ -15,15 +15,17 @@ module EmailHunter
15
15
  end
16
16
 
17
17
  def hunt
18
- response = apiresponse
19
- Struct.new(*response.keys).new(*response.values) unless response.empty?
18
+ Struct.new(*data.keys).new(*data.values)
20
19
  end
21
20
 
22
- private
21
+ def data
22
+ @data ||= begin
23
+ response = Faraday.new("#{API_EXIST_URL}email=#{email}&api_key=#{key}").get
23
24
 
24
- def apiresponse
25
- response = Faraday.new("#{API_EXIST_URL}email=#{@email}&api_key=#{@key}").get
26
- response.success? ? JSON.parse(response.body, { symbolize_names: true }) : []
25
+ return {} unless response.success?
26
+
27
+ JSON.parse(response.body, { symbolize_names: true })
28
+ end
27
29
  end
28
30
  end
29
31
  end
@@ -7,7 +7,7 @@ API_FINDER_URL = 'https://api.hunter.io/v2/email-finder?'
7
7
 
8
8
  module EmailHunter
9
9
  class Finder
10
- attr_reader :email, :score, :sources, :domain, :meta
10
+ attr_reader :email, :score, :sources, :domain, :meta, :key, :first_name, :last_name
11
11
 
12
12
  def initialize(domain, first_name, last_name, key)
13
13
  @domain = domain
@@ -17,15 +17,17 @@ module EmailHunter
17
17
  end
18
18
 
19
19
  def hunt
20
- response = apiresponse
21
- Struct.new(*response.keys).new(*response.values) unless response.empty?
20
+ Struct.new(*data.keys).new(*data.values)
22
21
  end
23
22
 
24
- private
23
+ def data
24
+ @data ||= begin
25
+ response = Faraday.new("#{API_FINDER_URL}domain=#{domain}&first_name=#{first_name}&last_name=#{last_name}&api_key=#{key}").get
25
26
 
26
- def apiresponse
27
- response = Faraday.new("#{API_FINDER_URL}domain=#{@domain}&first_name=#{@first_name}&last_name=#{@last_name}&api_key=#{@key}").get
28
- response.success? ? JSON.parse(response.body, { symbolize_names: true }) : []
27
+ return [] unless response.success?
28
+
29
+ JSON.parse(response.body, { symbolize_names: true })
30
+ end
29
31
  end
30
32
  end
31
33
  end
@@ -7,7 +7,7 @@ API_SEARCH_URL = 'https://api.hunter.io/v2/domain-search?'
7
7
 
8
8
  module EmailHunter
9
9
  class Search
10
- attr_reader :meta, :webmail, :emails, :pattern, :domain
10
+ attr_reader :meta, :webmail, :emails, :pattern, :domain, :params, :key
11
11
 
12
12
  def initialize(domain, key, params = {})
13
13
  @domain = domain
@@ -16,15 +16,25 @@ module EmailHunter
16
16
  end
17
17
 
18
18
  def hunt
19
- response = apiresponse
20
- Struct.new(*response.keys).new(*response.values) unless response.empty?
19
+ Struct.new(*data.keys).new(*data.values)
21
20
  end
22
21
 
23
- private
22
+ def limit
23
+ params[:limit] || 10
24
+ end
25
+
26
+ def offset
27
+ params[:offset] || 0
28
+ end
29
+
30
+ def data
31
+ @data ||= begin
32
+ response = Faraday.new("#{API_SEARCH_URL}domain=#{domain}&api_key=#{key}&type=#{params[:type]}&offset=#{offset}&limit=#{limit}").get
33
+
34
+ return {} unless response.success?
24
35
 
25
- def apiresponse
26
- response = Faraday.new("#{API_SEARCH_URL}domain=#{@domain}&api_key=#{@key}&type=#{@params[:type]}&offset=#{@params[:offset]}&limit=#{@params[:limit]}").get
27
- response.success? ? JSON.parse(response.body, { symbolize_names: true }) : []
36
+ JSON.parse(response.body, { symbolize_names: true })
37
+ end
28
38
  end
29
39
  end
30
40
  end
@@ -7,7 +7,8 @@ API_VERIFY_URL = 'https://api.hunter.io/v2/email-verifier?'
7
7
 
8
8
  module EmailHunter
9
9
  class Verify
10
- attr_reader :result, :score, :regexp, :gibberish, :disposable, :webmail, :mx_records, :smtp_server, :smtp_check, :accept_all, :sources, :meta
10
+ attr_reader :result, :score, :regexp, :gibberish, :disposable, :webmail, :mx_records, :smtp_server, :smtp_check,
11
+ :accept_all, :sources, :meta, :key, :email
11
12
 
12
13
  def initialize(email, key)
13
14
  @email = email
@@ -15,15 +16,17 @@ module EmailHunter
15
16
  end
16
17
 
17
18
  def hunt
18
- response = apiresponse
19
- Struct.new(*response.keys).new(*response.values) unless response.empty?
19
+ Struct.new(*data.keys).new(*data.values)
20
20
  end
21
21
 
22
- private
22
+ def data
23
+ @data ||= begin
24
+ response = Faraday.new("#{API_VERIFY_URL}email=#{email}&api_key=#{key}").get
23
25
 
24
- def apiresponse
25
- response = Faraday.new("#{API_VERIFY_URL}email=#{@email}&api_key=#{@key}").get
26
- response.success? ? JSON.parse(response.body, { symbolize_names: true }) : []
26
+ return [] unless response.success?
27
+
28
+ JSON.parse(response.body, { symbolize_names: true })
29
+ end
27
30
  end
28
31
  end
29
32
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EmailHunter
4
- VERSION = '0.9.0'
4
+ VERSION = '1.0.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emailhunter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Davide Santangelo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-25 00:00:00.000000000 Z
11
+ date: 2022-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.8'
19
+ version: '2.1'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.8'
26
+ version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  - !ruby/object:Gem::Version
157
157
  version: '0'
158
158
  requirements: []
159
- rubygems_version: 3.0.8
159
+ rubygems_version: 3.2.3
160
160
  signing_key:
161
161
  specification_version: 4
162
162
  summary: A tiny ruby wrapper around Hunter.io API