Class: ModernTreasury::LedgerEntryOfTransactionVersion

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

Overview

LedgerEntryOfTransactionVersion 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:, amount:, direction:, status:, ledger_account_id:, ledger_account_lock_version:, ledger_account_currency:, ledger_account_currency_exponent:, ledger_transaction_id:, metadata:, resulting_ledger_account_balances:) ⇒ LedgerEntryOfTransactionVersion

Returns a new instance of LedgerEntryOfTransactionVersion.



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

def initialize(id:, object:, live_mode:, created_at:, amount:, direction:,
               status:, ledger_account_id:, ledger_account_lock_version:,
               ledger_account_currency:, ledger_account_currency_exponent:,
               ledger_transaction_id:, metadata:,
               resulting_ledger_account_balances:)
  @id = id
  @object = object
  @live_mode = live_mode
  @created_at = created_at
  @amount = amount
  @direction = direction
  @status = status
  @ledger_account_id = 
  @ledger_account_lock_version = 
  @ledger_account_currency = 
  @ledger_account_currency_exponent = 
  @ledger_transaction_id = ledger_transaction_id
  @metadata = 
  @resulting_ledger_account_balances = 
end

Instance Attribute Details

#amountInteger

Value in specified currency’s smallest unit. e.g. $10 would be represented as 1000. Can be any integer up to 36 digits.

Returns:

  • (Integer)


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

def amount
  @amount
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_entry_of_transaction_version.rb', line 29

def created_at
  @created_at
end

#directionDirection5

One of ‘credit`, `debit`. Describes the direction money is flowing in the transaction. A `credit` moves money from your account to someone else’s. A ‘debit` pulls money from someone else’s account to your own. Note that wire, rtp, and check payments will always be ‘credit`.

Returns:



41
42
43
# File 'lib/modern_treasury/models/ledger_entry_of_transaction_version.rb', line 41

def direction
  @direction
end

#idUUID | String

TODO: Write general description for this method

Returns:

  • (UUID | String)


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

def id
  @id
end

#ledger_account_currencyString

The currency of the ledger account.

Returns:

  • (String)


61
62
63
# File 'lib/modern_treasury/models/ledger_entry_of_transaction_version.rb', line 61

def 
  @ledger_account_currency
end

#ledger_account_currency_exponentInteger

The currency exponent of the ledger account.

Returns:

  • (Integer)


65
66
67
# File 'lib/modern_treasury/models/ledger_entry_of_transaction_version.rb', line 65

def 
  @ledger_account_currency_exponent
end

#ledger_account_idUUID | String

The ledger account that this ledger entry is associated with.

Returns:

  • (UUID | String)


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

def 
  @ledger_account_id
end

#ledger_account_lock_versionInteger

Lock version of the ledger account. This can be passed when creating a ledger transaction to only succeed if no ledger transactions have posted since the given version. See our post about Designing the Ledgers API with Optimistic Locking for more details.

Returns:

  • (Integer)


57
58
59
# File 'lib/modern_treasury/models/ledger_entry_of_transaction_version.rb', line 57

def 
  @ledger_account_lock_version
end

#ledger_transaction_idString

The ledger transaction that this ledger entry is associated with.

Returns:

  • (String)


69
70
71
# File 'lib/modern_treasury/models/ledger_entry_of_transaction_version.rb', line 69

def ledger_transaction_id
  @ledger_transaction_id
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_entry_of_transaction_version.rb', line 24

def live_mode
  @live_mode
end

#metadataHash[String, String]

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

Returns:

  • (Hash[String, String])


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

def 
  @metadata
end

#objectString

TODO: Write general description for this method

Returns:

  • (String)


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

def object
  @object
end

#resulting_ledger_account_balancesLedgerBalances

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

Returns:



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

def 
  @resulting_ledger_account_balances
end

#statusStatus9

Equal to the state of the ledger transaction when the ledger entry was created. One of ‘pending`, `posted`, or `archived`.

Returns:



46
47
48
# File 'lib/modern_treasury/models/ledger_entry_of_transaction_version.rb', line 46

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



137
138
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
# File 'lib/modern_treasury/models/ledger_entry_of_transaction_version.rb', line 137

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
  amount = hash.key?('amount') ? hash['amount'] : nil
  direction = hash.key?('direction') ? hash['direction'] : nil
  status = hash.key?('status') ? hash['status'] : nil
   =
    hash.key?('ledger_account_id') ? hash['ledger_account_id'] : nil
   =
    hash.key?('ledger_account_lock_version') ? hash['ledger_account_lock_version'] : nil
   =
    hash.key?('ledger_account_currency') ? hash['ledger_account_currency'] : nil
   =
    hash.key?('ledger_account_currency_exponent') ? hash['ledger_account_currency_exponent'] : nil
  ledger_transaction_id =
    hash.key?('ledger_transaction_id') ? hash['ledger_transaction_id'] : nil
   = hash.key?('metadata') ? hash['metadata'] : nil
  if hash['resulting_ledger_account_balances']
     = LedgerBalances.from_hash(hash['resulting_ledger_account_balances'])
  end

  # Create object from extracted values.
  LedgerEntryOfTransactionVersion.new(id: id,
                                      object: object,
                                      live_mode: live_mode,
                                      created_at: created_at,
                                      amount: amount,
                                      direction: direction,
                                      status: status,
                                      ledger_account_id: ,
                                      ledger_account_lock_version: ,
                                      ledger_account_currency: ,
                                      ledger_account_currency_exponent: ,
                                      ledger_transaction_id: ledger_transaction_id,
                                      metadata: ,
                                      resulting_ledger_account_balances: )
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
101
# File 'lib/modern_treasury/models/ledger_entry_of_transaction_version.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['amount'] = 'amount'
  @_hash['direction'] = 'direction'
  @_hash['status'] = 'status'
  @_hash['ledger_account_id'] = 'ledger_account_id'
  @_hash['ledger_account_lock_version'] = 'ledger_account_lock_version'
  @_hash['ledger_account_currency'] = 'ledger_account_currency'
  @_hash['ledger_account_currency_exponent'] =
    'ledger_account_currency_exponent'
  @_hash['ledger_transaction_id'] = 'ledger_transaction_id'
  @_hash['metadata'] = 'metadata'
  @_hash['resulting_ledger_account_balances'] =
    'resulting_ledger_account_balances'
  @_hash
end

.nullablesObject

An array for nullable fields



109
110
111
112
113
# File 'lib/modern_treasury/models/ledger_entry_of_transaction_version.rb', line 109

def self.nullables
  %w[
    ledger_account_lock_version
  ]
end

.optionalsObject

An array for optional fields



104
105
106
# File 'lib/modern_treasury/models/ledger_entry_of_transaction_version.rb', line 104

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/modern_treasury/models/ledger_entry_of_transaction_version.rb', line 199

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}, amount: #{@amount.inspect},"\
  " direction: #{@direction.inspect}, status: #{@status.inspect}, ledger_account_id:"\
  " #{@ledger_account_id.inspect}, ledger_account_lock_version:"\
  " #{@ledger_account_lock_version.inspect}, ledger_account_currency:"\
  " #{@ledger_account_currency.inspect}, ledger_account_currency_exponent:"\
  " #{@ledger_account_currency_exponent.inspect}, ledger_transaction_id:"\
  " #{@ledger_transaction_id.inspect}, metadata: #{@metadata.inspect},"\
  " resulting_ledger_account_balances: #{@resulting_ledger_account_balances.inspect}>"
end

#to_custom_created_atObject



182
183
184
# File 'lib/modern_treasury/models/ledger_entry_of_transaction_version.rb', line 182

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_sObject

Provides a human-readable string representation of the object.



187
188
189
190
191
192
193
194
195
196
# File 'lib/modern_treasury/models/ledger_entry_of_transaction_version.rb', line 187

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, object: #{@object}, live_mode: #{@live_mode}, created_at:"\
  " #{@created_at}, amount: #{@amount}, direction: #{@direction}, status: #{@status},"\
  " ledger_account_id: #{@ledger_account_id}, ledger_account_lock_version:"\
  " #{@ledger_account_lock_version}, ledger_account_currency: #{@ledger_account_currency},"\
  " ledger_account_currency_exponent: #{@ledger_account_currency_exponent},"\
  " ledger_transaction_id: #{@ledger_transaction_id}, metadata: #{@metadata},"\
  " resulting_ledger_account_balances: #{@resulting_ledger_account_balances}>"
end