Class: StarkInfra::IssuingBalance

Inherits:
StarkCore::Utils::Resource
  • Object
show all
Defined in:
lib/issuing_balance/issuing_balance.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 issuing 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

Constructor Details

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

Returns a new instance of IssuingBalance.



20
21
22
23
24
25
# File 'lib/issuing_balance/issuing_balance.rb', line 20

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.



19
20
21
# File 'lib/issuing_balance/issuing_balance.rb', line 19

def amount
  @amount
end

#currencyObject (readonly)

Returns the value of attribute currency.



19
20
21
# File 'lib/issuing_balance/issuing_balance.rb', line 19

def currency
  @currency
end

#idObject (readonly)

Returns the value of attribute id.



19
20
21
# File 'lib/issuing_balance/issuing_balance.rb', line 19

def id
  @id
end

#updatedObject (readonly)

Returns the value of attribute updated.



19
20
21
# File 'lib/issuing_balance/issuing_balance.rb', line 19

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



36
37
38
# File 'lib/issuing_balance/issuing_balance.rb', line 36

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

.resourceObject



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

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