Sha256: 051714b98cde35f0c18488e23b223cdb6795dabed2549fde20b08beaf0150c2a

Contents?: true

Size: 973 Bytes

Versions: 1

Compression:

Stored size: 973 Bytes

Contents

require 'rest-client'
require 'json'

module Ibanomat
  URL = 'http://www.sparkasse.de/firmenkunden/konto-karte/iban-resources/iban/iban.php'

  def self.find(options)
    raise ArgumentError.new unless options.is_a?(Hash)
    raise ArgumentError.new('Option :bank_code is missing!') if options[:bank_code].empty?

    response = RestClient.get URL, {
                                :params => {
                                  'bank-code'           => options[:bank_code],
                                  'bank-account-number' => options[:bank_account_number]
                                },
                                :accept => :json
                              }
    if response.code == 200
      hash = JSON.parse(response)

      case hash['RetCode']
      when '00'
        { :bank_name => hash['Institutsname'],
          :bic       => hash['BIC'],
          :iban      => hash['IBAN']
        }
      else
        :error
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ibanomat-0.0.3 lib/ibanomat/client.rb