Module: Bankscrap::Openbank::Utils
Instance Method Summary collapse
- #format_date(date) ⇒ Object
- #money(data) ⇒ Object
- #next_page_fields(data) ⇒ Object
- #parse_date(date) ⇒ Object
Instance Method Details
#format_date(date) ⇒ Object
16 17 18 |
# File 'lib/bankscrap/openbank/utils.rb', line 16 def format_date(date) "%04d-%02d-%02d" % [date.year, date.month, date.day] end |
#money(data) ⇒ Object
5 6 7 8 9 10 |
# 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) ⇒ Object
20 21 22 23 24 25 |
# 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) ⇒ Object
12 13 14 |
# File 'lib/bankscrap/openbank/utils.rb', line 12 def parse_date(date) Date.strptime(date, '%Y-%m-%d') end |