Module: KontoAPI

Extended by:
KontoAPI
Included in:
KontoAPI
Defined in:
lib/kontoapi-ruby.rb

Constant Summary collapse

VALIDITY_URL =
Addressable::URI.parse 'https://ask.kontoapi.de/for/validity.json'
BANKNAME_URL =
Addressable::URI.parse 'https://ask.kontoapi.de/for/bankname.json'
DEFAULT_TIMEOUT =
10
@@api_key =
nil
@@timeout =
nil

Instance Method Summary collapse

Instance Method Details

#api_keyObject



18
19
20
# File 'lib/kontoapi-ruby.rb', line 18

def api_key
  @@api_key
end

#api_key=(key) ⇒ Object



15
16
17
# File 'lib/kontoapi-ruby.rb', line 15

def api_key=(key)
  @@api_key = key
end

#bank_name(bank_code) ⇒ Object



36
37
38
39
40
# File 'lib/kontoapi-ruby.rb', line 36

def bank_name(bank_code)
  return nil if bank_code.to_s.strip.empty?
  response = ask_for(:bankname, { :blz => bank_code.to_s })
  response['answer'].empty? ? nil : response['answer']
end

#timeoutObject



26
27
28
# File 'lib/kontoapi-ruby.rb', line 26

def timeout
  @@timeout || DEFAULT_TIMEOUT
end

#timeout=(new_timeout) ⇒ Object



23
24
25
# File 'lib/kontoapi-ruby.rb', line 23

def timeout=(new_timeout)
  @@timeout = new_timeout
end

#valid?(account_number, bank_code) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
34
# File 'lib/kontoapi-ruby.rb', line 30

def valid?(, bank_code)
  return false if .to_s.strip.empty? || bank_code.to_s.strip.empty?
  response = ask_for(:validity, { :ktn => .to_s, :blz => bank_code.to_s })
  response['answer'].eql?('yes')
end