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 +4 -4
- data/lib/email_hunter/api.rb +12 -7
- data/lib/email_hunter/exist.rb +28 -0
- data/lib/email_hunter/search.rb +6 -2
- data/lib/email_hunter/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f06bb3c5d21ec48256f0a9060a8f5104a43a23f
|
4
|
+
data.tar.gz: a6a59d6a5524be03c74843546b9d684959727619
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 814f17babd817bc4705fc7f0149f21a2d12f92f2e94574f2a9b8ac5260d58efc3ae3e93d451524a298a8074aa27808b3d8f41e01952e9999d71bbcddf7e2cd96
|
7
|
+
data.tar.gz: 9d2ae97e5e2b590d2bb9ec6e04cc1f242f2fed97ac18fb00a103806e1654c40e022e9e0a2ce2c58a5a12dc22355aa9fd4fbe39ea480b7bed31463c0748df555b
|
data/lib/email_hunter/api.rb
CHANGED
@@ -13,14 +13,19 @@ module EmailHunter
|
|
13
13
|
end
|
14
14
|
|
15
15
|
# Domain search API
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
def search(domain, params = {})
|
17
|
+
EmailHunter::Search.new(domain, self.key, params).hunt
|
18
|
+
end
|
19
19
|
|
20
|
-
# Email
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
data/lib/email_hunter/search.rb
CHANGED
@@ -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 =
|
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
|
data/lib/email_hunter/version.rb
CHANGED
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
|
+
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-
|
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
|