Class: PostcodeAnywhere::BankAccountValidation

Inherits:
Object
  • Object
show all
Includes:
HTTParty, HTTParty::Icebox
Defined in:
lib/postcodeanywhere_banking.rb

Constant Summary collapse

HEADERS =
{
  "User-Agent"    => "Ruby.PostcodeAnywhere.BankAccountValidation",
  "Accept"        => "application/json",
  "Content-Type"  => "application/json"
}

Class Method Summary collapse

Methods included from HTTParty::Icebox

included

Class Method Details

.authenticate(api_key) ⇒ Object



22
23
24
# File 'lib/postcodeanywhere_banking.rb', line 22

def self.authenticate(api_key)
  default_params "Key" => api_key
end

.validate(opts) ⇒ Object



26
27
28
29
# File 'lib/postcodeanywhere_banking.rb', line 26

def self.validate(opts)
  res = get "/json.ws", :query => {"AccountNumber" => opts[:account_number], "SortCode" => opts[:sort_code]}
  res.code == 200 ? BankAccountValidationResponse.new(res.parsed_response[0]) : res
end