Class: StarkBank::Balance
- Inherits:
-
StarkCore::Utils::Resource
- Object
- StarkCore::Utils::Resource
- StarkBank::Balance
- Defined in:
- lib/balance/balance.rb
Overview
# 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]: unique id returned when Balance is created. ex: ‘5656565656565656’
-
amount [integer]: current balance amount of the workspace in cents. ex: 200 (= R$ 2.00)
-
currency [string]: currency of the current workspace. Expect others to be added eventually. ex:‘BRL’
-
updated [DateTime]: update datetime for the balance. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#updated ⇒ Object
readonly
Returns the value of attribute updated.
Class Method Summary collapse
-
.get(user: nil) ⇒ Object
# Retrieve the Balance object.
Instance Method Summary collapse
-
#initialize(amount:, currency:, updated:, id:) ⇒ Balance
constructor
A new instance of Balance.
Constructor Details
#initialize(amount:, currency:, updated:, id:) ⇒ Balance
Returns a new instance of Balance.
22 23 24 25 26 27 |
# File 'lib/balance/balance.rb', line 22 def initialize(amount:, currency:, updated:, id:) super(id) @amount = amount @currency = currency @updated = StarkCore::Utils::Checks.check_datetime(updated) end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
21 22 23 |
# File 'lib/balance/balance.rb', line 21 def amount @amount end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
21 22 23 |
# File 'lib/balance/balance.rb', line 21 def currency @currency end |
#updated ⇒ Object (readonly)
Returns the value of attribute updated.
21 22 23 |
# File 'lib/balance/balance.rb', line 21 def updated @updated end |
Class Method Details
.get(user: nil) ⇒ Object
# Retrieve the Balance object
Receive the Balance object linked to your workspace in the Stark Bank API
## Parameters (optional):
-
user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
## Return:
-
Balance object with updated attributes
38 39 40 |
# File 'lib/balance/balance.rb', line 38 def self.get(user: nil) StarkBank::Utils::Rest.get_stream(user: user, **resource).next end |