Class: StarkBank::CorporateBalance
- Inherits:
-
StarkCore::Utils::Resource
- Object
- StarkCore::Utils::Resource
- StarkBank::CorporateBalance
- Defined in:
- lib/corporate_balance/corporatebalance.rb
Overview
# CorporateBalance object
The CorporateBalance object displays the current corporate 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 CorporateBalance is created. ex: ‘5656565656565656’
-
amount [integer]: current corporate balance amount of the Workspace in cents. ex: 200 (= R$ 2.00)
-
limit [integer]: the maximum negative balance allowed by the user. ex: 10000 (= R$ 100.00)
-
max_limit [integer]: the maximum negative balance allowed by StarkBank. ex: 100000 (= R$ 1000.00)
-
currency [string]: currency of the current Workspace. Expect others to be added eventually. ex: ‘BRL’
-
updated [DateTime]: latest update datetime for the CorporateBalance. 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.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#max_limit ⇒ Object
readonly
Returns the value of attribute max_limit.
-
#updated ⇒ Object
readonly
Returns the value of attribute updated.
Class Method Summary collapse
-
.get(user: nil) ⇒ Object
# Retrieve the CorporateBalance object.
- .resource ⇒ Object
Instance Method Summary collapse
-
#initialize(amount: nil, limit: nil, max_limit: nil, currency: nil, updated: nil, id: nil) ⇒ CorporateBalance
constructor
A new instance of CorporateBalance.
Constructor Details
#initialize(amount: nil, limit: nil, max_limit: nil, currency: nil, updated: nil, id: nil) ⇒ CorporateBalance
Returns a new instance of CorporateBalance.
22 23 24 25 26 27 28 29 |
# File 'lib/corporate_balance/corporatebalance.rb', line 22 def initialize(amount: nil, limit: nil, max_limit: nil, currency: nil, updated: nil, id: nil) super(id) @amount = amount @limit = limit @max_limit = max_limit @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/corporate_balance/corporatebalance.rb', line 21 def amount @amount end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
21 22 23 |
# File 'lib/corporate_balance/corporatebalance.rb', line 21 def currency @currency end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
21 22 23 |
# File 'lib/corporate_balance/corporatebalance.rb', line 21 def id @id end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
21 22 23 |
# File 'lib/corporate_balance/corporatebalance.rb', line 21 def limit @limit end |
#max_limit ⇒ Object (readonly)
Returns the value of attribute max_limit.
21 22 23 |
# File 'lib/corporate_balance/corporatebalance.rb', line 21 def max_limit @max_limit end |
#updated ⇒ Object (readonly)
Returns the value of attribute updated.
21 22 23 |
# File 'lib/corporate_balance/corporatebalance.rb', line 21 def updated @updated end |
Class Method Details
.get(user: nil) ⇒ Object
# Retrieve the CorporateBalance object
Receive the CorporateBalance 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 StarkBank.user was set before function call
## Return:
-
CorporateBalance object with updated attributes
40 41 42 |
# File 'lib/corporate_balance/corporatebalance.rb', line 40 def self.get(user: nil) StarkBank::Utils::Rest.get_stream(user: user, **resource).next end |
.resource ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/corporate_balance/corporatebalance.rb', line 44 def self.resource { resource_name: 'CorporateBalance', resource_maker: proc { |json| CorporateBalance.new( id: json['id'], amount: json['amount'], limit: json['limit'], max_limit: json['max_limit'], currency: json['currency'], updated: json['updated'] ) } } end |