Class: Belvo::Balance

Inherits:
Resource show all
Defined in:
lib/belvo/resources.rb

Overview

A Balance represents the financial status of an Account at a given time.

Instance Attribute Summary

Attributes inherited from Resource

#endpoint

Instance Method Summary collapse

Methods inherited from Resource

#clean, #delete, #detail, #list, #resume

Constructor Details

#initialize(session) ⇒ Balance

Returns a new instance of Balance.



220
221
222
223
# File 'lib/belvo/resources.rb', line 220

def initialize(session)
  super(session)
  @endpoint = 'balances/'
end

Instance Method Details

#retrieve(link:, date_from:, options: nil) ⇒ Hash

Retrieve balances from a specific account or all accounts from a

specific link

Parameters:

  • link (String)

    Link UUID

  • date_from (String)

    Date string (YYYY-MM-DD)

  • options (BalanceOptions) (defaults to: nil)

    Configurable properties

Returns:

  • (Hash)

    created balances details

Raises:



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/belvo/resources.rb', line 232

def retrieve(link:, date_from:, options: nil)
  options = BalanceOptions.from(options)
  date_to = options.date_to || Date.today.to_s
  body = {
    link: link,
    date_from: date_from,
    date_to: date_to,
    token: options.token,
    account: options.,
    encryption_key: options.encryption_key,
    save_data: options.save_data || true
  }.merge(options)
  body = clean body: body
  @session.post(@endpoint, body)
end