module Bankscrap::Openbank::Utils

Public Instance Methods

format_date(date) click to toggle source
# File lib/bankscrap/openbank/utils.rb, line 16
def format_date(date)
  "%04d-%02d-%02d" % [date.year, date.month, date.day]
end
money(data) click to toggle source
# File lib/bankscrap/openbank/utils.rb, line 5
def money(data)
  Money.new(
    data['importe'] * 100.0,
    data['divisa'].presence || 'EUR'
  )
end
next_page_fields(data) click to toggle source
# File lib/bankscrap/openbank/utils.rb, line 20
def next_page_fields(data)
  link = data&.fetch('_links', nil)&.fetch('nextPage', nil)&.fetch('href', nil)
  return {} unless link
  uri = URI.parse(link)
  URI::decode_www_form(uri.query).to_h
end
parse_date(date) click to toggle source
# File lib/bankscrap/openbank/utils.rb, line 12
def parse_date(date)
  Date.strptime(date, '%Y-%m-%d')
end