Class: Plaid::TransactionBase
- Defined in:
- lib/plaid/models/transaction_base.rb
Overview
A representation of a transaction
Instance Attribute Summary collapse
-
#account_id ⇒ String
The ID of the account in which this transaction occurred.
-
#account_owner ⇒ String
The name of the account owner.
-
#amount ⇒ Float
The settled value of the transaction, denominated in the account’s currency, as stated in ‘iso_currency_code` or `unofficial_currency_code`.
-
#category ⇒ Array[String]
A hierarchical array of the categories to which this transaction belongs.
-
#category_id ⇒ String
The ID of the category to which this transaction belongs.
-
#date ⇒ Date
For pending transactions, the date that the transaction occurred; for posted transactions, the date that the transaction posted.
-
#iso_currency_code ⇒ String
The ISO-4217 currency code of the transaction.
-
#location ⇒ TransactionLocation
A representation of where a transaction took place.
-
#name ⇒ String
The merchant name or transaction description.
-
#original_description ⇒ String
The string returned by the financial institution to describe the transaction.
-
#payment_meta ⇒ PaymentMeta
Transaction information specific to inter-bank transfers.
-
#pending ⇒ TrueClass | FalseClass
When ‘true`, identifies the transaction as pending or unsettled.
-
#pending_transaction_id ⇒ String
The ID of a posted transaction’s associated pending transaction, where applicable.
-
#transaction_id ⇒ String
The unique ID of the transaction.
-
#transaction_type ⇒ TransactionType
Please use the ‘payment_channel` field, `transaction_type` will be deprecated in the future.
-
#unofficial_currency_code ⇒ String
The unofficial currency code associated with the transaction.
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(account_id:, amount:, iso_currency_code:, unofficial_currency_code:, date:, pending:, transaction_id:, transaction_type: SKIP, pending_transaction_id: SKIP, category_id: SKIP, category: SKIP, location: SKIP, payment_meta: SKIP, account_owner: SKIP, name: SKIP, original_description: SKIP, additional_properties: nil) ⇒ TransactionBase
constructor
A new instance of TransactionBase.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#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(account_id:, amount:, iso_currency_code:, unofficial_currency_code:, date:, pending:, transaction_id:, transaction_type: SKIP, pending_transaction_id: SKIP, category_id: SKIP, category: SKIP, location: SKIP, payment_meta: SKIP, account_owner: SKIP, name: SKIP, original_description: SKIP, additional_properties: nil) ⇒ TransactionBase
Returns a new instance of TransactionBase.
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 |
# File 'lib/plaid/models/transaction_base.rb', line 174 def initialize(account_id:, amount:, iso_currency_code:, unofficial_currency_code:, date:, pending:, transaction_id:, transaction_type: SKIP, pending_transaction_id: SKIP, category_id: SKIP, category: SKIP, location: SKIP, payment_meta: SKIP, account_owner: SKIP, name: SKIP, original_description: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @transaction_type = transaction_type unless transaction_type == SKIP @pending_transaction_id = pending_transaction_id unless pending_transaction_id == SKIP @category_id = category_id unless category_id == SKIP @category = category unless category == SKIP @location = location unless location == SKIP @payment_meta = unless == SKIP @account_owner = account_owner unless account_owner == SKIP @name = name unless name == SKIP @original_description = original_description unless original_description == SKIP @account_id = account_id @amount = amount @iso_currency_code = iso_currency_code @unofficial_currency_code = unofficial_currency_code @date = date @pending = pending @transaction_id = transaction_id @additional_properties = additional_properties end |
Instance Attribute Details
#account_id ⇒ String
The ID of the account in which this transaction occurred.
81 82 83 |
# File 'lib/plaid/models/transaction_base.rb', line 81 def account_id @account_id end |
#account_owner ⇒ String
The name of the account owner. This field is not typically populated and only relevant when dealing with sub-accounts.
60 61 62 |
# File 'lib/plaid/models/transaction_base.rb', line 60 def account_owner @account_owner end |
#amount ⇒ Float
The settled value of the transaction, denominated in the account’s currency, as stated in ‘iso_currency_code` or `unofficial_currency_code`. Positive values when money moves out of the account; negative values when money moves in. For example, debit card purchases are positive; credit card payments, direct deposits, and refunds are negative.
89 90 91 |
# File 'lib/plaid/models/transaction_base.rb', line 89 def amount @amount end |
#category ⇒ Array[String]
A hierarchical array of the categories to which this transaction belongs. See [Categories](plaid.com/docs/#category-overview). If the ‘transactions` object was returned by an Assets endpoint such as `/asset_report/get/` or `/asset_report/pdf/get`, this field will only appear in an Asset Report with Insights.
40 41 42 |
# File 'lib/plaid/models/transaction_base.rb', line 40 def category @category end |
#category_id ⇒ String
The ID of the category to which this transaction belongs. See [Categories](plaid.com/docs/#category-overview). If the ‘transactions` object was returned by an Assets endpoint such as `/asset_report/get/` or `/asset_report/pdf/get`, this field will only appear in an Asset Report with Insights.
32 33 34 |
# File 'lib/plaid/models/transaction_base.rb', line 32 def category_id @category_id end |
#date ⇒ Date
For pending transactions, the date that the transaction occurred; for posted transactions, the date that the transaction posted. Both dates are returned in an [ISO 8601](wikipedia.org/wiki/ISO_8601) format ( ‘YYYY-MM-DD` ).
111 112 113 |
# File 'lib/plaid/models/transaction_base.rb', line 111 def date @date end |
#iso_currency_code ⇒ String
The ISO-4217 currency code of the transaction. Always ‘null` if `unofficial_currency_code` is non-null.
94 95 96 |
# File 'lib/plaid/models/transaction_base.rb', line 94 def iso_currency_code @iso_currency_code end |
#location ⇒ TransactionLocation
A representation of where a transaction took place
44 45 46 |
# File 'lib/plaid/models/transaction_base.rb', line 44 def location @location end |
#name ⇒ String
The merchant name or transaction description. If the ‘transactions` object was returned by a Transactions endpoint such as `/transactions/get`, this field will always appear. If the `transactions` object was returned by an Assets endpoint such as `/asset_report/get/` or `/asset_report/pdf/get`, this field will only appear in an Asset Report with Insights.
69 70 71 |
# File 'lib/plaid/models/transaction_base.rb', line 69 def name @name end |
#original_description ⇒ String
The string returned by the financial institution to describe the transaction. For transactions returned by ‘/transactions/get`, this field is in beta and will be omitted unless the client is both enrolled in the closed beta program and has set `options.include_original_description` to `true`.
77 78 79 |
# File 'lib/plaid/models/transaction_base.rb', line 77 def original_description @original_description end |
#payment_meta ⇒ PaymentMeta
Transaction information specific to inter-bank transfers. If the transaction was not an inter-bank transfer, all fields will be ‘null`. If the `transactions` object was returned by a Transactions endpoint such as `/transactions/get`, the `payment_meta` key will always appear, but no data elements are guaranteed. If the `transactions` object was returned by an Assets endpoint such as `/asset_report/get/` or `/asset_report/pdf/get`, this field will only appear in an Asset Report with Insights.
55 56 57 |
# File 'lib/plaid/models/transaction_base.rb', line 55 def @payment_meta end |
#pending ⇒ TrueClass | FalseClass
When ‘true`, identifies the transaction as pending or unsettled. Pending transaction details (name, type, amount, category ID) may change before they are settled.
117 118 119 |
# File 'lib/plaid/models/transaction_base.rb', line 117 def pending @pending end |
#pending_transaction_id ⇒ String
The ID of a posted transaction’s associated pending transaction, where applicable.
24 25 26 |
# File 'lib/plaid/models/transaction_base.rb', line 24 def pending_transaction_id @pending_transaction_id end |
#transaction_id ⇒ String
The unique ID of the transaction. Like all Plaid identifiers, the ‘transaction_id` is case sensitive.
122 123 124 |
# File 'lib/plaid/models/transaction_base.rb', line 122 def transaction_id @transaction_id end |
#transaction_type ⇒ TransactionType
Please use the ‘payment_channel` field, `transaction_type` will be deprecated in the future. `digital:` transactions that took place online. `place:` transactions that were made at a physical location. `special:` transactions that relate to banks, e.g. fees or deposits. `unresolved:` transactions that do not fit into the other three types.
19 20 21 |
# File 'lib/plaid/models/transaction_base.rb', line 19 def transaction_type @transaction_type end |
#unofficial_currency_code ⇒ String
The unofficial currency code associated with the transaction. Always ‘null` if `iso_currency_code` is non-`null`. Unofficial currency codes are used for currencies that do not have official ISO currency codes, such as cryptocurrencies and the currencies of certain countries. See the [currency code schema](plaid.com/docs/api/accounts#currency-code-schema) for a full listing of supported `iso_currency_code`s.
104 105 106 |
# File 'lib/plaid/models/transaction_base.rb', line 104 def unofficial_currency_code @unofficial_currency_code end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 |
# File 'lib/plaid/models/transaction_base.rb', line 203 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. account_id = hash.key?('account_id') ? hash['account_id'] : nil amount = hash.key?('amount') ? hash['amount'] : nil iso_currency_code = hash.key?('iso_currency_code') ? hash['iso_currency_code'] : nil unofficial_currency_code = hash.key?('unofficial_currency_code') ? hash['unofficial_currency_code'] : nil date = hash.key?('date') ? hash['date'] : nil pending = hash.key?('pending') ? hash['pending'] : nil transaction_id = hash.key?('transaction_id') ? hash['transaction_id'] : nil transaction_type = hash.key?('transaction_type') ? hash['transaction_type'] : SKIP pending_transaction_id = hash.key?('pending_transaction_id') ? hash['pending_transaction_id'] : SKIP category_id = hash.key?('category_id') ? hash['category_id'] : SKIP category = hash.key?('category') ? hash['category'] : SKIP location = TransactionLocation.from_hash(hash['location']) if hash['location'] = PaymentMeta.from_hash(hash['payment_meta']) if hash['payment_meta'] account_owner = hash.key?('account_owner') ? hash['account_owner'] : SKIP name = hash.key?('name') ? hash['name'] : SKIP original_description = hash.key?('original_description') ? hash['original_description'] : SKIP # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. TransactionBase.new(account_id: account_id, amount: amount, iso_currency_code: iso_currency_code, unofficial_currency_code: unofficial_currency_code, date: date, pending: pending, transaction_id: transaction_id, transaction_type: transaction_type, pending_transaction_id: pending_transaction_id, category_id: category_id, category: category, location: location, payment_meta: , account_owner: account_owner, name: name, original_description: original_description, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/plaid/models/transaction_base.rb', line 125 def self.names @_hash = {} if @_hash.nil? @_hash['transaction_type'] = 'transaction_type' @_hash['pending_transaction_id'] = 'pending_transaction_id' @_hash['category_id'] = 'category_id' @_hash['category'] = 'category' @_hash['location'] = 'location' @_hash['payment_meta'] = 'payment_meta' @_hash['account_owner'] = 'account_owner' @_hash['name'] = 'name' @_hash['original_description'] = 'original_description' @_hash['account_id'] = 'account_id' @_hash['amount'] = 'amount' @_hash['iso_currency_code'] = 'iso_currency_code' @_hash['unofficial_currency_code'] = 'unofficial_currency_code' @_hash['date'] = 'date' @_hash['pending'] = 'pending' @_hash['transaction_id'] = 'transaction_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/plaid/models/transaction_base.rb', line 162 def self.nullables %w[ pending_transaction_id category_id category account_owner original_description iso_currency_code unofficial_currency_code ] end |
.optionals ⇒ Object
An array for optional fields
147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/plaid/models/transaction_base.rb', line 147 def self.optionals %w[ transaction_type pending_transaction_id category_id category location payment_meta account_owner name original_description ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/plaid/models/transaction_base.rb', line 271 def inspect class_name = self.class.name.split('::').last "<#{class_name} transaction_type: #{@transaction_type.inspect}, pending_transaction_id:"\ " #{@pending_transaction_id.inspect}, category_id: #{@category_id.inspect}, category:"\ " #{@category.inspect}, location: #{@location.inspect}, payment_meta:"\ " #{@payment_meta.inspect}, account_owner: #{@account_owner.inspect}, name:"\ " #{@name.inspect}, original_description: #{@original_description.inspect}, account_id:"\ " #{@account_id.inspect}, amount: #{@amount.inspect}, iso_currency_code:"\ " #{@iso_currency_code.inspect}, unofficial_currency_code:"\ " #{@unofficial_currency_code.inspect}, date: #{@date.inspect}, pending:"\ " #{@pending.inspect}, transaction_id: #{@transaction_id.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/plaid/models/transaction_base.rb', line 258 def to_s class_name = self.class.name.split('::').last "<#{class_name} transaction_type: #{@transaction_type}, pending_transaction_id:"\ " #{@pending_transaction_id}, category_id: #{@category_id}, category: #{@category},"\ " location: #{@location}, payment_meta: #{@payment_meta}, account_owner: #{@account_owner},"\ " name: #{@name}, original_description: #{@original_description}, account_id:"\ " #{@account_id}, amount: #{@amount}, iso_currency_code: #{@iso_currency_code},"\ " unofficial_currency_code: #{@unofficial_currency_code}, date: #{@date}, pending:"\ " #{@pending}, transaction_id: #{@transaction_id}, additional_properties:"\ " #{@additional_properties}>" end |