Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed Email "check" and "exist" API (deprecated) and added new Email Verification API #1

Merged
merged 5 commits into from
Dec 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,25 @@ result.webmail
result.emails
result.offset
```


## Email check API
Checks if a given email address has been found in our base and returns the sources.
## Email Verify API
Allows you to verify the deliverability of an email address.
```ruby
email_hunter.exist('[email protected]')
email_hunter.verify('[email protected]')
```

## Accessing email check response
## Accessing email verify response
```ruby
result.status
result.email
result.exist
result.score
result.regexp
result.gibberish
result.disposable
result.webmail
result.mx_records
result.smtp_server
result.smtp_check
result.accept_all
result.sources
```

Expand Down
6 changes: 5 additions & 1 deletion lib/email_hunter/api.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'uri'

require File.expand_path(File.join(File.dirname(__FILE__), 'search'))
require File.expand_path(File.join(File.dirname(__FILE__), 'exist'))
require File.expand_path(File.join(File.dirname(__FILE__), 'generate'))
require File.expand_path(File.join(File.dirname(__FILE__), 'verify'))

module EmailHunter
class Api
Expand All @@ -26,5 +26,9 @@ def exist(email)
def generate(domain, first_name, last_name)
EmailHunter::Generate.new(domain, first_name, last_name, self.key).hunt
end

def verify(email)
EmailHunter::Verify.new(email, self.key).hunt
end
end
end
8 changes: 4 additions & 4 deletions lib/email_hunter/exist.rb → lib/email_hunter/verify.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require 'faraday'
require 'json'

API_EXISTS_URL = 'https://api.emailhunter.co/v1/exist?'
API_VERIFY_URL = 'https://api.emailhunter.co/v1/verify?'

module EmailHunter
class Exist
attr_reader :status, :email, :exist, :sources
class Verify
attr_reader :status, :email, :result, :score, :regexp, :gibberish, :disposable, :webmail,:mx_records,:smtp_server, :smtp_check,:accept_all, :sources

def initialize(email, key)
@email = email
Expand All @@ -20,7 +20,7 @@ def hunt
private

def apiresponse
url = URI.parse(URI.encode("#{API_EXISTS_URL}email=#{@email}&api_key=#{@key}"))
url = URI.parse(URI.encode("#{API_VERIFY_URL}email=#{@email}&api_key=#{@key}"))
response = Faraday.new(url).get
response.success? ? JSON.parse(response.body, {symbolize_names: true}) : []
end
Expand Down
13 changes: 3 additions & 10 deletions spec/emailhunter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,10 @@
end
end

it 'exists API expect status \'success\'' do
VCR.use_cassette 'exists API expect status \'success\'' do
it 'verify API expect status \'success\'' do
VCR.use_cassette 'verify API expect status \'success\'' do
email_hunter = EmailHunter.new(key)
expect(email_hunter.exist('[email protected]').status).to eq('success')
end
end

it 'exists API expect status \'true\'' do
VCR.use_cassette 'exists API expect status \'true\'' do
email_hunter = EmailHunter.new(key)
expect(email_hunter.exist('[email protected]').exist).to eq(true)
expect(email_hunter.verify('[email protected]').exist).to eq('success')
end
end

Expand Down