Module: KontoAPI
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'
- IBAN_AND_BIC_URL =
Addressable::URI.parse 'https://ask.kontoapi.de/for/iban_and_bic.json'
- DEFAULT_TIMEOUT =
10- @@api_key =
nil- @@timeout =
nil
Instance Method Summary collapse
- #api_key ⇒ Object
- #api_key=(key) ⇒ Object
- #bank_name(bank_code) ⇒ Object
- #iban_and_bic(ktn, blz) ⇒ Object
- #timeout ⇒ Object
- #timeout=(new_timeout) ⇒ Object
- #valid?(options = {}) ⇒ Boolean
Instance Method Details
#api_key ⇒ Object
20 21 22 |
# File 'lib/kontoapi-ruby.rb', line 20 def api_key @@api_key end |
#api_key=(key) ⇒ Object
17 18 19 |
# File 'lib/kontoapi-ruby.rb', line 17 def api_key=(key) @@api_key = key end |
#bank_name(bank_code) ⇒ Object
38 39 40 41 42 |
# File 'lib/kontoapi-ruby.rb', line 38 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 |
#iban_and_bic(ktn, blz) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/kontoapi-ruby.rb', line 44 def iban_and_bic(ktn, blz) stripped_ktn = ktn.to_s.strip stripped_blz = blz.to_s.strip return nil if stripped_ktn.empty? return nil if stripped_blz.empty? response = ask_for(:iban_and_bic, { :ktn => stripped_ktn, :blz => stripped_blz }) response['answer'] end |
#timeout ⇒ Object
28 29 30 |
# File 'lib/kontoapi-ruby.rb', line 28 def timeout @@timeout || DEFAULT_TIMEOUT end |
#timeout=(new_timeout) ⇒ Object
25 26 27 |
# File 'lib/kontoapi-ruby.rb', line 25 def timeout=(new_timeout) @@timeout = new_timeout end |
#valid?(options = {}) ⇒ Boolean
32 33 34 35 36 |
# File 'lib/kontoapi-ruby.rb', line 32 def valid?(={}) return false unless (![:ktn].to_s.strip.empty? && ![:blz].to_s.strip.empty?) || ![:iban].to_s.strip.empty? || ![:bic].to_s.strip.empty? response = ask_for(:validity, ) response['answer'].eql?('yes') end |