mailboxvalidator_ruby 1.2.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 545fb96f0e69fd79fe99b2eac91ec6ea24222788
4
- data.tar.gz: c14f0e3d4d235d1c1969fe2a939effb7c8b001b9
2
+ SHA256:
3
+ metadata.gz: 4b106b9f3c1c8bb8eb76d52f21c8ca98d3c4b74420c945ba4fabece41fd654a7
4
+ data.tar.gz: e9e22f9f8b6437f55871bae91421525408257f0400d40fade9fda876855aac41
5
5
  SHA512:
6
- metadata.gz: 876166562734586db3908977628088e98ed6ba4e28821e35a9e75d3e6d81e5b904cb84ac833265b8c3742da042e9fac8cd36eaddd37af4a9f2def5c030d1c83b
7
- data.tar.gz: 05beff128529752e63bebe5bcbaa098fd6ca9730022103087bc66c01e6bde11c8685dc9531e9147ebaf907391e8f5bee4d3a73f35c28a5ef8abb8384174848e5
6
+ metadata.gz: 0551d315437005f3fac038bbb6379228d5ac090e09aa4718fcef2465a288dbe505f6dbe220d366d29c3fc49db7bcd8bbd643e11776f9000d01f977940d9d336d
7
+ data.tar.gz: 116c7a5f2b3bfcb61fa99804ba8b2993b29fbfb5762d0704bd2e4b69a746efb1a6d6361a5a7777f36c4cba19b606e99d28d888cc89d72f3efeaf52bc62c0c2f4
data/README.rdoc CHANGED
@@ -1,71 +1,74 @@
1
- = MailboxValidator
2
-
3
- == Usage
4
-
5
- require "mailboxvalidator_ruby"
6
-
7
- apikey = "MY_API_KEY"
8
- email = "example@example.com"
9
-
10
- mbv = MailboxValidator::MBV.new()
11
- mbv.apikey = apikey
12
-
13
- mbv.query_single(email)
14
-
15
- if mbv.error != nil
16
- puts "Error: #{mbv.error}"
17
- elsif mbv.result != nil
18
- puts "email_address: #{mbv.result.email_address}"
19
- puts "domain: #{mbv.result.domain}"
20
- puts "is_free: #{mbv.result.is_free}"
21
- puts "is_syntax: #{mbv.result.is_syntax}"
22
- puts "is_domain: #{mbv.result.is_domain}"
23
- puts "is_smtp: #{mbv.result.is_smtp}"
24
- puts "is_verified: #{mbv.result.is_verified}"
25
- puts "is_server_down: #{mbv.result.is_server_down}"
26
- puts "is_greylisted: #{mbv.result.is_greylisted}"
27
- puts "is_disposable: #{mbv.result.is_disposable}"
28
- puts "is_suppressed: #{mbv.result.is_suppressed}"
29
- puts "is_role: #{mbv.result.is_role}"
30
- puts "is_high_risk: #{mbv.result.is_high_risk}"
31
- puts "is_catchall: #{mbv.result.is_catchall}"
32
- puts "mailboxvalidator_score: #{mbv.result.mailboxvalidator_score}"
33
- puts "time_taken: #{mbv.result.time_taken}"
34
- puts "status: #{mbv.result.status}"
35
- puts "credits_available: #{mbv.result.credits_available}"
36
- puts "error_code: #{mbv.result.error_code}"
37
- puts "error_message: #{mbv.result.error_message}"
38
- end
39
-
40
- mbv.disposable_email(email)
41
-
42
- if mbv.error != nil
43
- puts "Error: #{mbv.error}"
44
- elsif mbv.result != nil
45
- puts "email_address: #{mbv.result.email_address}"
46
- puts "is_disposable: #{mbv.result.is_disposable}"
47
- puts "credits_available: #{mbv.result.credits_available}"
48
- puts "error_code: #{mbv.result.error_code}"
49
- puts "error_message: #{mbv.result.error_message}"
50
- end
51
-
52
- mbv.free_email(email)
53
-
54
- if mbv.error != nil
55
- puts "Error: #{mbv.error}"
56
- elsif mbv.result != nil
57
- puts "email_address: #{mbv.result.email_address}"
58
- puts "is_free: #{mbv.result.is_free}"
59
- puts "credits_available: #{mbv.result.credits_available}"
60
- puts "error_code: #{mbv.result.error_code}"
61
- puts "error_message: #{mbv.result.error_message}"
62
- end
63
-
64
- == Dependencies
65
-
66
- * Go to https://www.mailboxvalidator.com/plans#api to sign up for a FREE API plan and you'll be given an API key.
67
-
68
- == Copyright
69
-
70
- Copyright (c) 2018 MailboxValidator.com
71
-
1
+ = MailboxValidator
2
+
3
+ == Usage
4
+
5
+ require "mailboxvalidator_ruby"
6
+
7
+ apikey = "MY_API_KEY"
8
+ email = "example@example.com"
9
+
10
+ mbv = MailboxValidator::MBV.new()
11
+ mbv.apikey = apikey
12
+
13
+ mbv.query_single(email)
14
+
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
19
+ puts "Error: #{mbv.error}"
20
+ elsif mbv.result != nil
21
+ puts "email_address: #{mbv.result.email_address}"
22
+ puts "domain: #{mbv.result.domain}"
23
+ puts "is_free: #{mbv.result.is_free}"
24
+ puts "is_syntax: #{mbv.result.is_syntax}"
25
+ puts "is_domain: #{mbv.result.is_domain}"
26
+ puts "is_smtp: #{mbv.result.is_smtp}"
27
+ puts "is_verified: #{mbv.result.is_verified}"
28
+ puts "is_server_down: #{mbv.result.is_server_down}"
29
+ puts "is_greylisted: #{mbv.result.is_greylisted}"
30
+ puts "is_disposable: #{mbv.result.is_disposable}"
31
+ puts "is_suppressed: #{mbv.result.is_suppressed}"
32
+ puts "is_role: #{mbv.result.is_role}"
33
+ puts "is_high_risk: #{mbv.result.is_high_risk}"
34
+ puts "is_catchall: #{mbv.result.is_catchall}"
35
+ puts "mailboxvalidator_score: #{mbv.result.mailboxvalidator_score}"
36
+ puts "time_taken: #{mbv.result.time_taken}"
37
+ puts "status: #{mbv.result.status}"
38
+ puts "credits_available: #{mbv.result.credits_available}"
39
+ end
40
+
41
+ mbv.disposable_email(email)
42
+
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
47
+ puts "Error: #{mbv.error}"
48
+ elsif mbv.result != nil
49
+ puts "email_address: #{mbv.result.email_address}"
50
+ puts "is_disposable: #{mbv.result.is_disposable}"
51
+ puts "credits_available: #{mbv.result.credits_available}"
52
+ end
53
+
54
+ mbv.free_email(email)
55
+
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
60
+ puts "Error: #{mbv.error}"
61
+ elsif mbv.result != nil
62
+ puts "email_address: #{mbv.result.email_address}"
63
+ puts "is_free: #{mbv.result.is_free}"
64
+ puts "credits_available: #{mbv.result.credits_available}"
65
+ end
66
+
67
+ == Dependencies
68
+
69
+ * Go to https://www.mailboxvalidator.com/plans#api to sign up for a FREE API plan and you'll be given an API key.
70
+
71
+ == Copyright
72
+
73
+ Copyright (c) 2023 MailboxValidator.com
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/v1/validation/single?key=#{@apikey}&email=#{@email}")
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 = nil
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/v1/email/disposable?key=#{@apikey}&email=#{@email}")
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 = nil
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/v1/email/free?key=#{@apikey}&email=#{@email}")
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 = nil
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
@@ -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,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailboxvalidator_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
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: 2018-09-13 00:00:00.000000000 Z
11
+ date: 2023-09-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: MailboxValidator API wrapper
13
+ description: Enable users to block disposal email, detect free email and validate
14
+ if an email is valid
14
15
  email: support@mailboxvalidator
15
16
  executables: []
16
17
  extensions: []
@@ -18,12 +19,13 @@ extra_rdoc_files: []
18
19
  files:
19
20
  - README.rdoc
20
21
  - lib/mailboxvalidator_ruby.rb
21
- - test/test.rb
22
- homepage: http://www.mailboxvalidator.com/ruby
22
+ - spec/mailboxvalidator_ruby_webservice_spec.rb
23
+ - spec/spec_helper.rb
24
+ homepage: https://www.mailboxvalidator.com/ruby
23
25
  licenses:
24
- - LGPL-3.0+
26
+ - MIT
25
27
  metadata: {}
26
- post_install_message:
28
+ post_install_message:
27
29
  rdoc_options: []
28
30
  require_paths:
29
31
  - lib
@@ -38,9 +40,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
38
40
  - !ruby/object:Gem::Version
39
41
  version: '0'
40
42
  requirements: []
41
- rubyforge_project:
42
- rubygems_version: 2.6.14.1
43
- signing_key:
43
+ rubygems_version: 3.3.7
44
+ signing_key:
44
45
  specification_version: 4
45
46
  summary: MailboxValidator API wrapper
46
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