Class: ModernTreasury::LedgerEntry
- Defined in:
- lib/modern_treasury/models/ledger_entry.rb
Overview
LedgerEntry Model.
Instance Attribute Summary collapse
-
#amount ⇒ Integer
Value in specified currency’s smallest unit.
-
#created_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
-
#direction ⇒ Direction5
One of ‘credit`, `debit`.
-
#discarded_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
-
#id ⇒ UUID | String
TODO: Write general description for this method.
-
#ledger_account_currency ⇒ String
The currency of the ledger account.
-
#ledger_account_currency_exponent ⇒ Integer
The currency exponent of the ledger account.
-
#ledger_account_id ⇒ UUID | String
The ledger account that this ledger entry is associated with.
-
#ledger_account_lock_version ⇒ Integer
Lock version of the ledger account.
-
#ledger_transaction_id ⇒ String
The ledger transaction that this ledger entry is associated with.
-
#live_mode ⇒ TrueClass | FalseClass
This field will be true if this object exists in the live environment or false if it exists in the test environment.
-
#metadata ⇒ Hash[String, String]
Additional data represented as key-value pairs.
-
#object ⇒ String
TODO: Write general description for this method.
-
#resulting_ledger_account_balances ⇒ LedgerBalances
The ledger transaction that this ledger entry is associated with.
-
#status ⇒ Status9
Equal to the state of the ledger transaction when the ledger entry was created.
-
#updated_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(id:, object:, live_mode:, created_at:, updated_at:, discarded_at:, amount:, direction:, status:, ledger_account_id:, ledger_account_lock_version:, ledger_account_currency:, ledger_account_currency_exponent:, ledger_transaction_id:, resulting_ledger_account_balances:, metadata:) ⇒ LedgerEntry
constructor
A new instance of LedgerEntry.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_created_at ⇒ Object
- #to_custom_discarded_at ⇒ Object
- #to_custom_updated_at ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
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:, amount:, direction:, status:, ledger_account_id:, ledger_account_lock_version:, ledger_account_currency:, ledger_account_currency_exponent:, ledger_transaction_id:, resulting_ledger_account_balances:, metadata:) ⇒ LedgerEntry
Returns a new instance of LedgerEntry.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 127 def initialize(id:, object:, live_mode:, created_at:, updated_at:, discarded_at:, amount:, direction:, status:, ledger_account_id:, ledger_account_lock_version:, ledger_account_currency:, ledger_account_currency_exponent:, ledger_transaction_id:, resulting_ledger_account_balances:, metadata:) @id = id @object = object @live_mode = live_mode @created_at = created_at @updated_at = updated_at @discarded_at = discarded_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 @resulting_ledger_account_balances = resulting_ledger_account_balances @metadata = end |
Instance Attribute Details
#amount ⇒ Integer
Value in specified currency’s smallest unit. e.g. $10 would be represented as 1000. Can be any integer up to 36 digits.
44 45 46 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 44 def amount @amount end |
#created_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
29 30 31 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 29 def created_at @created_at end |
#direction ⇒ Direction5
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`.
51 52 53 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 51 def direction @direction end |
#discarded_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
39 40 41 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 39 def discarded_at @discarded_at end |
#id ⇒ UUID | String
TODO: Write general description for this method
15 16 17 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 15 def id @id end |
#ledger_account_currency ⇒ String
The currency of the ledger account.
71 72 73 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 71 def ledger_account_currency @ledger_account_currency end |
#ledger_account_currency_exponent ⇒ Integer
The currency exponent of the ledger account.
75 76 77 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 75 def ledger_account_currency_exponent @ledger_account_currency_exponent end |
#ledger_account_id ⇒ UUID | String
The ledger account that this ledger entry is associated with.
60 61 62 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 60 def ledger_account_id @ledger_account_id end |
#ledger_account_lock_version ⇒ Integer
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.
67 68 69 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 67 def ledger_account_lock_version @ledger_account_lock_version end |
#ledger_transaction_id ⇒ String
The ledger transaction that this ledger entry is associated with.
79 80 81 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 79 def ledger_transaction_id @ledger_transaction_id end |
#live_mode ⇒ TrueClass | FalseClass
This field will be true if this object exists in the live environment or false if it exists in the test environment.
24 25 26 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 24 def live_mode @live_mode end |
#metadata ⇒ Hash[String, String]
Additional data represented as key-value pairs. Both the key and value must be strings.
88 89 90 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 88 def @metadata end |
#object ⇒ String
TODO: Write general description for this method
19 20 21 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 19 def object @object end |
#resulting_ledger_account_balances ⇒ LedgerBalances
The ledger transaction that this ledger entry is associated with.
83 84 85 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 83 def resulting_ledger_account_balances @resulting_ledger_account_balances end |
#status ⇒ Status9
Equal to the state of the ledger transaction when the ledger entry was created. One of ‘pending`, `posted`, or `archived`.
56 57 58 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 56 def status @status end |
#updated_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
34 35 36 |
# File 'lib/modern_treasury/models/ledger_entry.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.
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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 152 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 amount = hash.key?('amount') ? hash['amount'] : nil direction = hash.key?('direction') ? hash['direction'] : nil status = hash.key?('status') ? hash['status'] : nil ledger_account_id = hash.key?('ledger_account_id') ? hash['ledger_account_id'] : nil ledger_account_lock_version = hash.key?('ledger_account_lock_version') ? hash['ledger_account_lock_version'] : nil ledger_account_currency = hash.key?('ledger_account_currency') ? hash['ledger_account_currency'] : nil ledger_account_currency_exponent = 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 if hash['resulting_ledger_account_balances'] resulting_ledger_account_balances = LedgerBalances.from_hash(hash['resulting_ledger_account_balances']) end = hash.key?('metadata') ? hash['metadata'] : nil # Create object from extracted values. LedgerEntry.new(id: id, object: object, live_mode: live_mode, created_at: created_at, updated_at: updated_at, discarded_at: discarded_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, resulting_ledger_account_balances: resulting_ledger_account_balances, metadata: ) end |
.names ⇒ Object
A mapping from model property names to API property names.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 91 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['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['resulting_ledger_account_balances'] = 'resulting_ledger_account_balances' @_hash['metadata'] = 'metadata' @_hash end |
.nullables ⇒ Object
An array for nullable fields
120 121 122 123 124 125 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 120 def self.nullables %w[ discarded_at ledger_account_lock_version ] end |
.optionals ⇒ Object
An array for optional fields
115 116 117 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 115 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 231 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}, 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}, resulting_ledger_account_balances:"\ " #{@resulting_ledger_account_balances.inspect}, metadata: #{@metadata.inspect}>" end |
#to_custom_created_at ⇒ Object
205 206 207 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 205 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_custom_discarded_at ⇒ Object
213 214 215 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 213 def to_custom_discarded_at DateTimeHelper.to_rfc3339(discarded_at) end |
#to_custom_updated_at ⇒ Object
209 210 211 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 209 def to_custom_updated_at DateTimeHelper.to_rfc3339(updated_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/modern_treasury/models/ledger_entry.rb', line 218 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}, 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},"\ " resulting_ledger_account_balances: #{@resulting_ledger_account_balances}, metadata:"\ " #{@metadata}>" end |