emailhunter 0.4.0 → 0.5.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
  SHA1:
3
- metadata.gz: dc31f283b37abc4701ee89f70239b12a2814abad
4
- data.tar.gz: dfebe8deff09ce7b29cbe6e3ff9e31da2ce01558
3
+ metadata.gz: 8f06bb3c5d21ec48256f0a9060a8f5104a43a23f
4
+ data.tar.gz: a6a59d6a5524be03c74843546b9d684959727619
5
5
  SHA512:
6
- metadata.gz: f0a00653e3b4e40e66e4a50cd6576ae999e487127220cd53f6f78ae79263f3e3877ca527ac329c771a5c05df3f9b75588cd05c21b58e98134683caa90ab4079a
7
- data.tar.gz: b2d84a7fecc6941f55713d0d9701e3e619ae32c4af5e1b6e707504dbe45c620612cb7fa724955a6fb0a7dcc86829e9c946484460e76aa908f11bf70b6c59b4be
6
+ metadata.gz: 814f17babd817bc4705fc7f0149f21a2d12f92f2e94574f2a9b8ac5260d58efc3ae3e93d451524a298a8074aa27808b3d8f41e01952e9999d71bbcddf7e2cd96
7
+ data.tar.gz: 9d2ae97e5e2b590d2bb9ec6e04cc1f242f2fed97ac18fb00a103806e1654c40e022e9e0a2ce2c58a5a12dc22355aa9fd4fbe39ea480b7bed31463c0748df555b
@@ -13,14 +13,19 @@ module EmailHunter
13
13
  end
14
14
 
15
15
  # Domain search API
16
- def search(domain)
17
- EmailHunter::Search.new(domain, self.key).hunt
18
- end
16
+ def search(domain, params = {})
17
+ EmailHunter::Search.new(domain, self.key, params).hunt
18
+ end
19
19
 
20
- # Email Check API
21
- def exist(email)
22
- EmailHunter::Exist.new(email, self.key).hunt
23
- end
20
+ # Email exist API
21
+ def exist(email)
22
+ EmailHunter::Exist.new(email, self.key).hunt
23
+ end
24
+
25
+ # Email verify API
26
+ def verify(email)
27
+ EmailHunter::Verify.new(email, self.key).hunt
28
+ end
24
29
 
25
30
  # Email Generate API
26
31
  def generate(domain, first_name, last_name)
@@ -0,0 +1,28 @@
1
+ require 'faraday'
2
+ require 'json'
3
+
4
+ API_EXIST_URL = 'https://api.emailhunter.co/v1/exist?'
5
+
6
+ module EmailHunter
7
+ class Exist
8
+ attr_reader :status, :email, :exist, :sources
9
+
10
+ def initialize(email, key)
11
+ @email = email
12
+ @key = key
13
+ end
14
+
15
+ def hunt
16
+ response = apiresponse
17
+ Struct.new(*response.keys).new(*response.values) unless response.empty?
18
+ end
19
+
20
+ private
21
+
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}) : []
26
+ end
27
+ end
28
+ end
@@ -7,9 +7,10 @@ module EmailHunter
7
7
  class Search
8
8
  attr_reader :status, :results, :webmail, :emails, :offset
9
9
 
10
- def initialize(domain, key)
10
+ def initialize(domain, key, params = {})
11
11
  @domain = domain
12
12
  @key = key
13
+ @params = params
13
14
  end
14
15
 
15
16
  def hunt
@@ -20,7 +21,10 @@ module EmailHunter
20
21
  private
21
22
 
22
23
  def apiresponse
23
- url = URI.parse(URI.encode("#{API_SEARCH_URL}domain=#{@domain}&api_key=#{@key}"))
24
+ url =
25
+ URI.parse(URI.encode(
26
+ "#{API_SEARCH_URL}domain=#{@domain}&api_key=#{@key}&type=#{@params[:type]}&offset=#{@params[:offset]}")
27
+ )
24
28
  response = Faraday.new(url).get
25
29
  response.success? ? JSON.parse(response.body, {symbolize_names: true}) : []
26
30
  end
@@ -1,3 +1,3 @@
1
1
  module EmailHunter
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  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.4.0
4
+ version: 0.5.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: 2015-12-12 00:00:00.000000000 Z
11
+ date: 2015-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -128,6 +128,7 @@ files:
128
128
  - emailhunter.gemspec
129
129
  - lib/email_hunter.rb
130
130
  - lib/email_hunter/api.rb
131
+ - lib/email_hunter/exist.rb
131
132
  - lib/email_hunter/generate.rb
132
133
  - lib/email_hunter/search.rb
133
134
  - lib/email_hunter/verify.rb