Class: ModernTreasury::LedgerBalance

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

Overview

LedgerBalance 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(credits:, debits:, amount:, currency:, currency_exponent:) ⇒ LedgerBalance

Returns a new instance of LedgerBalance.



53
54
55
56
57
58
59
# File 'lib/modern_treasury/models/ledger_balance.rb', line 53

def initialize(credits:, debits:, amount:, currency:, currency_exponent:)
  @credits = credits
  @debits = debits
  @amount = amount
  @currency = currency
  @currency_exponent = currency_exponent
end

Instance Attribute Details

#amountInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def amount
  @amount
end

#creditsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def credits
  @credits
end

#currencyString

The currency of the ledger account.

Returns:

  • (String)


26
27
28
# File 'lib/modern_treasury/models/ledger_balance.rb', line 26

def currency
  @currency
end

#currency_exponentInteger

The currency exponent of the ledger account.

Returns:

  • (Integer)


30
31
32
# File 'lib/modern_treasury/models/ledger_balance.rb', line 30

def currency_exponent
  @currency_exponent
end

#debitsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def debits
  @debits
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/modern_treasury/models/ledger_balance.rb', line 62

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  credits = hash.key?('credits') ? hash['credits'] : nil
  debits = hash.key?('debits') ? hash['debits'] : nil
  amount = hash.key?('amount') ? hash['amount'] : nil
  currency = hash.key?('currency') ? hash['currency'] : nil
  currency_exponent =
    hash.key?('currency_exponent') ? hash['currency_exponent'] : nil

  # Create object from extracted values.
  LedgerBalance.new(credits: credits,
                    debits: debits,
                    amount: amount,
                    currency: currency,
                    currency_exponent: currency_exponent)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
40
41
# File 'lib/modern_treasury/models/ledger_balance.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['credits'] = 'credits'
  @_hash['debits'] = 'debits'
  @_hash['amount'] = 'amount'
  @_hash['currency'] = 'currency'
  @_hash['currency_exponent'] = 'currency_exponent'
  @_hash
end

.nullablesObject

An array for nullable fields



49
50
51
# File 'lib/modern_treasury/models/ledger_balance.rb', line 49

def self.nullables
  []
end

.optionalsObject

An array for optional fields



44
45
46
# File 'lib/modern_treasury/models/ledger_balance.rb', line 44

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



89
90
91
92
93
94
# File 'lib/modern_treasury/models/ledger_balance.rb', line 89

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} credits: #{@credits.inspect}, debits: #{@debits.inspect}, amount:"\
  " #{@amount.inspect}, currency: #{@currency.inspect}, currency_exponent:"\
  " #{@currency_exponent.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



82
83
84
85
86
# File 'lib/modern_treasury/models/ledger_balance.rb', line 82

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} credits: #{@credits}, debits: #{@debits}, amount: #{@amount}, currency:"\
  " #{@currency}, currency_exponent: #{@currency_exponent}>"
end