Module: Ibanomat
- Defined in:
- lib/ibanomat/client.rb,
lib/ibanomat/version.rb
Defined Under Namespace
Classes: ResourceNotFoundError
Constant Summary collapse
- URL =
'https://www.sparkasse.de/bin/servlets/sparkasse/iban'- VERSION =
'1.3.2'
Class Method Summary collapse
Class Method Details
.find(options) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ibanomat/client.rb', line 9 def self.find() raise ArgumentError.new unless .is_a?(Hash) raise ArgumentError.new('Option :bank_code is missing!') if [:bank_code].empty? raise ArgumentError.new('Option :bank_account_number is missing!') if [:bank_account_number].empty? uri = URI(URL) params = { 'b' => [:bank_code], 'a' => [:bank_account_number] } uri.query = URI.encode_www_form(params) case response = Net::HTTP.get_response(uri) when Net::HTTPSuccess hash = JSON.parse(response.body) { :bank_name => hash['Institutsname'], :bic => hash['BIC'], :iban => hash['IBAN'], :bank_code => hash['BLZ'], :bank_account_number => hash['KtoNr'], :return_code => hash['RetCode'] } when Net::HTTPNotFound raise ResourceNotFoundError else raise RuntimeError end end |