Class: StarkInfra::IssuingBalance

Inherits:
Utils::Resource show all
Defined in:
lib/issuingbalance/issuingbalance.rb

Overview

# IssuingBalance object

The IssuingBalance object displays the current issuing 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 IssuingBalance 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]: latest update datetime for the IssuingBalance. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Utils::SubResource

#inspect, #to_s

Constructor Details

#initialize(amount: nil, currency: nil, updated: nil, id: nil) ⇒ IssuingBalance

Returns a new instance of IssuingBalance.



21
22
23
24
25
26
# File 'lib/issuingbalance/issuingbalance.rb', line 21

def initialize(amount: nil, currency: nil, updated: nil, id: nil)
  super(id)
  @amount = amount
  @currency = currency
  @updated = updated
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



20
21
22
# File 'lib/issuingbalance/issuingbalance.rb', line 20

def amount
  @amount
end

#currencyObject (readonly)

Returns the value of attribute currency.



20
21
22
# File 'lib/issuingbalance/issuingbalance.rb', line 20

def currency
  @currency
end

#idObject (readonly)

Returns the value of attribute id.



20
21
22
# File 'lib/issuingbalance/issuingbalance.rb', line 20

def id
  @id
end

#updatedObject (readonly)

Returns the value of attribute updated.



20
21
22
# File 'lib/issuingbalance/issuingbalance.rb', line 20

def updated
  @updated
end

Class Method Details

.get(user: nil) ⇒ Object

# Retrieve the IssuingBalance object

Receive the IssuingBalance object linked to your Workspace in the Stark Infrq API

## Parameters (optional):

  • user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call

## Return:

  • IssuingBalance object with updated attributes



37
38
39
# File 'lib/issuingbalance/issuingbalance.rb', line 37

def self.get(user: nil)
  StarkInfra::Utils::Rest.get_stream(user: user, **resource).next
end

.resourceObject



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/issuingbalance/issuingbalance.rb', line 41

def self.resource
  {
    resource_name: 'IssuingBalance',
    resource_maker: proc { |json|
      IssuingBalance.new(
        amount: json['amount'],
        currency: json['currency'],
        updated: json['updated'],
        id: json['id']
      )
    }
  }
end