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.



249
250
251
252
# File 'lib/belvo/resources.rb', line 249

def initialize(session)
  super(session)
  @endpoint = 'api/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:



261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/belvo/resources.rb', line 261

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.,
    save_data: options.save_data || true
  }.merge(options)
  body = clean body: body
  @session.post(@endpoint, body)
end