Class: ModernTreasury::Transaction
- Defined in:
- lib/modern_treasury/models/transaction.rb
Overview
Transaction Model.
Instance Attribute Summary collapse
-
#amount ⇒ Integer
Value in specified currency’s smallest unit.
-
#as_of_date ⇒ Date
The date on which the transaction occurred.
-
#as_of_time ⇒ DateTime
The time on which the transaction occurred.
-
#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.
-
#currency ⇒ Currency
Three-letter ISO currency code.
-
#details ⇒ Hash[String, String]
This field contains additional information that the bank provided about the transaction.
-
#direction ⇒ String
Either ‘credit` or `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.
-
#internal_account_id ⇒ UUID | String
The ID of the relevant Internal Account.
-
#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 ⇒ TrueClass | FalseClass
This field will be ‘true` if the transaction has posted to the account.
-
#reconciled ⇒ TrueClass | FalseClass
This field will be ‘true` if a transaction is reconciled by the Modern Treasury system.
-
#type ⇒ Type11
The type of the transaction.
-
#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.
-
#vendor_code ⇒ String
When applicable, the bank-given code that determines the transaction’s category.
-
#vendor_code_type ⇒ VendorCodeType1
The type of ‘vendor_code` being reported.
-
#vendor_customer_id ⇒ String
An identifier given to this transaction by the bank, often ‘null`.
-
#vendor_description ⇒ String
The transaction detail text that often appears in on your bank statement and in your banking portal.
-
#vendor_id ⇒ String
An identifier given to this transaction by the bank.
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:, currency:, direction:, vendor_description:, vendor_code:, vendor_code_type:, vendor_id:, as_of_date:, as_of_time:, internal_account_id:, metadata:, posted:, vendor_customer_id:, reconciled:, details:, type:) ⇒ Transaction
constructor
A new instance of Transaction.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_as_of_time ⇒ Object
- #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:, currency:, direction:, vendor_description:, vendor_code:, vendor_code_type:, vendor_id:, as_of_date:, as_of_time:, internal_account_id:, metadata:, posted:, vendor_customer_id:, reconciled:, details:, type:) ⇒ Transaction
Returns a new instance of Transaction.
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 |
# File 'lib/modern_treasury/models/transaction.rb', line 170 def initialize(id:, object:, live_mode:, created_at:, updated_at:, discarded_at:, amount:, currency:, direction:, vendor_description:, vendor_code:, vendor_code_type:, vendor_id:, as_of_date:, as_of_time:, internal_account_id:, metadata:, posted:, vendor_customer_id:, reconciled:, details:, type:) @id = id @object = object @live_mode = live_mode @created_at = created_at @updated_at = updated_at @discarded_at = discarded_at @amount = amount @currency = currency @direction = direction @vendor_description = vendor_description @vendor_code = vendor_code @vendor_code_type = vendor_code_type @vendor_id = vendor_id @as_of_date = as_of_date @as_of_time = as_of_time @internal_account_id = internal_account_id @metadata = @posted = posted @vendor_customer_id = vendor_customer_id @reconciled = reconciled @details = details @type = type end |
Instance Attribute Details
#amount ⇒ Integer
Value in specified currency’s smallest unit. e.g. $10 would be represented as 1000.
44 45 46 |
# File 'lib/modern_treasury/models/transaction.rb', line 44 def amount @amount end |
#as_of_date ⇒ Date
The date on which the transaction occurred.
77 78 79 |
# File 'lib/modern_treasury/models/transaction.rb', line 77 def as_of_date @as_of_date end |
#as_of_time ⇒ DateTime
The time on which the transaction occurred. Depending on the granularity of the timestamp information received from the bank, it may be ‘null`.
82 83 84 |
# File 'lib/modern_treasury/models/transaction.rb', line 82 def as_of_time @as_of_time 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.rb', line 29 def created_at @created_at end |
#currency ⇒ Currency
Three-letter ISO currency code.
48 49 50 |
# File 'lib/modern_treasury/models/transaction.rb', line 48 def currency @currency end |
#details ⇒ Hash[String, String]
This field contains additional information that the bank provided about the transaction. This is structured data. Some of the data in here might overlap with what is in the ‘vendor_description`. For example, the OBI could be a part of the vendor description, and it would also be included in here. The attributes that are passed through the details field will vary based on your banking partner. Currently, the following keys may be in the details object: `originator_name`, `originator_to_beneficiary_information`.
116 117 118 |
# File 'lib/modern_treasury/models/transaction.rb', line 116 def details @details end |
#direction ⇒ String
Either ‘credit` or `debit`.
52 53 54 |
# File 'lib/modern_treasury/models/transaction.rb', line 52 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/transaction.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/transaction.rb', line 15 def id @id end |
#internal_account_id ⇒ UUID | String
The ID of the relevant Internal Account.
86 87 88 |
# File 'lib/modern_treasury/models/transaction.rb', line 86 def internal_account_id @internal_account_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.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.
91 92 93 |
# File 'lib/modern_treasury/models/transaction.rb', line 91 def @metadata end |
#object ⇒ String
TODO: Write general description for this method
19 20 21 |
# File 'lib/modern_treasury/models/transaction.rb', line 19 def object @object end |
#posted ⇒ TrueClass | FalseClass
This field will be ‘true` if the transaction has posted to the account.
95 96 97 |
# File 'lib/modern_treasury/models/transaction.rb', line 95 def posted @posted end |
#reconciled ⇒ TrueClass | FalseClass
This field will be ‘true` if a transaction is reconciled by the Modern Treasury system. This means that it has transaction line items that sum up to the transaction’s amount.
105 106 107 |
# File 'lib/modern_treasury/models/transaction.rb', line 105 def reconciled @reconciled end |
#type ⇒ Type11
The type of the transaction. Can be one of ‘ach`, `wire`, `check`, `rtp`, `book`, or `sen`.
121 122 123 |
# File 'lib/modern_treasury/models/transaction.rb', line 121 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.rb', line 34 def updated_at @updated_at end |
#vendor_code ⇒ String
When applicable, the bank-given code that determines the transaction’s category. For most banks this is the BAI2/BTRS transaction code.
62 63 64 |
# File 'lib/modern_treasury/models/transaction.rb', line 62 def vendor_code @vendor_code end |
#vendor_code_type ⇒ VendorCodeType1
The type of ‘vendor_code` being reported. Can be one of `bai2`, `bankprov`, `bnk_dev`, `cleartouch`, `currencycloud`, `cross_river`, `dc_bank`, `dwolla`, `evolve`, `goldman_sachs`, `iso20022`, `jpmc`, `mx`, `signet`, `silvergate`, `swift`, or `us_bank`.
69 70 71 |
# File 'lib/modern_treasury/models/transaction.rb', line 69 def vendor_code_type @vendor_code_type end |
#vendor_customer_id ⇒ String
An identifier given to this transaction by the bank, often ‘null`.
99 100 101 |
# File 'lib/modern_treasury/models/transaction.rb', line 99 def vendor_customer_id @vendor_customer_id end |
#vendor_description ⇒ String
The transaction detail text that often appears in on your bank statement and in your banking portal.
57 58 59 |
# File 'lib/modern_treasury/models/transaction.rb', line 57 def vendor_description @vendor_description end |
#vendor_id ⇒ String
An identifier given to this transaction by the bank.
73 74 75 |
# File 'lib/modern_treasury/models/transaction.rb', line 73 def vendor_id @vendor_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/modern_treasury/models/transaction.rb', line 201 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 currency = hash.key?('currency') ? hash['currency'] : nil direction = hash.key?('direction') ? hash['direction'] : nil vendor_description = hash.key?('vendor_description') ? hash['vendor_description'] : nil vendor_code = hash.key?('vendor_code') ? hash['vendor_code'] : nil vendor_code_type = hash.key?('vendor_code_type') ? hash['vendor_code_type'] : nil vendor_id = hash.key?('vendor_id') ? hash['vendor_id'] : nil as_of_date = hash.key?('as_of_date') ? hash['as_of_date'] : nil as_of_time = if hash.key?('as_of_time') (DateTimeHelper.from_rfc3339(hash['as_of_time']) if hash['as_of_time']) end internal_account_id = hash.key?('internal_account_id') ? hash['internal_account_id'] : nil = hash.key?('metadata') ? hash['metadata'] : nil posted = hash.key?('posted') ? hash['posted'] : nil vendor_customer_id = hash.key?('vendor_customer_id') ? hash['vendor_customer_id'] : nil reconciled = hash.key?('reconciled') ? hash['reconciled'] : nil details = hash.key?('details') ? hash['details'] : nil type = hash.key?('type') ? hash['type'] : nil # Create object from extracted values. Transaction.new(id: id, object: object, live_mode: live_mode, created_at: created_at, updated_at: updated_at, discarded_at: discarded_at, amount: amount, currency: currency, direction: direction, vendor_description: vendor_description, vendor_code: vendor_code, vendor_code_type: vendor_code_type, vendor_id: vendor_id, as_of_date: as_of_date, as_of_time: as_of_time, internal_account_id: internal_account_id, metadata: , posted: posted, vendor_customer_id: vendor_customer_id, reconciled: reconciled, details: details, type: type) end |
.names ⇒ Object
A mapping from model property names to API property names.
124 125 126 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/transaction.rb', line 124 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['currency'] = 'currency' @_hash['direction'] = 'direction' @_hash['vendor_description'] = 'vendor_description' @_hash['vendor_code'] = 'vendor_code' @_hash['vendor_code_type'] = 'vendor_code_type' @_hash['vendor_id'] = 'vendor_id' @_hash['as_of_date'] = 'as_of_date' @_hash['as_of_time'] = 'as_of_time' @_hash['internal_account_id'] = 'internal_account_id' @_hash['metadata'] = 'metadata' @_hash['posted'] = 'posted' @_hash['vendor_customer_id'] = 'vendor_customer_id' @_hash['reconciled'] = 'reconciled' @_hash['details'] = 'details' @_hash['type'] = 'type' @_hash end |
.nullables ⇒ Object
An array for nullable fields
157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/modern_treasury/models/transaction.rb', line 157 def self.nullables %w[ discarded_at vendor_description vendor_code vendor_code_type vendor_id as_of_date as_of_time vendor_customer_id ] end |
.optionals ⇒ Object
An array for optional fields
152 153 154 |
# File 'lib/modern_treasury/models/transaction.rb', line 152 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/modern_treasury/models/transaction.rb', line 295 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}, currency: #{@currency.inspect}, direction: #{@direction.inspect},"\ " vendor_description: #{@vendor_description.inspect}, vendor_code: #{@vendor_code.inspect},"\ " vendor_code_type: #{@vendor_code_type.inspect}, vendor_id: #{@vendor_id.inspect},"\ " as_of_date: #{@as_of_date.inspect}, as_of_time: #{@as_of_time.inspect},"\ " internal_account_id: #{@internal_account_id.inspect}, metadata: #{@metadata.inspect},"\ " posted: #{@posted.inspect}, vendor_customer_id: #{@vendor_customer_id.inspect},"\ " reconciled: #{@reconciled.inspect}, details: #{@details.inspect}, type: #{@type.inspect}>" end |
#to_custom_as_of_time ⇒ Object
277 278 279 |
# File 'lib/modern_treasury/models/transaction.rb', line 277 def to_custom_as_of_time DateTimeHelper.to_rfc3339(as_of_time) end |
#to_custom_created_at ⇒ Object
265 266 267 |
# File 'lib/modern_treasury/models/transaction.rb', line 265 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_custom_discarded_at ⇒ Object
273 274 275 |
# File 'lib/modern_treasury/models/transaction.rb', line 273 def to_custom_discarded_at DateTimeHelper.to_rfc3339(discarded_at) end |
#to_custom_updated_at ⇒ Object
269 270 271 |
# File 'lib/modern_treasury/models/transaction.rb', line 269 def to_custom_updated_at DateTimeHelper.to_rfc3339(updated_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/modern_treasury/models/transaction.rb', line 282 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}, currency: #{@currency}, direction: #{@direction}, vendor_description:"\ " #{@vendor_description}, vendor_code: #{@vendor_code}, vendor_code_type:"\ " #{@vendor_code_type}, vendor_id: #{@vendor_id}, as_of_date: #{@as_of_date}, as_of_time:"\ " #{@as_of_time}, internal_account_id: #{@internal_account_id}, metadata: #{@metadata},"\ " posted: #{@posted}, vendor_customer_id: #{@vendor_customer_id}, reconciled:"\ " #{@reconciled}, details: #{@details}, type: #{@type}>" end |