Class: ModernTreasury::TransactionLineItem
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ModernTreasury::TransactionLineItem
- Defined in:
- lib/modern_treasury/models/transaction_line_item.rb
Overview
TransactionLineItem Model.
Instance Attribute Summary collapse
-
#amount ⇒ Integer
If a matching object exists in Modern Treasury, ‘amount` will be populated.
-
#counterparty_id ⇒ String
The ID for the counterparty for this transaction line item.
-
#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
If no matching object is found, ‘description` will be a free-form text field describing the line item.
-
#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.
-
#expected_payment_id ⇒ String
The ID of the reconciled Expected Payment, otherwise ‘null`.
-
#id ⇒ UUID | String
TODO: Write general description for this method.
-
#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.
-
#object ⇒ String
TODO: Write general description for this method.
-
#transactable_id ⇒ String
If a matching object exists in Modern Treasury, the ID will be populated here, otherwise ‘null`.
-
#transactable_type ⇒ TransactableType
If a matching object exists in Modern Treasury, the type will be populated here, otherwise ‘null`.
-
#type ⇒ Type12
Indicates whether the line item is ‘originating` or `receiving` (see www.moderntreasury.com/journal/beginners-guide-to-ach for more).
-
#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:, type:, transactable_type:, transactable_id:, amount:, description:, counterparty_id:, expected_payment_id:) ⇒ TransactionLineItem
constructor
A new instance of TransactionLineItem.
-
#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:, type:, transactable_type:, transactable_id:, amount:, description:, counterparty_id:, expected_payment_id:) ⇒ TransactionLineItem
Returns a new instance of TransactionLineItem.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/modern_treasury/models/transaction_line_item.rb', line 112 def initialize(id:, object:, live_mode:, created_at:, updated_at:, discarded_at:, type:, transactable_type:, transactable_id:, amount:, description:, counterparty_id:, expected_payment_id:) @id = id @object = object @live_mode = live_mode @created_at = created_at @updated_at = updated_at @discarded_at = discarded_at @type = type @transactable_type = transactable_type @transactable_id = transactable_id @amount = amount @description = description @counterparty_id = counterparty_id @expected_payment_id = expected_payment_id end |
Instance Attribute Details
#amount ⇒ Integer
If a matching object exists in Modern Treasury, ‘amount` will be populated. Value in specified currency’s smallest unit (taken from parent Transaction).
60 61 62 |
# File 'lib/modern_treasury/models/transaction_line_item.rb', line 60 def amount @amount end |
#counterparty_id ⇒ String
The ID for the counterparty for this transaction line item.
73 74 75 |
# File 'lib/modern_treasury/models/transaction_line_item.rb', line 73 def counterparty_id @counterparty_id 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/transaction_line_item.rb', line 29 def created_at @created_at end |
#description ⇒ String
If no matching object is found, ‘description` will be a free-form text field describing the line item. This field may contain personally identifiable information (PII) and is not included in API responses by default. Learn more about changing your settings at docs.moderntreasury.com/reference/personally-identifiable-informat ion.
69 70 71 |
# File 'lib/modern_treasury/models/transaction_line_item.rb', line 69 def description @description 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/transaction_line_item.rb', line 39 def discarded_at @discarded_at end |
#expected_payment_id ⇒ String
The ID of the reconciled Expected Payment, otherwise ‘null`.
77 78 79 |
# File 'lib/modern_treasury/models/transaction_line_item.rb', line 77 def expected_payment_id @expected_payment_id end |
#id ⇒ UUID | String
TODO: Write general description for this method
15 16 17 |
# File 'lib/modern_treasury/models/transaction_line_item.rb', line 15 def id @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/transaction_line_item.rb', line 24 def live_mode @live_mode end |
#object ⇒ String
TODO: Write general description for this method
19 20 21 |
# File 'lib/modern_treasury/models/transaction_line_item.rb', line 19 def object @object end |
#transactable_id ⇒ String
If a matching object exists in Modern Treasury, the ID will be populated here, otherwise ‘null`.
54 55 56 |
# File 'lib/modern_treasury/models/transaction_line_item.rb', line 54 def transactable_id @transactable_id end |
#transactable_type ⇒ TransactableType
If a matching object exists in Modern Treasury, the type will be populated here, otherwise ‘null`.
49 50 51 |
# File 'lib/modern_treasury/models/transaction_line_item.rb', line 49 def transactable_type @transactable_type end |
#type ⇒ Type12
Indicates whether the line item is ‘originating` or `receiving` (see www.moderntreasury.com/journal/beginners-guide-to-ach for more).
44 45 46 |
# File 'lib/modern_treasury/models/transaction_line_item.rb', line 44 def type @type 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/transaction_line_item.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.
132 133 134 135 136 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 |
# File 'lib/modern_treasury/models/transaction_line_item.rb', line 132 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 type = hash.key?('type') ? hash['type'] : nil transactable_type = hash.key?('transactable_type') ? hash['transactable_type'] : nil transactable_id = hash.key?('transactable_id') ? hash['transactable_id'] : nil amount = hash.key?('amount') ? hash['amount'] : nil description = hash.key?('description') ? hash['description'] : nil counterparty_id = hash.key?('counterparty_id') ? hash['counterparty_id'] : nil expected_payment_id = hash.key?('expected_payment_id') ? hash['expected_payment_id'] : nil # Create object from extracted values. TransactionLineItem.new(id: id, object: object, live_mode: live_mode, created_at: created_at, updated_at: updated_at, discarded_at: discarded_at, type: type, transactable_type: transactable_type, transactable_id: transactable_id, amount: amount, description: description, counterparty_id: counterparty_id, expected_payment_id: expected_payment_id) end |
.names ⇒ Object
A mapping from model property names to API property names.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/modern_treasury/models/transaction_line_item.rb', line 80 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['type'] = 'type' @_hash['transactable_type'] = 'transactable_type' @_hash['transactable_id'] = 'transactable_id' @_hash['amount'] = 'amount' @_hash['description'] = 'description' @_hash['counterparty_id'] = 'counterparty_id' @_hash['expected_payment_id'] = 'expected_payment_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
104 105 106 107 108 109 110 |
# File 'lib/modern_treasury/models/transaction_line_item.rb', line 104 def self.nullables %w[ discarded_at transactable_type transactable_id ] end |
.optionals ⇒ Object
An array for optional fields
99 100 101 |
# File 'lib/modern_treasury/models/transaction_line_item.rb', line 99 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
199 200 201 202 203 204 205 206 207 208 |
# File 'lib/modern_treasury/models/transaction_line_item.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}, updated_at:"\ " #{@updated_at.inspect}, discarded_at: #{@discarded_at.inspect}, type: #{@type.inspect},"\ " transactable_type: #{@transactable_type.inspect}, transactable_id:"\ " #{@transactable_id.inspect}, amount: #{@amount.inspect}, description:"\ " #{@description.inspect}, counterparty_id: #{@counterparty_id.inspect},"\ " expected_payment_id: #{@expected_payment_id.inspect}>" end |
#to_custom_created_at ⇒ Object
176 177 178 |
# File 'lib/modern_treasury/models/transaction_line_item.rb', line 176 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_custom_discarded_at ⇒ Object
184 185 186 |
# File 'lib/modern_treasury/models/transaction_line_item.rb', line 184 def to_custom_discarded_at DateTimeHelper.to_rfc3339(discarded_at) end |
#to_custom_updated_at ⇒ Object
180 181 182 |
# File 'lib/modern_treasury/models/transaction_line_item.rb', line 180 def to_custom_updated_at DateTimeHelper.to_rfc3339(updated_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
189 190 191 192 193 194 195 196 |
# File 'lib/modern_treasury/models/transaction_line_item.rb', line 189 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}, type:"\ " #{@type}, transactable_type: #{@transactable_type}, transactable_id: #{@transactable_id},"\ " amount: #{@amount}, description: #{@description}, counterparty_id: #{@counterparty_id},"\ " expected_payment_id: #{@expected_payment_id}>" end |