emailhunter 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e61a72900856fb1673b6f9c638e698cc46da893d
4
- data.tar.gz: 827e67f09bd849839da89e74346ada5fe11e8190
3
+ metadata.gz: 418afd79eb8611762f1188045655c3e49502c699
4
+ data.tar.gz: 129521b1fe42d462ad1c5611c935ac8d58a7976e
5
5
  SHA512:
6
- metadata.gz: 4116e6ff396c087629474b15a460c8a486712904f3e39c584564651bb9091fd59fe20ac5239f76dabaeba8880e12e6757c180f1751360c00888681bc08c78c0d
7
- data.tar.gz: af88f3486570bf89003bf19aca7920ed45f537ef4032dfa8e7129c01f7d24430c52855c64847b5ee53c6cdaba00a5c9295ee34ab7e1a10e613690a883a942d71
6
+ metadata.gz: 5b3180c68060abf4267c2937943a4a337229ffd0d3141b2e41d6d09e98b1aa0f450a81914be4488b9078ef96f4e37cb5aa57de1d2199ac062d89056df64e46be
7
+ data.tar.gz: 63e31331d83896e3014c3c5be5d093533774df7b291af26035af596422449e9c33461397b00f4923c1b0ac7ad4ee62a65d57985fd66433a615accd5f6911618f
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Emailhunter
2
2
 
3
- A tiny ruby wrapper around Email Hunter API
3
+ A tiny ruby wrapper around Email Hunter API. Direct access to all the web's email addresses.
4
+
4
5
 
5
6
  ## Installation
6
7
 
@@ -28,7 +29,7 @@ email_hunter = EmailHunter.new('Your secret API key')
28
29
  Your secret API key. You can generate it in your dashboard from https://emailhunter.co
29
30
 
30
31
  ## Domain search API
31
- Get the list of all the emails from a given domain name. Each email is returned with our source(s), its type (generic or personnal) and the date it was extracted on
32
+ Returns all the email addresses found using one given domain name, with our sources.
32
33
  ```ruby
33
34
  result = email_hunter.search('stripe.com')
34
35
  ```
@@ -37,12 +38,14 @@ result = email_hunter.search('stripe.com')
37
38
  ```ruby
38
39
  result.status
39
40
  result.results
41
+ result.webmail
40
42
  result.emails
43
+ result.offset
41
44
  ```
42
45
 
43
46
 
44
47
  ## Email check API
45
- Find if a given email exist. If it does, we'll return where it was found.
48
+ Checks if a given email address has been found in our base and returns the sources.
46
49
  ```ruby
47
50
  email_hunter.exist('bonjour@firmapi.com')
48
51
  ```
@@ -55,8 +58,21 @@ result.exist
55
58
  result.sources
56
59
  ```
57
60
 
61
+ ## Generate API
62
+ Guesses the most likely email of a person from his first name, his last name and a domain name.
63
+ ```ruby
64
+ email_hunter.generate('gmail.com', 'Davide', 'Santangelo')
65
+ ```
66
+
67
+ ## Accessing email check response
68
+ ```ruby
69
+ result.status
70
+ result.email
71
+ result.score
72
+ ```
73
+
58
74
  ## License
59
- The restcountry GEM is released under the MIT License.
75
+ The emailhunter GEM is released under the MIT License.
60
76
 
61
77
 
62
78
  ## Contributing
data/lib/email_hunter.rb CHANGED
@@ -7,4 +7,4 @@ module EmailHunter
7
7
  def new(key)
8
8
  Api.new(key)
9
9
  end
10
- end
10
+ end
@@ -2,11 +2,12 @@ require 'uri'
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), 'search'))
4
4
  require File.expand_path(File.join(File.dirname(__FILE__), 'exist'))
5
+ require File.expand_path(File.join(File.dirname(__FILE__), 'generate'))
5
6
 
6
7
  module EmailHunter
7
8
  class Api
8
9
  attr_reader :key
9
-
10
+
10
11
  def initialize(key)
11
12
  @key = key
12
13
  end
@@ -20,5 +21,10 @@ module EmailHunter
20
21
  def exist(email)
21
22
  EmailHunter::Exist.new(email, self.key).hunt
22
23
  end
24
+
25
+ # Email Generate API
26
+ def generate(domain, first_name, last_name)
27
+ EmailHunter::Generate.new(domain, first_name, last_name, self.key).hunt
28
+ end
23
29
  end
24
- end
30
+ end
@@ -7,7 +7,7 @@ module EmailHunter
7
7
  class Exist
8
8
  attr_reader :status, :email, :exist, :sources
9
9
 
10
- def initialize(email, key)
10
+ def initialize(email, key)
11
11
  @email = email
12
12
  @key = key
13
13
  end
@@ -20,9 +20,9 @@ module EmailHunter
20
20
  private
21
21
 
22
22
  def apiresponse
23
- url = "#{API_EXISTS_URL}email=#{@email}&api_key=#{@key}"
24
- response = (Faraday.new URI.parse(URI.encode(url)), :ssl => {:verify => false}).get
23
+ url = URI.parse(URI.encode("#{API_EXISTS_URL}email=#{@email}&api_key=#{@key}"))
24
+ response = Faraday.new(url).get
25
25
  response.success? ? JSON.parse(response.body, {symbolize_names: true}) : []
26
26
  end
27
27
  end
28
- end
28
+ end
@@ -0,0 +1,30 @@
1
+ require 'faraday'
2
+ require 'json'
3
+
4
+ API_GENERATE_URL = 'https://api.emailhunter.co/v1/generate?'
5
+
6
+ module EmailHunter
7
+ class Generate
8
+ attr_reader :status, :email, :score
9
+
10
+ def initialize(domain, first_name, last_name, key)
11
+ @first_name = first_name
12
+ @last_name = last_name
13
+ @domain = domain
14
+ @key = key
15
+ end
16
+
17
+ def hunt
18
+ response = apiresponse
19
+ Struct.new(*response.keys).new(*response.values) unless response.empty?
20
+ end
21
+
22
+ private
23
+
24
+ def apiresponse
25
+ url = URI.parse(URI.encode("#{API_GENERATE_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}) : []
28
+ end
29
+ end
30
+ end
@@ -20,9 +20,9 @@ module EmailHunter
20
20
  private
21
21
 
22
22
  def apiresponse
23
- url = "#{API_SEARCH_URL}domain=#{@domain}&api_key=#{@key}"
24
- response = (Faraday.new URI.parse(URI.encode(url)), :ssl => {:verify => false}).get
23
+ url = URI.parse(URI.encode("#{API_SEARCH_URL}domain=#{@domain}&api_key=#{@key}"))
24
+ response = Faraday.new(url).get
25
25
  response.success? ? JSON.parse(response.body, {symbolize_names: true}) : []
26
26
  end
27
27
  end
28
- end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module EmailHunter
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.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.2.2
4
+ version: 0.3.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-07-01 00:00:00.000000000 Z
11
+ date: 2015-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -129,6 +129,7 @@ files:
129
129
  - lib/email_hunter.rb
130
130
  - lib/email_hunter/api.rb
131
131
  - lib/email_hunter/exist.rb
132
+ - lib/email_hunter/generate.rb
132
133
  - lib/email_hunter/search.rb
133
134
  - lib/email_hunter/version.rb
134
135
  - lib/emailhunter.rb