Module: Ibanomat

Defined in:
lib/ibanomat/client.rb,
lib/ibanomat/version.rb

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.find(options) ⇒ Object

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ibanomat/client.rb', line 7

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?
  raise ArgumentError.new('Option :bank_code_number is missing!') if options[:bank_account_number].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