Sha256: c754777e00033636b30b432c90567fdfa6eddb14ddb9a77997fbfc195b1285be

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

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)

      { :bank_name           => hash['Institutsname'],
        :bic                 => hash['BIC'],
        :iban                => hash['IBAN'],
        :bank_code           => hash['BLZ'],
        :bank_account_number => hash['KtoNr'],
        :return_code         => hash['RetCode']
      }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ibanomat-1.0.0 lib/ibanomat/client.rb
ibanomat-0.0.5 lib/ibanomat/client.rb
ibanomat-0.0.4 lib/ibanomat/client.rb