mailboxvalidator_ruby 1.2.1 → 2.0.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 +4 -4
- data/README.rdoc +13 -10
- data/lib/mailboxvalidator_ruby.rb +6 -6
- data/spec/mailboxvalidator_ruby_webservice_spec.rb +61 -0
- data/spec/spec_helper.rb +14 -0
- metadata +8 -8
- data/test/test.rb +0 -58
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4b106b9f3c1c8bb8eb76d52f21c8ca98d3c4b74420c945ba4fabece41fd654a7
|
|
4
|
+
data.tar.gz: e9e22f9f8b6437f55871bae91421525408257f0400d40fade9fda876855aac41
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0551d315437005f3fac038bbb6379228d5ac090e09aa4718fcef2465a288dbe505f6dbe220d366d29c3fc49db7bcd8bbd643e11776f9000d01f977940d9d336d
|
|
7
|
+
data.tar.gz: 116c7a5f2b3bfcb61fa99804ba8b2993b29fbfb5762d0704bd2e4b69a746efb1a6d6361a5a7777f36c4cba19b606e99d28d888cc89d72f3efeaf52bc62c0c2f4
|
data/README.rdoc
CHANGED
|
@@ -12,7 +12,10 @@ mbv.apikey = apikey
|
|
|
12
12
|
|
|
13
13
|
mbv.query_single(email)
|
|
14
14
|
|
|
15
|
-
if mbv.error != nil
|
|
15
|
+
if mbv.error != nil && mbv.result != nil
|
|
16
|
+
puts "error_code: #{mbv.result.error.error_code}"
|
|
17
|
+
puts "error_message: #{mbv.result.error.error_message}"
|
|
18
|
+
elsif mbv.error != nil
|
|
16
19
|
puts "Error: #{mbv.error}"
|
|
17
20
|
elsif mbv.result != nil
|
|
18
21
|
puts "email_address: #{mbv.result.email_address}"
|
|
@@ -33,32 +36,32 @@ elsif mbv.result != nil
|
|
|
33
36
|
puts "time_taken: #{mbv.result.time_taken}"
|
|
34
37
|
puts "status: #{mbv.result.status}"
|
|
35
38
|
puts "credits_available: #{mbv.result.credits_available}"
|
|
36
|
-
puts "error_code: #{mbv.result.error_code}"
|
|
37
|
-
puts "error_message: #{mbv.result.error_message}"
|
|
38
39
|
end
|
|
39
40
|
|
|
40
41
|
mbv.disposable_email(email)
|
|
41
42
|
|
|
42
|
-
if mbv.error != nil
|
|
43
|
+
if mbv.error != nil && mbv.result != nil
|
|
44
|
+
puts "error_code: #{mbv.result.error.error_code}"
|
|
45
|
+
puts "error_message: #{mbv.result.error.error_message}"
|
|
46
|
+
elsif mbv.error != nil
|
|
43
47
|
puts "Error: #{mbv.error}"
|
|
44
48
|
elsif mbv.result != nil
|
|
45
49
|
puts "email_address: #{mbv.result.email_address}"
|
|
46
50
|
puts "is_disposable: #{mbv.result.is_disposable}"
|
|
47
51
|
puts "credits_available: #{mbv.result.credits_available}"
|
|
48
|
-
puts "error_code: #{mbv.result.error_code}"
|
|
49
|
-
puts "error_message: #{mbv.result.error_message}"
|
|
50
52
|
end
|
|
51
53
|
|
|
52
54
|
mbv.free_email(email)
|
|
53
55
|
|
|
54
|
-
if mbv.error != nil
|
|
56
|
+
if mbv.error != nil && mbv.result != nil
|
|
57
|
+
puts "error_code: #{mbv.result.error.error_code}"
|
|
58
|
+
puts "error_message: #{mbv.result.error.error_message}"
|
|
59
|
+
elsif mbv.error != nil
|
|
55
60
|
puts "Error: #{mbv.error}"
|
|
56
61
|
elsif mbv.result != nil
|
|
57
62
|
puts "email_address: #{mbv.result.email_address}"
|
|
58
63
|
puts "is_free: #{mbv.result.is_free}"
|
|
59
64
|
puts "credits_available: #{mbv.result.credits_available}"
|
|
60
|
-
puts "error_code: #{mbv.result.error_code}"
|
|
61
|
-
puts "error_message: #{mbv.result.error_message}"
|
|
62
65
|
end
|
|
63
66
|
|
|
64
67
|
== Dependencies
|
|
@@ -67,5 +70,5 @@ end
|
|
|
67
70
|
|
|
68
71
|
== Copyright
|
|
69
72
|
|
|
70
|
-
Copyright (c)
|
|
73
|
+
Copyright (c) 2023 MailboxValidator.com
|
|
71
74
|
|
|
@@ -16,7 +16,7 @@ module MailboxValidator
|
|
|
16
16
|
|
|
17
17
|
def query_single(email)
|
|
18
18
|
@email = CGI.escape(email)
|
|
19
|
-
uri = URI("https://api.mailboxvalidator.com/
|
|
19
|
+
uri = URI("https://api.mailboxvalidator.com/v2/validation/single?key=#{@apikey}&email=#{@email}")
|
|
20
20
|
|
|
21
21
|
begin
|
|
22
22
|
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
|
@@ -28,7 +28,7 @@ module MailboxValidator
|
|
|
28
28
|
@error = nil
|
|
29
29
|
else
|
|
30
30
|
@error = "#{response.code} - #{response.message}"
|
|
31
|
-
@result =
|
|
31
|
+
@result = JSON.parse(response.body, object_class: OpenStruct)
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
rescue Exception => e
|
|
@@ -39,7 +39,7 @@ module MailboxValidator
|
|
|
39
39
|
|
|
40
40
|
def disposable_email(email)
|
|
41
41
|
@email = CGI.escape(email)
|
|
42
|
-
uri = URI("https://api.mailboxvalidator.com/
|
|
42
|
+
uri = URI("https://api.mailboxvalidator.com/v2/email/disposable?key=#{@apikey}&email=#{@email}")
|
|
43
43
|
|
|
44
44
|
begin
|
|
45
45
|
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
|
@@ -51,7 +51,7 @@ module MailboxValidator
|
|
|
51
51
|
@error = nil
|
|
52
52
|
else
|
|
53
53
|
@error = "#{response.code} - #{response.message}"
|
|
54
|
-
@result =
|
|
54
|
+
@result = JSON.parse(response.body, object_class: OpenStruct)
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
rescue Exception => e
|
|
@@ -62,7 +62,7 @@ module MailboxValidator
|
|
|
62
62
|
|
|
63
63
|
def free_email(email)
|
|
64
64
|
@email = CGI.escape(email)
|
|
65
|
-
uri = URI("https://api.mailboxvalidator.com/
|
|
65
|
+
uri = URI("https://api.mailboxvalidator.com/v2/email/free?key=#{@apikey}&email=#{@email}")
|
|
66
66
|
|
|
67
67
|
begin
|
|
68
68
|
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
|
@@ -74,7 +74,7 @@ module MailboxValidator
|
|
|
74
74
|
@error = nil
|
|
75
75
|
else
|
|
76
76
|
@error = "#{response.code} - #{response.message}"
|
|
77
|
-
@result =
|
|
77
|
+
@result = JSON.parse(response.body, object_class: OpenStruct)
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
rescue Exception => e
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
+
|
|
3
|
+
describe "MailboxvalidatorRuby" do
|
|
4
|
+
it "work correctly with invalid api key" do
|
|
5
|
+
if $api_key == 'YOUR_API_KEY'
|
|
6
|
+
mbv = MailboxValidator::MBV.new()
|
|
7
|
+
mbv.apikey = $api_key
|
|
8
|
+
mbv.query_single('example@example.com')
|
|
9
|
+
expect(mbv.result.error.error_message).to eq 'API key not found.'
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "work correctly with api key exists" do
|
|
14
|
+
if $api_key == 'YOUR_API_KEY'
|
|
15
|
+
print "/*
|
|
16
|
+
* You could enter a MailboxValidator API Key in spec/spec_helper.rb
|
|
17
|
+
* for real web service calling test.
|
|
18
|
+
*
|
|
19
|
+
* You could sign up for a free API key at https://www.mailboxvalidator.com/plans#api
|
|
20
|
+
* if you do not have one.
|
|
21
|
+
*/"
|
|
22
|
+
expect($api_key).to eq 'YOUR_API_KEY'
|
|
23
|
+
else
|
|
24
|
+
expect($api_key).to_not eq 'YOUR_API_KEY'
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "work correctly with validate email" do
|
|
29
|
+
mbv = MailboxValidator::MBV.new()
|
|
30
|
+
mbv.apikey = $api_key
|
|
31
|
+
mbv.query_single('example@example.com')
|
|
32
|
+
if $api_key == 'YOUR_API_KEY'
|
|
33
|
+
expect(mbv.result.error.error_code).to eq 10001
|
|
34
|
+
else
|
|
35
|
+
expect(mbv.result.status).to eq false
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "work correctly with disposable email" do
|
|
40
|
+
mbv = MailboxValidator::MBV.new()
|
|
41
|
+
mbv.apikey = $api_key
|
|
42
|
+
mbv.disposable_email('example@example.com')
|
|
43
|
+
if $api_key == 'YOUR_API_KEY'
|
|
44
|
+
expect(mbv.result.error.error_code).to eq 10001
|
|
45
|
+
else
|
|
46
|
+
expect(mbv.result.is_disposable).to eq false
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "work correctly with free email" do
|
|
51
|
+
mbv = MailboxValidator::MBV.new()
|
|
52
|
+
mbv.apikey = $api_key
|
|
53
|
+
mbv.free_email('example@example.com')
|
|
54
|
+
if $api_key == 'YOUR_API_KEY'
|
|
55
|
+
expect(mbv.result.error.error_code).to eq 10001
|
|
56
|
+
else
|
|
57
|
+
expect(mbv.result.is_free).to eq false
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
3
|
+
require 'rspec'
|
|
4
|
+
require 'mailboxvalidator_ruby'
|
|
5
|
+
|
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
|
7
|
+
# in ./support/ and its subdirectories.
|
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
|
9
|
+
|
|
10
|
+
RSpec.configure do |config|
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
$api_key = 'YOUR_API_KEY'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mailboxvalidator_ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- MailboxValidator
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-09-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Enable users to block disposal email, detect free email and validate
|
|
14
14
|
if an email is valid
|
|
@@ -19,12 +19,13 @@ extra_rdoc_files: []
|
|
|
19
19
|
files:
|
|
20
20
|
- README.rdoc
|
|
21
21
|
- lib/mailboxvalidator_ruby.rb
|
|
22
|
-
-
|
|
22
|
+
- spec/mailboxvalidator_ruby_webservice_spec.rb
|
|
23
|
+
- spec/spec_helper.rb
|
|
23
24
|
homepage: https://www.mailboxvalidator.com/ruby
|
|
24
25
|
licenses:
|
|
25
26
|
- MIT
|
|
26
27
|
metadata: {}
|
|
27
|
-
post_install_message:
|
|
28
|
+
post_install_message:
|
|
28
29
|
rdoc_options: []
|
|
29
30
|
require_paths:
|
|
30
31
|
- lib
|
|
@@ -39,9 +40,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
39
40
|
- !ruby/object:Gem::Version
|
|
40
41
|
version: '0'
|
|
41
42
|
requirements: []
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
signing_key:
|
|
43
|
+
rubygems_version: 3.3.7
|
|
44
|
+
signing_key:
|
|
45
45
|
specification_version: 4
|
|
46
46
|
summary: MailboxValidator API wrapper
|
|
47
47
|
test_files: []
|
data/test/test.rb
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
require "mailboxvalidator_ruby"
|
|
2
|
-
|
|
3
|
-
apikey = "MY_API_KEY"
|
|
4
|
-
email = "example@example.com"
|
|
5
|
-
|
|
6
|
-
mbv = MailboxValidator::MBV.new()
|
|
7
|
-
mbv.apikey = apikey
|
|
8
|
-
|
|
9
|
-
mbv.query_single(email)
|
|
10
|
-
|
|
11
|
-
if mbv.error != nil
|
|
12
|
-
puts "Error: #{mbv.error}"
|
|
13
|
-
elsif mbv.result != nil
|
|
14
|
-
puts "email_address: #{mbv.result.email_address}"
|
|
15
|
-
puts "domain: #{mbv.result.domain}"
|
|
16
|
-
puts "is_free: #{mbv.result.is_free}"
|
|
17
|
-
puts "is_syntax: #{mbv.result.is_syntax}"
|
|
18
|
-
puts "is_domain: #{mbv.result.is_domain}"
|
|
19
|
-
puts "is_smtp: #{mbv.result.is_smtp}"
|
|
20
|
-
puts "is_verified: #{mbv.result.is_verified}"
|
|
21
|
-
puts "is_server_down: #{mbv.result.is_server_down}"
|
|
22
|
-
puts "is_greylisted: #{mbv.result.is_greylisted}"
|
|
23
|
-
puts "is_disposable: #{mbv.result.is_disposable}"
|
|
24
|
-
puts "is_suppressed: #{mbv.result.is_suppressed}"
|
|
25
|
-
puts "is_role: #{mbv.result.is_role}"
|
|
26
|
-
puts "is_high_risk: #{mbv.result.is_high_risk}"
|
|
27
|
-
puts "is_catchall: #{mbv.result.is_catchall}"
|
|
28
|
-
puts "mailboxvalidator_score: #{mbv.result.mailboxvalidator_score}"
|
|
29
|
-
puts "time_taken: #{mbv.result.time_taken}"
|
|
30
|
-
puts "status: #{mbv.result.status}"
|
|
31
|
-
puts "credits_available: #{mbv.result.credits_available}"
|
|
32
|
-
puts "error_code: #{mbv.result.error_code}"
|
|
33
|
-
puts "error_message: #{mbv.result.error_message}"
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
mbv.disposable_email(email)
|
|
37
|
-
|
|
38
|
-
if mbv.error != nil
|
|
39
|
-
puts "Error: #{mbv.error}"
|
|
40
|
-
elsif mbv.result != nil
|
|
41
|
-
puts "email_address: #{mbv.result.email_address}"
|
|
42
|
-
puts "is_disposable: #{mbv.result.is_disposable}"
|
|
43
|
-
puts "credits_available: #{mbv.result.credits_available}"
|
|
44
|
-
puts "error_code: #{mbv.result.error_code}"
|
|
45
|
-
puts "error_message: #{mbv.result.error_message}"
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
mbv.free_email(email)
|
|
49
|
-
|
|
50
|
-
if mbv.error != nil
|
|
51
|
-
puts "Error: #{mbv.error}"
|
|
52
|
-
elsif mbv.result != nil
|
|
53
|
-
puts "email_address: #{mbv.result.email_address}"
|
|
54
|
-
puts "is_free: #{mbv.result.is_free}"
|
|
55
|
-
puts "credits_available: #{mbv.result.credits_available}"
|
|
56
|
-
puts "error_code: #{mbv.result.error_code}"
|
|
57
|
-
puts "error_message: #{mbv.result.error_message}"
|
|
58
|
-
end
|