Class: CzechBanksParser

Inherits:
Object
  • Object
show all
Defined in:
lib/czech_banks_parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ CzechBanksParser

Returns a new instance of CzechBanksParser.



6
7
8
# File 'lib/czech_banks_parser.rb', line 6

def initialize(opts = {})
  @opts = opts
end

Instance Method Details

#config(state) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/czech_banks_parser.rb', line 18

def config(state)
  case state
    when 'csas'
      {
        base_uri: @opts[:mode] == 'production' ? '' : 'https://www.csast.csas.cz/webapi/api/v3',
        auth_uri: @opts[:mode] == 'production' ? '' : 'https://www.csast.csas.cz/widp/oauth2/auth',
        token_uri: @opts[:mode] == 'production' ? '' : 'https://www.csast.csas.cz/widp/oauth2/token',
        client_id: @opts[:client_id],
        secret: @opts[:secret],
        web_api_key: @opts[:web_api_key]
      }
    when 'fio'
      {
        base_uri: 'https://www.fio.cz/ib_api/rest'
      }
  end
end

#connect(token, bank) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/czech_banks_parser.rb', line 10

def connect(token, bank)
  case bank
    when 'csas' then Banks::Csas.new(token, config('csas'))
    when 'fio' then Banks::Fio.new(token, config('fio'))
    else raise(NotImplementedError)
  end
end