Module: KontoAPI

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

Constant Summary collapse

RootCA =
'/etc/ssl/certs'
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



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

def api_key
  @@api_key
end

#api_key=(key) ⇒ Object



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

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

#bank_name(bank_code) ⇒ Object



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

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



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

def timeout
  @@timeout || DEFAULT_TIMEOUT
end

#timeout=(new_timeout) ⇒ Object



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

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

#valid?(options = {}) ⇒ Boolean

Returns:

  • (Boolean)


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

def valid?(options={})
  return false  unless (!options[:ktn].to_s.strip.empty? && !options[:blz].to_s.strip.empty?) || !options[:iban].to_s.strip.empty? || !options[:bic].to_s.strip.empty?
  response = ask_for(:validity, options)
  response['answer'].eql?('yes')
end