Class: ModernTreasury::LedgerTransaction
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ModernTreasury::LedgerTransaction
- Defined in:
- lib/modern_treasury/models/ledger_transaction.rb
Overview
LedgerTransaction Model.
Instance Attribute Summary collapse
-
#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.
-
#description ⇒ String
An optional description for internal use.
-
#effective_at ⇒ Date
The timestamp (ISO8601 format) at which the ledger transaction happened for reporting purposes.
-
#effective_date ⇒ Date
The date (YYYY-MM-DD) on which the ledger transaction happened for reporting purposes.
-
#external_id ⇒ String
A unique string to represent the ledger transaction.
-
#id ⇒ UUID | String
TODO: Write general description for this method.
-
#ledger_entries ⇒ Array[LedgerEntry]
An array of ledger entry objects.
-
#ledger_id ⇒ UUID | String
The ID of the ledger this ledger transaction belongs to.
-
#ledgerable_id ⇒ UUID | String
If the ledger transaction can be reconciled to another object in Modern Treasury, the id will be populated here, otherwise null.
-
#ledgerable_type ⇒ LedgerableType2
If the ledger transaction can be reconciled to another object in Modern Treasury, the type will be populated here, otherwise null.
-
#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.
-
#posted_at ⇒ DateTime
The time on which the ledger transaction posted.
-
#reverses_ledger_transaction_id ⇒ String
The ID of the original ledger transaction that this ledger transaction reverses.
-
#status ⇒ Status11
To post a ledger transaction at creation, use ‘posted`.
-
#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:, description:, status:, metadata:, effective_at:, effective_date:, ledger_entries:, posted_at:, ledger_id:, ledgerable_type:, ledgerable_id:, external_id:, reverses_ledger_transaction_id:) ⇒ LedgerTransaction
constructor
A new instance of LedgerTransaction.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_created_at ⇒ Object
- #to_custom_posted_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:, description:, status:, metadata:, effective_at:, effective_date:, ledger_entries:, posted_at:, ledger_id:, ledgerable_type:, ledgerable_id:, external_id:, reverses_ledger_transaction_id:) ⇒ LedgerTransaction
Returns a new instance of LedgerTransaction.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 135 def initialize(id:, object:, live_mode:, created_at:, updated_at:, description:, status:, metadata:, effective_at:, effective_date:, ledger_entries:, posted_at:, ledger_id:, ledgerable_type:, ledgerable_id:, external_id:, reverses_ledger_transaction_id:) @id = id @object = object @live_mode = live_mode @created_at = created_at @updated_at = updated_at @description = description @status = status @metadata = @effective_at = effective_at @effective_date = effective_date @ledger_entries = ledger_entries @posted_at = posted_at @ledger_id = ledger_id @ledgerable_type = ledgerable_type @ledgerable_id = ledgerable_id @external_id = external_id @reverses_ledger_transaction_id = reverses_ledger_transaction_id end |
Instance Attribute Details
#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_transaction.rb', line 29 def created_at @created_at end |
#description ⇒ String
An optional description for internal use.
38 39 40 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 38 def description @description end |
#effective_at ⇒ Date
The timestamp (ISO8601 format) at which the ledger transaction happened for reporting purposes.
52 53 54 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 52 def effective_at @effective_at end |
#effective_date ⇒ Date
The date (YYYY-MM-DD) on which the ledger transaction happened for reporting purposes.
57 58 59 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 57 def effective_date @effective_date end |
#external_id ⇒ String
A unique string to represent the ledger transaction. Only one pending or posted ledger transaction may have this ID in the ledger.
87 88 89 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 87 def external_id @external_id end |
#id ⇒ UUID | String
TODO: Write general description for this method
15 16 17 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 15 def id @id end |
#ledger_entries ⇒ Array[LedgerEntry]
An array of ledger entry objects.
61 62 63 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 61 def ledger_entries @ledger_entries end |
#ledger_id ⇒ UUID | String
The ID of the ledger this ledger transaction belongs to.
70 71 72 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 70 def ledger_id @ledger_id end |
#ledgerable_id ⇒ UUID | String
If the ledger transaction can be reconciled to another object in Modern Treasury, the id will be populated here, otherwise null.
82 83 84 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 82 def ledgerable_id @ledgerable_id end |
#ledgerable_type ⇒ LedgerableType2
If the ledger transaction can be reconciled to another object in Modern Treasury, the type will be populated here, otherwise null. This can be one of payment_order, incoming_payment_detail, expected_payment, return, or reversal.
77 78 79 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 77 def ledgerable_type @ledgerable_type 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_transaction.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.
47 48 49 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 47 def @metadata end |
#object ⇒ String
TODO: Write general description for this method
19 20 21 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 19 def object @object end |
#posted_at ⇒ DateTime
The time on which the ledger transaction posted. This is null if the ledger transaction is pending.
66 67 68 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 66 def posted_at @posted_at end |
#reverses_ledger_transaction_id ⇒ String
The ID of the original ledger transaction that this ledger transaction reverses.
92 93 94 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 92 def reverses_ledger_transaction_id @reverses_ledger_transaction_id end |
#status ⇒ Status11
To post a ledger transaction at creation, use ‘posted`.
42 43 44 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 42 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_transaction.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.
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 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 160 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 description = hash.key?('description') ? hash['description'] : nil status = hash.key?('status') ? hash['status'] : nil = hash.key?('metadata') ? hash['metadata'] : nil effective_at = hash.key?('effective_at') ? hash['effective_at'] : nil effective_date = hash.key?('effective_date') ? hash['effective_date'] : nil # Parameter is an array, so we need to iterate through it ledger_entries = nil unless hash['ledger_entries'].nil? ledger_entries = [] hash['ledger_entries'].each do |structure| ledger_entries << (LedgerEntry.from_hash(structure) if structure) end end ledger_entries = nil unless hash.key?('ledger_entries') posted_at = if hash.key?('posted_at') (DateTimeHelper.from_rfc3339(hash['posted_at']) if hash['posted_at']) end ledger_id = hash.key?('ledger_id') ? hash['ledger_id'] : nil ledgerable_type = hash.key?('ledgerable_type') ? hash['ledgerable_type'] : nil ledgerable_id = hash.key?('ledgerable_id') ? hash['ledgerable_id'] : nil external_id = hash.key?('external_id') ? hash['external_id'] : nil reverses_ledger_transaction_id = hash.key?('reverses_ledger_transaction_id') ? hash['reverses_ledger_transaction_id'] : nil # Create object from extracted values. LedgerTransaction.new(id: id, object: object, live_mode: live_mode, created_at: created_at, updated_at: updated_at, description: description, status: status, metadata: , effective_at: effective_at, effective_date: effective_date, ledger_entries: ledger_entries, posted_at: posted_at, ledger_id: ledger_id, ledgerable_type: ledgerable_type, ledgerable_id: ledgerable_id, external_id: external_id, reverses_ledger_transaction_id: reverses_ledger_transaction_id) end |
.names ⇒ Object
A mapping from model property names to API property names.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 95 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['description'] = 'description' @_hash['status'] = 'status' @_hash['metadata'] = 'metadata' @_hash['effective_at'] = 'effective_at' @_hash['effective_date'] = 'effective_date' @_hash['ledger_entries'] = 'ledger_entries' @_hash['posted_at'] = 'posted_at' @_hash['ledger_id'] = 'ledger_id' @_hash['ledgerable_type'] = 'ledgerable_type' @_hash['ledgerable_id'] = 'ledgerable_id' @_hash['external_id'] = 'external_id' @_hash['reverses_ledger_transaction_id'] = 'reverses_ledger_transaction_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
124 125 126 127 128 129 130 131 132 133 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 124 def self.nullables %w[ description posted_at ledgerable_type ledgerable_id external_id reverses_ledger_transaction_id ] end |
.optionals ⇒ Object
An array for optional fields
119 120 121 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 119 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 245 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}, description: #{@description.inspect}, status: #{@status.inspect},"\ " metadata: #{@metadata.inspect}, effective_at: #{@effective_at.inspect}, effective_date:"\ " #{@effective_date.inspect}, ledger_entries: #{@ledger_entries.inspect}, posted_at:"\ " #{@posted_at.inspect}, ledger_id: #{@ledger_id.inspect}, ledgerable_type:"\ " #{@ledgerable_type.inspect}, ledgerable_id: #{@ledgerable_id.inspect}, external_id:"\ " #{@external_id.inspect}, reverses_ledger_transaction_id:"\ " #{@reverses_ledger_transaction_id.inspect}>" end |
#to_custom_created_at ⇒ Object
220 221 222 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 220 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_custom_posted_at ⇒ Object
228 229 230 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 228 def to_custom_posted_at DateTimeHelper.to_rfc3339(posted_at) end |
#to_custom_updated_at ⇒ Object
224 225 226 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 224 def to_custom_updated_at DateTimeHelper.to_rfc3339(updated_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
233 234 235 236 237 238 239 240 241 242 |
# File 'lib/modern_treasury/models/ledger_transaction.rb', line 233 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}, description: #{@description}, status:"\ " #{@status}, metadata: #{@metadata}, effective_at: #{@effective_at}, effective_date:"\ " #{@effective_date}, ledger_entries: #{@ledger_entries}, posted_at: #{@posted_at},"\ " ledger_id: #{@ledger_id}, ledgerable_type: #{@ledgerable_type}, ledgerable_id:"\ " #{@ledgerable_id}, external_id: #{@external_id}, reverses_ledger_transaction_id:"\ " #{@reverses_ledger_transaction_id}>" end |