emailhunter 0.8.1 → 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: 6212d2572b7b4291f9c6b0458869d2704bfd6b7a0e682808b841f9f6088f6aa8
4
- data.tar.gz: db1d5f7d367f74128d3a06684ac924fc0e2870dd34545571fd99f54ed36c181c
3
+ metadata.gz: aa2d9e9cc40ed470a2704f6cb875ade4b23bfb3f256ea535fc9ec772aa6d36f7
4
+ data.tar.gz: b16e0822b7b5362ac3ce01435467db482dd867d97abd9a394b40394c7f67989a
5
5
  SHA512:
6
- metadata.gz: '086b73b47ae012cbb1fbc66ce246085c47e9a921e17bd82a057349e340d17feadd8732b7d1dd1df191390f9f0c5cb7f4cd014bc947089c920034a38efc783974'
7
- data.tar.gz: af1d937ccc400bf39a688f92024b851696f5cfd6fb4d859bc70cf6542279f0d388b8330ed512be1a1d6a7b3523f0b910f4a85c0fb3c3f6ebc9a78e7912db7eb3
6
+ metadata.gz: 119c49c0e20229684a533a5bd000c33b5ba7470d2bc0ddcb075bfab48b705b1f0fe84e59227e2ed621c4ec27b335328189d7920b9db80037a5ad674864f94c22
7
+ data.tar.gz: 1de4508d1b3289004fe3a5603e48c2f03ce1b5cd4334c6a2b2efcf846e52a4f9966a2224639a342d790f0bd05b1adbcb5e322358567cae8d979930e526d7f6f4
data/Rakefile CHANGED
@@ -1,2 +1 @@
1
- require "bundler/gem_tasks"
2
-
1
+ require 'bundler/gem_tasks'
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "emailhunter"
3
+ require 'bundler/setup'
4
+ require 'emailhunter'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "emailhunter"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start
data/emailhunter.gemspec CHANGED
@@ -1,32 +1,30 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require File.expand_path('../lib/email_hunter/version', __FILE__)
3
+ require File.expand_path('lib/email_hunter/version', __dir__)
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "emailhunter"
6
+ spec.name = 'emailhunter'
8
7
  spec.version = EmailHunter::VERSION
9
- spec.authors = ["Davide Santangelo"]
10
- spec.email = ["davide.santangelo@gmail.com"]
8
+ spec.authors = ['Davide Santangelo']
9
+ spec.email = ['davide.santangelo@gmail.com']
11
10
 
12
-
13
- spec.summary = %q{A tiny ruby wrapper around Email Hunter API }
14
- spec.description = %q{A tiny ruby wrapper around Email Hunter API. Email Hunter helps sales people reach their targets and increase their sales. }
15
- spec.license = "MIT"
11
+ spec.summary = 'A tiny ruby wrapper around Hunter.io API '
12
+ spec.description = 'A tiny ruby wrapper around Hunter.io API. Hunter.io helps sales people reach their targets and increase their sales. '
13
+ spec.license = 'MIT'
16
14
 
17
15
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
16
+ spec.bindir = 'exe'
19
17
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
18
+ spec.require_paths = ['lib']
21
19
 
22
- spec.add_development_dependency "bundler", "~> 1.8"
23
- spec.add_development_dependency "rake", "~> 10.0"
20
+ spec.add_development_dependency 'bundler', '~> 2.1'
21
+ spec.add_development_dependency 'rake', '~> 10.0'
24
22
  spec.add_development_dependency 'rspec'
25
- spec.add_development_dependency "vcr"
26
- spec.add_development_dependency "typhoeus"
23
+ spec.add_development_dependency 'typhoeus'
24
+ spec.add_development_dependency 'vcr'
27
25
 
28
- spec.required_ruby_version = ">= 1.9.3"
26
+ spec.required_ruby_version = '>= 1.9.3'
29
27
 
30
- spec.add_dependency "faraday"
31
- spec.add_dependency "json"
28
+ spec.add_dependency 'faraday'
29
+ spec.add_dependency 'json'
32
30
  end
@@ -1,11 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'faraday'
2
4
  require 'json'
3
5
 
4
- API_VERIFY_URL = 'https://api.hunter.io/v2/account?'
6
+ API_ACCOUNT_URL = 'https://api.hunter.io/v2/account?'
5
7
 
6
8
  module EmailHunter
7
9
  class Account
8
- attr_reader :result, :first_name, :last_name, :email, :plan_name, :plan_level, :reset_date, :team_id, :calls
10
+ attr_reader :result, :first_name, :last_name, :email, :plan_name, :plan_level, :reset_date, :team_id, :calls,
11
+ :requests
9
12
 
10
13
  def initialize(key)
11
14
  @key = key
@@ -19,9 +22,8 @@ module EmailHunter
19
22
  private
20
23
 
21
24
  def apiresponse
22
- url = URI.parse(URI.encode("#{API_VERIFY_URL}&api_key=#{@key}"))
23
- response = Faraday.new(url).get
24
- response.success? ? JSON.parse(response.body, {symbolize_names: true}) : []
25
+ response = Faraday.new("#{API_ACCOUNT_URL}&api_key=#{@key}").get
26
+ response.success? ? JSON.parse(response.body, { symbolize_names: true }) : []
25
27
  end
26
28
  end
27
- end
29
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'uri'
2
4
 
3
5
  require File.expand_path(File.join(File.dirname(__FILE__), 'exist'))
@@ -11,28 +13,28 @@ module EmailHunter
11
13
  class Api
12
14
  attr_reader :key
13
15
 
14
- def initialize(key)
15
- @key = key
16
- end
16
+ def initialize(key)
17
+ @key = key
18
+ end
17
19
 
18
20
  # Domain search API
19
21
  def search(domain, params = {})
20
- EmailHunter::Search.new(domain, self.key, params).hunt
22
+ EmailHunter::Search.new(domain, key, params).hunt
21
23
  end
22
24
 
23
25
  # Email exist API
24
26
  def exist(email)
25
- EmailHunter::Exist.new(email, self.key).hunt
27
+ EmailHunter::Exist.new(email, key).hunt
26
28
  end
27
29
 
28
30
  # Email verify API
29
31
  def verify(email)
30
- EmailHunter::Verify.new(email, self.key).hunt
32
+ EmailHunter::Verify.new(email, key).hunt
31
33
  end
32
34
 
33
35
  # Email Finder API
34
36
  def finder(domain, first_name, last_name)
35
- EmailHunter::Finder.new(domain, first_name, last_name, self.key).hunt
37
+ EmailHunter::Finder.new(domain, first_name, last_name, key).hunt
36
38
  end
37
39
 
38
40
  # Email Count API
@@ -42,7 +44,7 @@ module EmailHunter
42
44
 
43
45
  # Account Information API
44
46
  def account
45
- EmailHunter::Account.new(self.key).hunt
47
+ EmailHunter::Account.new(key).hunt
46
48
  end
47
49
  end
48
50
  end
@@ -1,27 +1,28 @@
1
1
  require 'faraday'
2
2
  require 'json'
3
3
 
4
- API_COUNT_URL = 'https://api.hunter.io/v2/email-count?'
4
+ 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
- url = URI.parse(URI.encode("#{API_COUNT_URL}domain=#{@domain}"))
23
- response = Faraday.new(url).get
24
- 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
25
26
  end
26
27
  end
27
28
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'faraday'
2
4
  require 'json'
3
5
 
@@ -5,7 +7,7 @@ API_EXIST_URL = 'https://api.emailhunter.co/v1/exist?'
5
7
 
6
8
  module EmailHunter
7
9
  class Exist
8
- attr_reader :status, :email, :exist, :sources
10
+ attr_reader :status, :email, :exist, :sources, :key
9
11
 
10
12
  def initialize(email, key)
11
13
  @email = email
@@ -13,16 +15,17 @@ module EmailHunter
13
15
  end
14
16
 
15
17
  def hunt
16
- response = apiresponse
17
- Struct.new(*response.keys).new(*response.values) unless response.empty?
18
+ Struct.new(*data.keys).new(*data.values)
18
19
  end
19
20
 
20
- private
21
+ def data
22
+ @data ||= begin
23
+ response = Faraday.new("#{API_EXIST_URL}email=#{email}&api_key=#{key}").get
24
+
25
+ return {} unless response.success?
21
26
 
22
- def apiresponse
23
- url = URI.parse(URI.encode("#{API_EXIST_URL}email=#{@email}&api_key=#{@key}"))
24
- response = Faraday.new(url).get
25
- response.success? ? JSON.parse(response.body, {symbolize_names: true}) : []
27
+ JSON.parse(response.body, { symbolize_names: true })
28
+ end
26
29
  end
27
30
  end
28
31
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'faraday'
2
4
  require 'json'
3
5
 
@@ -5,7 +7,7 @@ API_FINDER_URL = 'https://api.hunter.io/v2/email-finder?'
5
7
 
6
8
  module EmailHunter
7
9
  class Finder
8
- attr_reader :email, :score, :sources, :domain, :meta
10
+ attr_reader :email, :score, :sources, :domain, :meta, :key, :first_name, :last_name
9
11
 
10
12
  def initialize(domain, first_name, last_name, key)
11
13
  @domain = domain
@@ -15,16 +17,17 @@ module EmailHunter
15
17
  end
16
18
 
17
19
  def hunt
18
- response = apiresponse
19
- Struct.new(*response.keys).new(*response.values) unless response.empty?
20
+ Struct.new(*data.keys).new(*data.values)
20
21
  end
21
22
 
22
- 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
26
+
27
+ return [] unless response.success?
23
28
 
24
- def apiresponse
25
- url = URI.parse(URI.encode("#{API_FINDER_URL}domain=#{@domain}&first_name=#{@first_name}&last_name=#{@last_name}&api_key=#{@key}"))
26
- response = Faraday.new(url).get
27
- response.success? ? JSON.parse(response.body, {symbolize_names: true}) : []
29
+ JSON.parse(response.body, { symbolize_names: true })
30
+ end
28
31
  end
29
32
  end
30
33
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'faraday'
2
4
  require 'json'
3
5
 
@@ -5,7 +7,7 @@ API_SEARCH_URL = 'https://api.hunter.io/v2/domain-search?'
5
7
 
6
8
  module EmailHunter
7
9
  class Search
8
- attr_reader :meta, :webmail, :emails, :pattern, :domain
10
+ attr_reader :meta, :webmail, :emails, :pattern, :domain, :params, :key
9
11
 
10
12
  def initialize(domain, key, params = {})
11
13
  @domain = domain
@@ -14,19 +16,25 @@ module EmailHunter
14
16
  end
15
17
 
16
18
  def hunt
17
- response = apiresponse
18
- Struct.new(*response.keys).new(*response.values) unless response.empty?
19
+ Struct.new(*data.keys).new(*data.values)
20
+ end
21
+
22
+ def limit
23
+ params[:limit] || 10
19
24
  end
20
25
 
21
- private
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?
22
35
 
23
- def apiresponse
24
- url =
25
- URI.parse(URI.encode(
26
- "#{API_SEARCH_URL}domain=#{@domain}&api_key=#{@key}&type=#{@params[:type]}&offset=#{@params[:offset]}")
27
- )
28
- response = Faraday.new(url).get
29
- response.success? ? JSON.parse(response.body, {symbolize_names: true}) : []
36
+ JSON.parse(response.body, { symbolize_names: true })
37
+ end
30
38
  end
31
39
  end
32
40
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'faraday'
2
4
  require 'json'
3
5
 
@@ -5,7 +7,8 @@ API_VERIFY_URL = 'https://api.hunter.io/v2/email-verifier?'
5
7
 
6
8
  module EmailHunter
7
9
  class Verify
8
- 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
9
12
 
10
13
  def initialize(email, key)
11
14
  @email = email
@@ -13,16 +16,17 @@ module EmailHunter
13
16
  end
14
17
 
15
18
  def hunt
16
- response = apiresponse
17
- Struct.new(*response.keys).new(*response.values) unless response.empty?
19
+ Struct.new(*data.keys).new(*data.values)
18
20
  end
19
21
 
20
- private
22
+ def data
23
+ @data ||= begin
24
+ response = Faraday.new("#{API_VERIFY_URL}email=#{email}&api_key=#{key}").get
25
+
26
+ return [] unless response.success?
21
27
 
22
- def apiresponse
23
- url = URI.parse(URI.encode("#{API_VERIFY_URL}email=#{@email}&api_key=#{@key}"))
24
- response = Faraday.new(url).get
25
- response.success? ? JSON.parse(response.body, {symbolize_names: true}) : []
28
+ JSON.parse(response.body, { symbolize_names: true })
29
+ end
26
30
  end
27
31
  end
28
32
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module EmailHunter
2
- VERSION = "0.8.1"
4
+ VERSION = '1.0.0'
3
5
  end
data/lib/email_hunter.rb CHANGED
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.expand_path(File.join(File.dirname(__FILE__), 'email_hunter/api'))
2
4
  require File.expand_path(File.join(File.dirname(__FILE__), 'email_hunter/version'))
3
5
 
4
6
  module EmailHunter
5
- extend self
7
+ module_function
6
8
 
7
9
  def new(key)
8
10
  Api.new(key)
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.8.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Davide Santangelo
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-21 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
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: vcr
56
+ name: typhoeus
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: typhoeus
70
+ name: vcr
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -108,8 +108,8 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- description: 'A tiny ruby wrapper around Email Hunter API. Email Hunter helps sales
112
- people reach their targets and increase their sales. '
111
+ description: 'A tiny ruby wrapper around Hunter.io API. Hunter.io helps sales people
112
+ reach their targets and increase their sales. '
113
113
  email:
114
114
  - davide.santangelo@gmail.com
115
115
  executables: []
@@ -137,11 +137,11 @@ files:
137
137
  - lib/email_hunter/verify.rb
138
138
  - lib/email_hunter/version.rb
139
139
  - lib/emailhunter.rb
140
- homepage:
140
+ homepage:
141
141
  licenses:
142
142
  - MIT
143
143
  metadata: {}
144
- post_install_message:
144
+ post_install_message:
145
145
  rdoc_options: []
146
146
  require_paths:
147
147
  - lib
@@ -156,8 +156,8 @@ 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.2
160
- signing_key:
159
+ rubygems_version: 3.2.3
160
+ signing_key:
161
161
  specification_version: 4
162
- summary: A tiny ruby wrapper around Email Hunter API
162
+ summary: A tiny ruby wrapper around Hunter.io API
163
163
  test_files: []