Sha256: c68ce27a47c611e5082a517172a9d1eb91fe3192e4aac16e62e85e7c03da69d6

Contents?: true

Size: 1.01 KB

Versions: 7

Compression:

Stored size: 1.01 KB

Contents

module Banks
  class Fio

    def initialize(token, config)
      @config = config
      @token = token
    end

    def transactions(time_start, time_end, iban = nil)
      url = "#{@config[:base_uri]}/periods/#{@token}/#{time_start.strftime('%Y-%m-%d')}/#{time_end.strftime('%Y-%m-%d')}/transactions.json"

      trans = []
      JSON.parse(RestClient.get(url), symbolize_names: true)[:accountStatement][:transactionList][:transaction].each do |tr|
        trans << {
          id: tr[:column22].try(:[], :value),
          date: tr[:column0].try(:[], :value),
          amount: tr[:column1].try(:[], :value),
          currency: tr[:column14].try(:[], :value),
          account: "#{tr[:column2].try(:[], :value)}/#{tr[:column3].try(:[], :value)}",
          bank: tr[:column12].try(:[], :value),
          name: tr[:column7].try(:[], :value) || tr[:column9].try(:[], :value),
          variable_symbol: tr[:column5].try(:[], :value),
          message: tr[:column16].try(:[], :value)
        }
      end
      trans
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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