class MailboxLayer::Client

Public Class Methods

new(access_key) click to toggle source
# File lib/email_address_validation.rb, line 13
def initialize(access_key)

  if access_key.nil?
    raise MailboxLayer::MissingArgumentException.new 'access_key'
  end

  @access_key = access_key

end

Public Instance Methods

check(email, options = {}) click to toggle source
# File lib/email_address_validation.rb, line 24
def check(email, options = {})

  if email.nil?
    raise MailboxLayer::MissingArgumentException.new 'email'
    return
  end

  # Create a shallow copy so we don't manipulate the original reference
  query = options.dup

  # Populate the Query
  query.access_key = @access_key
  query.email = email

  # We then create the Request
  req = CheckRequest.new(query)

  #  We create a Hash of the request so we can send it via HTTP
  req_dto = req.to_dh

  begin

    # We make the actual request
    res = self.class.get('/check', req_dto)

    # We ensure that we tap the response so we can use the results
    res.inspect

    # We just return the parsed binary response
    return res.parsed_response

  rescue => e
    puts e.inspect
    return

  end
end