Class: ModernTreasury::LedgerAccount

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

Overview

LedgerAccount 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(id:, object:, live_mode:, created_at:, updated_at:, discarded_at:, name:, description:, normal_balance:, balances:, lock_version:, ledger_id:, ledgerable_id:, ledgerable_type:, metadata:) ⇒ LedgerAccount

Returns a new instance of LedgerAccount.



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/modern_treasury/models/ledger_account.rb', line 117

def initialize(id:, object:, live_mode:, created_at:, updated_at:,
               discarded_at:, name:, description:, normal_balance:,
               balances:, lock_version:, ledger_id:, ledgerable_id:,
               ledgerable_type:, metadata:)
  @id = id
  @object = object
  @live_mode = live_mode
  @created_at = created_at
  @updated_at = updated_at
  @discarded_at = discarded_at
  @name = name
  @description = description
  @normal_balance = normal_balance
  @balances = balances
  @lock_version = lock_version
  @ledger_id = ledger_id
  @ledgerable_id = ledgerable_id
  @ledgerable_type = ledgerable_type
  @metadata = 
end

Instance Attribute Details

#balancesLedgerBalancesWithEffectiveAt

The normal balance of the ledger account.



55
56
57
# File 'lib/modern_treasury/models/ledger_account.rb', line 55

def balances
  @balances
end

#created_atDateTime

This field will be true if this object exists in the live environment or false if it exists in the test environment.

Returns:

  • (DateTime)


29
30
31
# File 'lib/modern_treasury/models/ledger_account.rb', line 29

def created_at
  @created_at
end

#descriptionString

The description of the ledger account.

Returns:

  • (String)


47
48
49
# File 'lib/modern_treasury/models/ledger_account.rb', line 47

def description
  @description
end

#discarded_atDateTime

This field will be true if this object exists in the live environment or false if it exists in the test environment.

Returns:

  • (DateTime)


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

def discarded_at
  @discarded_at
end

#idUUID | String

TODO: Write general description for this method

Returns:

  • (UUID | String)


15
16
17
# File 'lib/modern_treasury/models/ledger_account.rb', line 15

def id
  @id
end

#ledger_idUUID | String

The id of the ledger that this account belongs to.

Returns:

  • (UUID | String)


63
64
65
# File 'lib/modern_treasury/models/ledger_account.rb', line 63

def ledger_id
  @ledger_id
end

#ledgerable_idUUID | String

If the ledger account links to another object in Modern Treasury, the id will be populated here, otherwise null.

Returns:

  • (UUID | String)


68
69
70
# File 'lib/modern_treasury/models/ledger_account.rb', line 68

def ledgerable_id
  @ledgerable_id
end

#ledgerable_typeLedgerableType

If the ledger account links to another object in Modern Treasury, the type will be populated here, otherwise null. The value is one of internal_account or external_account.

Returns:



74
75
76
# File 'lib/modern_treasury/models/ledger_account.rb', line 74

def ledgerable_type
  @ledgerable_type
end

#live_modeTrueClass | FalseClass

This field will be true if this object exists in the live environment or false if it exists in the test environment.

Returns:

  • (TrueClass | FalseClass)


24
25
26
# File 'lib/modern_treasury/models/ledger_account.rb', line 24

def live_mode
  @live_mode
end

#lock_versionInteger

Lock version of the ledger account.

Returns:

  • (Integer)


59
60
61
# File 'lib/modern_treasury/models/ledger_account.rb', line 59

def lock_version
  @lock_version
end

#metadataHash[String, String]

Additional data represented as key-value pairs. Both the key and value must be strings.

Returns:

  • (Hash[String, String])


79
80
81
# File 'lib/modern_treasury/models/ledger_account.rb', line 79

def 
  @metadata
end

#nameString

The name of the ledger account.

Returns:

  • (String)


43
44
45
# File 'lib/modern_treasury/models/ledger_account.rb', line 43

def name
  @name
end

#normal_balanceNormalBalance

The normal balance of the ledger account.

Returns:



51
52
53
# File 'lib/modern_treasury/models/ledger_account.rb', line 51

def normal_balance
  @normal_balance
end

#objectString

TODO: Write general description for this method

Returns:

  • (String)


19
20
21
# File 'lib/modern_treasury/models/ledger_account.rb', line 19

def object
  @object
end

#updated_atDateTime

This field will be true if this object exists in the live environment or false if it exists in the test environment.

Returns:

  • (DateTime)


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

def updated_at
  @updated_at
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/modern_treasury/models/ledger_account.rb', line 139

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  object = hash.key?('object') ? hash['object'] : nil
  live_mode = hash.key?('live_mode') ? hash['live_mode'] : nil
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               end
  updated_at = if hash.key?('updated_at')
                 (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at'])
               end
  discarded_at = if hash.key?('discarded_at')
                   (DateTimeHelper.from_rfc3339(hash['discarded_at']) if hash['discarded_at'])
                 end
  name = hash.key?('name') ? hash['name'] : nil
  description = hash.key?('description') ? hash['description'] : nil
  normal_balance =
    hash.key?('normal_balance') ? hash['normal_balance'] : nil
  balances = LedgerBalancesWithEffectiveAt.from_hash(hash['balances']) if hash['balances']
  lock_version = hash.key?('lock_version') ? hash['lock_version'] : nil
  ledger_id = hash.key?('ledger_id') ? hash['ledger_id'] : nil
  ledgerable_id = hash.key?('ledgerable_id') ? hash['ledgerable_id'] : nil
  ledgerable_type =
    hash.key?('ledgerable_type') ? hash['ledgerable_type'] : nil
   = hash.key?('metadata') ? hash['metadata'] : nil

  # Create object from extracted values.
  LedgerAccount.new(id: id,
                    object: object,
                    live_mode: live_mode,
                    created_at: created_at,
                    updated_at: updated_at,
                    discarded_at: discarded_at,
                    name: name,
                    description: description,
                    normal_balance: normal_balance,
                    balances: balances,
                    lock_version: lock_version,
                    ledger_id: ledger_id,
                    ledgerable_id: ledgerable_id,
                    ledgerable_type: ledgerable_type,
                    metadata: )
end

.namesObject

A mapping from model property names to API property names.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/modern_treasury/models/ledger_account.rb', line 82

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['object'] = 'object'
  @_hash['live_mode'] = 'live_mode'
  @_hash['created_at'] = 'created_at'
  @_hash['updated_at'] = 'updated_at'
  @_hash['discarded_at'] = 'discarded_at'
  @_hash['name'] = 'name'
  @_hash['description'] = 'description'
  @_hash['normal_balance'] = 'normal_balance'
  @_hash['balances'] = 'balances'
  @_hash['lock_version'] = 'lock_version'
  @_hash['ledger_id'] = 'ledger_id'
  @_hash['ledgerable_id'] = 'ledgerable_id'
  @_hash['ledgerable_type'] = 'ledgerable_type'
  @_hash['metadata'] = 'metadata'
  @_hash
end

.nullablesObject

An array for nullable fields



108
109
110
111
112
113
114
115
# File 'lib/modern_treasury/models/ledger_account.rb', line 108

def self.nullables
  %w[
    discarded_at
    description
    ledgerable_id
    ledgerable_type
  ]
end

.optionalsObject

An array for optional fields



103
104
105
# File 'lib/modern_treasury/models/ledger_account.rb', line 103

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



208
209
210
211
212
213
214
215
216
217
# File 'lib/modern_treasury/models/ledger_account.rb', line 208

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, object: #{@object.inspect}, live_mode:"\
  " #{@live_mode.inspect}, created_at: #{@created_at.inspect}, updated_at:"\
  " #{@updated_at.inspect}, discarded_at: #{@discarded_at.inspect}, name: #{@name.inspect},"\
  " description: #{@description.inspect}, normal_balance: #{@normal_balance.inspect},"\
  " balances: #{@balances.inspect}, lock_version: #{@lock_version.inspect}, ledger_id:"\
  " #{@ledger_id.inspect}, ledgerable_id: #{@ledgerable_id.inspect}, ledgerable_type:"\
  " #{@ledgerable_type.inspect}, metadata: #{@metadata.inspect}>"
end

#to_custom_created_atObject



185
186
187
# File 'lib/modern_treasury/models/ledger_account.rb', line 185

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_custom_discarded_atObject



193
194
195
# File 'lib/modern_treasury/models/ledger_account.rb', line 193

def to_custom_discarded_at
  DateTimeHelper.to_rfc3339(discarded_at)
end

#to_custom_updated_atObject



189
190
191
# File 'lib/modern_treasury/models/ledger_account.rb', line 189

def to_custom_updated_at
  DateTimeHelper.to_rfc3339(updated_at)
end

#to_sObject

Provides a human-readable string representation of the object.



198
199
200
201
202
203
204
205
# File 'lib/modern_treasury/models/ledger_account.rb', line 198

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, object: #{@object}, live_mode: #{@live_mode}, created_at:"\
  " #{@created_at}, updated_at: #{@updated_at}, discarded_at: #{@discarded_at}, name:"\
  " #{@name}, description: #{@description}, normal_balance: #{@normal_balance}, balances:"\
  " #{@balances}, lock_version: #{@lock_version}, ledger_id: #{@ledger_id}, ledgerable_id:"\
  " #{@ledgerable_id}, ledgerable_type: #{@ledgerable_type}, metadata: #{@metadata}>"
end