class StarkBank::Balance
# Balance
object
The Balance
object displays the current balance of the workspace, which is the result of the sum of all transactions within this workspace. The balance is never generated by the user, but it can be retrieved to see the available information.
## Attributes (return-only):
-
id [string, default nil]: unique id returned when
Balance
is created. ex: '5656565656565656' -
amount [integer, default nil]: current balance amount of the workspace in cents. ex: 200 (= R$ 2.00)
-
currency [string, default nil]: currency of the current workspace. Expect others to be added eventually. ex:'BRL'
-
updated [DateTime, default nil]: update datetime for the balance. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
Attributes
Public Class Methods
# Retrieve the Balance
object
Receive the Balance
object linked to your workspace in the Stark Bank API
## Parameters (optional):
-
user [Organization/Project object]:
Organization
orProject
object. Not necessary ifStarkBank.user
was set before function call
## Return:
-
Balance
object with updated attributes
# File lib/balance/balance.rb, line 38 def self.get(user: nil) StarkBank::Utils::Rest.get_stream(user: user, **resource).next end
StarkBank::Utils::Resource::new
# File lib/balance/balance.rb, line 22 def initialize(amount:, currency:, updated:, id:) super(id) @amount = amount @currency = currency @updated = StarkBank::Utils::Checks.check_datetime(updated) end
Private Class Methods
# File lib/balance/balance.rb, line 45 def resource { resource_name: 'Balance', resource_maker: proc { |json| Balance.new( amount: json['amount'], currency: json['currency'], updated: json['updated'], id: json['id'] ) } } end