Class: ModernTreasury::LedgerBalancesWithEffectiveAt

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

Overview

LedgerBalancesWithEffectiveAt 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(effective_at_lower_bound:, effective_at_upper_bound:, pending_balance:, posted_balance:, available_balance:) ⇒ LedgerBalancesWithEffectiveAt

Returns a new instance of LedgerBalancesWithEffectiveAt.



62
63
64
65
66
67
68
69
# File 'lib/modern_treasury/models/ledger_balances_with_effective_at.rb', line 62

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

Instance Attribute Details

#available_balanceLedgerBalance

The exclusive upper bound of the effective_at timestamp for the returned balances.

Returns:



36
37
38
# File 'lib/modern_treasury/models/ledger_balances_with_effective_at.rb', line 36

def available_balance
  @available_balance
end

#effective_at_lower_boundDateTime

The inclusive lower bound of the effective_at timestamp for the returned balances.

Returns:

  • (DateTime)


16
17
18
# File 'lib/modern_treasury/models/ledger_balances_with_effective_at.rb', line 16

def effective_at_lower_bound
  @effective_at_lower_bound
end

#effective_at_upper_boundDateTime

The exclusive upper bound of the effective_at timestamp for the returned balances.

Returns:

  • (DateTime)


21
22
23
# File 'lib/modern_treasury/models/ledger_balances_with_effective_at.rb', line 21

def effective_at_upper_bound
  @effective_at_upper_bound
end

#pending_balanceLedgerBalance

The exclusive upper bound of the effective_at timestamp for the returned balances.

Returns:



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

def pending_balance
  @pending_balance
end

#posted_balanceLedgerBalance

The exclusive upper bound of the effective_at timestamp for the returned balances.

Returns:



31
32
33
# File 'lib/modern_treasury/models/ledger_balances_with_effective_at.rb', line 31

def posted_balance
  @posted_balance
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/modern_treasury/models/ledger_balances_with_effective_at.rb', line 72

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  effective_at_lower_bound = if hash.key?('effective_at_lower_bound')
                               (DateTimeHelper.from_rfc3339(hash['effective_at_lower_bound']) if hash['effective_at_lower_bound'])
                             end
  effective_at_upper_bound = if hash.key?('effective_at_upper_bound')
                               (DateTimeHelper.from_rfc3339(hash['effective_at_upper_bound']) if hash['effective_at_upper_bound'])
                             end
  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.
  LedgerBalancesWithEffectiveAt.new(effective_at_lower_bound: effective_at_lower_bound,
                                    effective_at_upper_bound: effective_at_upper_bound,
                                    pending_balance: pending_balance,
                                    posted_balance: posted_balance,
                                    available_balance: available_balance)
end

.namesObject

A mapping from model property names to API property names.



39
40
41
42
43
44
45
46
47
# File 'lib/modern_treasury/models/ledger_balances_with_effective_at.rb', line 39

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

.nullablesObject

An array for nullable fields



55
56
57
58
59
60
# File 'lib/modern_treasury/models/ledger_balances_with_effective_at.rb', line 55

def self.nullables
  %w[
    effective_at_lower_bound
    effective_at_upper_bound
  ]
end

.optionalsObject

An array for optional fields



50
51
52
# File 'lib/modern_treasury/models/ledger_balances_with_effective_at.rb', line 50

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



114
115
116
117
118
119
120
# File 'lib/modern_treasury/models/ledger_balances_with_effective_at.rb', line 114

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

#to_custom_effective_at_lower_boundObject



96
97
98
# File 'lib/modern_treasury/models/ledger_balances_with_effective_at.rb', line 96

def to_custom_effective_at_lower_bound
  DateTimeHelper.to_rfc3339(effective_at_lower_bound)
end

#to_custom_effective_at_upper_boundObject



100
101
102
# File 'lib/modern_treasury/models/ledger_balances_with_effective_at.rb', line 100

def to_custom_effective_at_upper_bound
  DateTimeHelper.to_rfc3339(effective_at_upper_bound)
end

#to_sObject

Provides a human-readable string representation of the object.



105
106
107
108
109
110
111
# File 'lib/modern_treasury/models/ledger_balances_with_effective_at.rb', line 105

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