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):

Attributes

amount[R]
currency[R]
updated[R]

Public Class Methods

get(user: nil) click to toggle source

# Retrieve the Balance object

Receive the Balance object linked to your workspace in the Stark Bank API

## Parameters (optional):

## 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
new(amount:, currency:, updated:, id:) click to toggle source
Calls superclass method 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

resource() click to toggle source
# 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