Sha256: 5fa5feb0efe9d44c0f7caf301c39c85d6d5fa2f69b0353d7ec59b44212589540

Contents?: true

Size: 963 Bytes

Versions: 7

Compression:

Stored size: 963 Bytes

Contents

require 'rest-client'
require 'banks/fio.rb'
require 'banks/csas.rb'

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

  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

  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
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
czech_banks_parser-0.0.8 lib/czech_banks_parser.rb
czech_banks_parser-0.0.7 lib/czech_banks_parser.rb
czech_banks_parser-0.0.6 lib/czech_banks_parser.rb
czech_banks_parser-0.0.5 lib/czech_banks_parser.rb
czech_banks_parser-0.0.4 lib/czech_banks_parser.rb
czech_banks_parser-0.0.3 lib/czech_banks_parser.rb
czech_banks_parser-0.0.2 lib/czech_banks_parser.rb