mailboxvalidator_ruby 1.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 +7 -0
 - data/README.rdoc +43 -0
 - data/lib/mailboxvalidator_ruby.rb +40 -0
 - data/test/test.rb +30 -0
 - metadata +46 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 32a848bdfcf5df4f05312a7da6d8aac31d92ea1b
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 72260d290a292c015970894bc71488a2532ceeda
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 6f5a83a4e1054649b43d0e28c5ea998ebf6ff10a85b657cc48faf65c5ca4f7628cda39541aef5d4b381375075212c58bc92548f50fab0d456d8c1448f76c99f1
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 0f046bf21524bc910e47c4378f290f3037bad4920b38ff076cc4231996e165e358cd77f017ac84b500cfda73de56c04c58a90130f153a193185512f523b39440
         
     | 
    
        data/README.rdoc
    ADDED
    
    | 
         @@ -0,0 +1,43 @@ 
     | 
|
| 
      
 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 
     | 
    
         
            +
            mbv.query_single(email)
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            if mbv.error != nil
         
     | 
| 
      
 15 
     | 
    
         
            +
            	puts "Error: #{mbv.error}"
         
     | 
| 
      
 16 
     | 
    
         
            +
            elsif mbv.result != nil
         
     | 
| 
      
 17 
     | 
    
         
            +
            	puts "email_address: #{mbv.result.email_address}"
         
     | 
| 
      
 18 
     | 
    
         
            +
            	puts "domain: #{mbv.result.domain}"
         
     | 
| 
      
 19 
     | 
    
         
            +
            	puts "is_free: #{mbv.result.is_free}"
         
     | 
| 
      
 20 
     | 
    
         
            +
            	puts "is_syntax: #{mbv.result.is_syntax}"
         
     | 
| 
      
 21 
     | 
    
         
            +
            	puts "is_domain: #{mbv.result.is_domain}"
         
     | 
| 
      
 22 
     | 
    
         
            +
            	puts "is_smtp: #{mbv.result.is_smtp}"
         
     | 
| 
      
 23 
     | 
    
         
            +
            	puts "is_verified: #{mbv.result.is_verified}"
         
     | 
| 
      
 24 
     | 
    
         
            +
            	puts "is_server_down: #{mbv.result.is_server_down}"
         
     | 
| 
      
 25 
     | 
    
         
            +
            	puts "is_greylisted: #{mbv.result.is_greylisted}"
         
     | 
| 
      
 26 
     | 
    
         
            +
            	puts "is_disposable: #{mbv.result.is_disposable}"
         
     | 
| 
      
 27 
     | 
    
         
            +
            	puts "is_suppressed: #{mbv.result.is_suppressed}"
         
     | 
| 
      
 28 
     | 
    
         
            +
            	puts "is_role: #{mbv.result.is_role}"
         
     | 
| 
      
 29 
     | 
    
         
            +
            	puts "is_high_risk: #{mbv.result.is_high_risk}"
         
     | 
| 
      
 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 
     | 
    
         
            +
            == Dependencies
         
     | 
| 
      
 37 
     | 
    
         
            +
             
         
     | 
| 
      
 38 
     | 
    
         
            +
            * Go to http://www.mailboxvalidator.com/plans to sign up for a trial plan or a paid plan and you'll be given an API key.
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            == Copyright
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            Copyright (c) 2015 MailboxValidator.com
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,40 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #!/usr/bin/ruby
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'cgi'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'net/http'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'json'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'ostruct'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            module MailboxValidator
         
     | 
| 
      
 8 
     | 
    
         
            +
            	class MBV
         
     | 
| 
      
 9 
     | 
    
         
            +
            		attr_accessor :apikey
         
     | 
| 
      
 10 
     | 
    
         
            +
            		attr_reader :result, :error
         
     | 
| 
      
 11 
     | 
    
         
            +
            		
         
     | 
| 
      
 12 
     | 
    
         
            +
            		def initialize(apikey = "")
         
     | 
| 
      
 13 
     | 
    
         
            +
            			@apikey = apikey
         
     | 
| 
      
 14 
     | 
    
         
            +
            			@error = nil
         
     | 
| 
      
 15 
     | 
    
         
            +
            		end
         
     | 
| 
      
 16 
     | 
    
         
            +
            		
         
     | 
| 
      
 17 
     | 
    
         
            +
            		def query_single(email)
         
     | 
| 
      
 18 
     | 
    
         
            +
            			@email = CGI.escape(email)
         
     | 
| 
      
 19 
     | 
    
         
            +
            			uri = URI("https://api.mailboxvalidator.com?key=#{@apikey}&email=#{@email}")
         
     | 
| 
      
 20 
     | 
    
         
            +
            			
         
     | 
| 
      
 21 
     | 
    
         
            +
            			begin
         
     | 
| 
      
 22 
     | 
    
         
            +
            				Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
         
     | 
| 
      
 23 
     | 
    
         
            +
            					request = Net::HTTP::Get.new uri
         
     | 
| 
      
 24 
     | 
    
         
            +
            					response = http.request request
         
     | 
| 
      
 25 
     | 
    
         
            +
            					
         
     | 
| 
      
 26 
     | 
    
         
            +
            					if response.code == "200"
         
     | 
| 
      
 27 
     | 
    
         
            +
            						@result = JSON.parse(response.body, object_class: OpenStruct)
         
     | 
| 
      
 28 
     | 
    
         
            +
            						@error = nil
         
     | 
| 
      
 29 
     | 
    
         
            +
            					else
         
     | 
| 
      
 30 
     | 
    
         
            +
            						@error = "#{response.code} - #{response.message}"
         
     | 
| 
      
 31 
     | 
    
         
            +
            						@result = nil
         
     | 
| 
      
 32 
     | 
    
         
            +
            					end
         
     | 
| 
      
 33 
     | 
    
         
            +
            				end
         
     | 
| 
      
 34 
     | 
    
         
            +
            			rescue Exception => e
         
     | 
| 
      
 35 
     | 
    
         
            +
            				@error = e.message
         
     | 
| 
      
 36 
     | 
    
         
            +
            				@result = nil
         
     | 
| 
      
 37 
     | 
    
         
            +
            			end
         
     | 
| 
      
 38 
     | 
    
         
            +
            		end
         
     | 
| 
      
 39 
     | 
    
         
            +
            	end
         
     | 
| 
      
 40 
     | 
    
         
            +
            end
         
     | 
    
        data/test/test.rb
    ADDED
    
    | 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 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 
     | 
    
         
            +
            mbv.query_single(email)
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            if mbv.error != nil
         
     | 
| 
      
 11 
     | 
    
         
            +
            	puts "Error: #{mbv.error}"
         
     | 
| 
      
 12 
     | 
    
         
            +
            elsif mbv.result != nil
         
     | 
| 
      
 13 
     | 
    
         
            +
            	puts "email_address: #{mbv.result.email_address}"
         
     | 
| 
      
 14 
     | 
    
         
            +
            	puts "domain: #{mbv.result.domain}"
         
     | 
| 
      
 15 
     | 
    
         
            +
            	puts "is_free: #{mbv.result.is_free}"
         
     | 
| 
      
 16 
     | 
    
         
            +
            	puts "is_syntax: #{mbv.result.is_syntax}"
         
     | 
| 
      
 17 
     | 
    
         
            +
            	puts "is_domain: #{mbv.result.is_domain}"
         
     | 
| 
      
 18 
     | 
    
         
            +
            	puts "is_smtp: #{mbv.result.is_smtp}"
         
     | 
| 
      
 19 
     | 
    
         
            +
            	puts "is_verified: #{mbv.result.is_verified}"
         
     | 
| 
      
 20 
     | 
    
         
            +
            	puts "is_server_down: #{mbv.result.is_server_down}"
         
     | 
| 
      
 21 
     | 
    
         
            +
            	puts "is_greylisted: #{mbv.result.is_greylisted}"
         
     | 
| 
      
 22 
     | 
    
         
            +
            	puts "is_disposable: #{mbv.result.is_disposable}"
         
     | 
| 
      
 23 
     | 
    
         
            +
            	puts "is_suppressed: #{mbv.result.is_suppressed}"
         
     | 
| 
      
 24 
     | 
    
         
            +
            	puts "is_role: #{mbv.result.is_role}"
         
     | 
| 
      
 25 
     | 
    
         
            +
            	puts "is_high_risk: #{mbv.result.is_high_risk}"
         
     | 
| 
      
 26 
     | 
    
         
            +
            	puts "status: #{mbv.result.status}"
         
     | 
| 
      
 27 
     | 
    
         
            +
            	puts "credits_available: #{mbv.result.credits_available}"
         
     | 
| 
      
 28 
     | 
    
         
            +
            	puts "error_code: #{mbv.result.error_code}"
         
     | 
| 
      
 29 
     | 
    
         
            +
            	puts "error_message: #{mbv.result.error_message}"
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,46 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: mailboxvalidator_ruby
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - MailboxValidator
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-11-19 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies: []
         
     | 
| 
      
 13 
     | 
    
         
            +
            description: MailboxValidator API wrapper
         
     | 
| 
      
 14 
     | 
    
         
            +
            email: support@mailboxvalidator
         
     | 
| 
      
 15 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 16 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 17 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 18 
     | 
    
         
            +
            files:
         
     | 
| 
      
 19 
     | 
    
         
            +
            - README.rdoc
         
     | 
| 
      
 20 
     | 
    
         
            +
            - lib/mailboxvalidator_ruby.rb
         
     | 
| 
      
 21 
     | 
    
         
            +
            - test/test.rb
         
     | 
| 
      
 22 
     | 
    
         
            +
            homepage: http://www.mailboxvalidator.com/ruby
         
     | 
| 
      
 23 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 24 
     | 
    
         
            +
            - LGPL-3.0+
         
     | 
| 
      
 25 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 26 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 27 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 28 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 29 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 30 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 31 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 32 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 33 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 34 
     | 
    
         
            +
                  version: 2.0.0
         
     | 
| 
      
 35 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 36 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 37 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 38 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 39 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 40 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 41 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 42 
     | 
    
         
            +
            rubygems_version: 2.4.6
         
     | 
| 
      
 43 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 44 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 45 
     | 
    
         
            +
            summary: MailboxValidator API wrapper
         
     | 
| 
      
 46 
     | 
    
         
            +
            test_files: []
         
     |