Class: ModernTreasury::LedgerBalances

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/modern_treasury/models/ledger_balances.rb

Overview

LedgerBalances Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(pending_balance:, posted_balance:, available_balance:) ⇒ LedgerBalances

Returns a new instance of LedgerBalances.



43
44
45
46
47
# File 'lib/modern_treasury/models/ledger_balances.rb', line 43

def initialize(pending_balance:, posted_balance:, available_balance:)
  @pending_balance = pending_balance
  @posted_balance = posted_balance
  @available_balance = available_balance
end

Instance Attribute Details

#available_balanceLedgerBalance

TODO: Write general description for this method

Returns:



22
23
24
# File 'lib/modern_treasury/models/ledger_balances.rb', line 22

def available_balance
  @available_balance
end

#pending_balanceLedgerBalance

TODO: Write general description for this method

Returns:



14
15
16
# File 'lib/modern_treasury/models/ledger_balances.rb', line 14

def pending_balance
  @pending_balance
end

#posted_balanceLedgerBalance

TODO: Write general description for this method

Returns:



18
19
20
# File 'lib/modern_treasury/models/ledger_balances.rb', line 18

def posted_balance
  @posted_balance
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/modern_treasury/models/ledger_balances.rb', line 50

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  pending_balance = LedgerBalance.from_hash(hash['pending_balance']) if
    hash['pending_balance']
  posted_balance = LedgerBalance.from_hash(hash['posted_balance']) if hash['posted_balance']
  available_balance = LedgerBalance.from_hash(hash['available_balance']) if
    hash['available_balance']

  # Create object from extracted values.
  LedgerBalances.new(pending_balance: pending_balance,
                     posted_balance: posted_balance,
                     available_balance: available_balance)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/modern_treasury/models/ledger_balances.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['pending_balance'] = 'pending_balance'
  @_hash['posted_balance'] = 'posted_balance'
  @_hash['available_balance'] = 'available_balance'
  @_hash
end

.nullablesObject

An array for nullable fields



39
40
41
# File 'lib/modern_treasury/models/ledger_balances.rb', line 39

def self.nullables
  []
end

.optionalsObject

An array for optional fields



34
35
36
# File 'lib/modern_treasury/models/ledger_balances.rb', line 34

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



74
75
76
77
78
# File 'lib/modern_treasury/models/ledger_balances.rb', line 74

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} pending_balance: #{@pending_balance.inspect}, posted_balance:"\
  " #{@posted_balance.inspect}, available_balance: #{@available_balance.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



67
68
69
70
71
# File 'lib/modern_treasury/models/ledger_balances.rb', line 67

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} pending_balance: #{@pending_balance}, posted_balance: #{@posted_balance},"\
  " available_balance: #{@available_balance}>"
end