Class: ThePlaidApi::TransactionBase
- Defined in:
- lib/the_plaid_api/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
This field is not typically populated and only relevant when dealing with sub-accounts.
-
#amount ⇒ Float
The settled value of the transaction, denominated in the transactions’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.
-
#check_number ⇒ String
The check number of the transaction.
-
#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.
-
#logo_url ⇒ String
The URL of a logo associated with this transaction, if available.
-
#merchant_name ⇒ String
The merchant name, as enriched by Plaid from the ‘name` field.
-
#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.
-
#website ⇒ String
The website associated with this transaction, if available.
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:, category: SKIP, category_id: SKIP, check_number: SKIP, location: SKIP, name: SKIP, merchant_name: SKIP, original_description: SKIP, payment_meta: SKIP, pending_transaction_id: SKIP, account_owner: SKIP, transaction_type: SKIP, logo_url: SKIP, website: 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:, category: SKIP, category_id: SKIP, check_number: SKIP, location: SKIP, name: SKIP, merchant_name: SKIP, original_description: SKIP, payment_meta: SKIP, pending_transaction_id: SKIP, account_owner: SKIP, transaction_type: SKIP, logo_url: SKIP, website: SKIP, additional_properties: nil) ⇒ TransactionBase
Returns a new instance of TransactionBase.
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 264 265 266 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 234 def initialize(account_id:, amount:, iso_currency_code:, unofficial_currency_code:, date:, pending:, transaction_id:, category: SKIP, category_id: SKIP, check_number: SKIP, location: SKIP, name: SKIP, merchant_name: SKIP, original_description: SKIP, payment_meta: SKIP, pending_transaction_id: SKIP, account_owner: SKIP, transaction_type: SKIP, logo_url: SKIP, website: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @account_id = account_id @amount = amount @iso_currency_code = iso_currency_code @unofficial_currency_code = unofficial_currency_code @category = category unless category == SKIP @category_id = category_id unless category_id == SKIP @check_number = check_number unless check_number == SKIP @date = date @location = location unless location == SKIP @name = name unless name == SKIP @merchant_name = merchant_name unless merchant_name == SKIP @original_description = original_description unless original_description == SKIP @payment_meta = unless == SKIP @pending = pending @pending_transaction_id = pending_transaction_id unless pending_transaction_id == SKIP @account_owner = account_owner unless account_owner == SKIP @transaction_id = transaction_id @transaction_type = transaction_type unless transaction_type == SKIP @logo_url = logo_url unless logo_url == SKIP @website = website unless website == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#account_id ⇒ String
The ID of the account in which this transaction occurred.
14 15 16 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 14 def account_id @account_id end |
#account_owner ⇒ String
This field is not typically populated and only relevant when dealing with sub-accounts. A sub-account most commonly exists in cases where a single account is linked to multiple cards, each with its own card number and card holder name; each card will be considered a sub-account. If the account does have sub-accounts, this field will typically be some combination of the sub-account owner’s name and/or the sub-account mask. The format of this field is not standardized and will vary based on institution.
147 148 149 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 147 def account_owner @account_owner end |
#amount ⇒ Float
The settled value of the transaction, denominated in the transactions’s currency, as stated in ‘iso_currency_code` or `unofficial_currency_code`. For all products except Income: 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. For Income endpoints, values are positive when representing income.
24 25 26 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 24 def amount @amount end |
#category ⇒ Array[String]
A hierarchical array of the categories to which this transaction belongs. For a full list of categories, see [‘/categories/get`](plaid.com/docs/api/products/transactions/#cate goriesget). All Transactions implementations are recommended to use the new `personal_finance_category` instead of `category`, as it provides greater accuracy and more meaningful categorization. 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.
52 53 54 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 52 def category @category end |
#category_id ⇒ String
The ID of the category to which this transaction belongs. For a full list of categories, see [‘/categories/get`](plaid.com/docs/api/products/transactions/#cate goriesget). All Transactions implementations are recommended to use the new `personal_finance_category` instead of `category`, as it provides greater accuracy and more meaningful categorization. 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.
65 66 67 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 65 def category_id @category_id end |
#check_number ⇒ String
The check number of the transaction. This field is only populated for check transactions.
70 71 72 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 70 def check_number @check_number 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` ). To receive information about the date that a posted transaction was initiated, see the `authorized_date` field.
78 79 80 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 78 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.
29 30 31 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 29 def iso_currency_code @iso_currency_code end |
#location ⇒ TransactionLocation
A representation of where a transaction took place. Location data is provided only for transactions at physical locations, not for online transactions. Location data availability depends primarily on the merchant and is most likely to be populated for transactions at large retail chains; small, local businesses are less likely to have location data available.
87 88 89 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 87 def location @location end |
#logo_url ⇒ String
The URL of a logo associated with this transaction, if available. The logo will always be 100×100 pixel PNG file.
166 167 168 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 166 def logo_url @logo_url end |
#merchant_name ⇒ String
The merchant name, as enriched by Plaid from the ‘name` field. This is typically a more human-readable version of the merchant counterparty in the transaction. For some bank transactions (such as checks or account transfers) where there is no meaningful merchant name, this value will be `null`.
107 108 109 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 107 def merchant_name @merchant_name end |
#name ⇒ String
The merchant name or transaction description. Note: While Plaid does not currently plan to remove this field, it is a legacy field that is not actively maintained. Use ‘merchant_name` instead for the merchant name. If the `transactions` object was returned by a Transactions endpoint such as `/transactions/sync` or `/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.
99 100 101 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 99 def name @name end |
#original_description ⇒ String
The string returned by the financial institution to describe the transaction. For transactions returned by ‘/transactions/sync` or `/transactions/get`, this field will only be included if the client has set `options.include_original_description` to `true`.
114 115 116 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 114 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/sync` or `/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.
125 126 127 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 125 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. Not all institutions provide pending transactions.
131 132 133 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 131 def pending @pending end |
#pending_transaction_id ⇒ String
The ID of a posted transaction’s associated pending transaction, where applicable. Not all institutions provide pending transactions.
136 137 138 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 136 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.
152 153 154 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 152 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.
161 162 163 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 161 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.
39 40 41 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 39 def unofficial_currency_code @unofficial_currency_code end |
#website ⇒ String
The website associated with this transaction, if available.
170 171 172 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 170 def website @website end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 269 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 category = hash.key?('category') ? hash['category'] : SKIP category_id = hash.key?('category_id') ? hash['category_id'] : SKIP check_number = hash.key?('check_number') ? hash['check_number'] : SKIP location = TransactionLocation.from_hash(hash['location']) if hash['location'] name = hash.key?('name') ? hash['name'] : SKIP merchant_name = hash.key?('merchant_name') ? hash['merchant_name'] : SKIP original_description = hash.key?('original_description') ? hash['original_description'] : SKIP = PaymentMeta.from_hash(hash['payment_meta']) if hash['payment_meta'] pending_transaction_id = hash.key?('pending_transaction_id') ? hash['pending_transaction_id'] : SKIP account_owner = hash.key?('account_owner') ? hash['account_owner'] : SKIP transaction_type = hash.key?('transaction_type') ? hash['transaction_type'] : SKIP logo_url = hash.key?('logo_url') ? hash['logo_url'] : SKIP website = hash.key?('website') ? hash['website'] : 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, category: category, category_id: category_id, check_number: check_number, location: location, name: name, merchant_name: merchant_name, original_description: original_description, payment_meta: , pending_transaction_id: pending_transaction_id, account_owner: account_owner, transaction_type: transaction_type, logo_url: logo_url, website: website, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 173 def self.names @_hash = {} if @_hash.nil? @_hash['account_id'] = 'account_id' @_hash['amount'] = 'amount' @_hash['iso_currency_code'] = 'iso_currency_code' @_hash['unofficial_currency_code'] = 'unofficial_currency_code' @_hash['category'] = 'category' @_hash['category_id'] = 'category_id' @_hash['check_number'] = 'check_number' @_hash['date'] = 'date' @_hash['location'] = 'location' @_hash['name'] = 'name' @_hash['merchant_name'] = 'merchant_name' @_hash['original_description'] = 'original_description' @_hash['payment_meta'] = 'payment_meta' @_hash['pending'] = 'pending' @_hash['pending_transaction_id'] = 'pending_transaction_id' @_hash['account_owner'] = 'account_owner' @_hash['transaction_id'] = 'transaction_id' @_hash['transaction_type'] = 'transaction_type' @_hash['logo_url'] = 'logo_url' @_hash['website'] = 'website' @_hash end |
.nullables ⇒ Object
An array for nullable fields
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 218 def self.nullables %w[ iso_currency_code unofficial_currency_code category category_id check_number merchant_name original_description pending_transaction_id account_owner logo_url website ] end |
.optionals ⇒ Object
An array for optional fields
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 199 def self.optionals %w[ category category_id check_number location name merchant_name original_description payment_meta pending_transaction_id account_owner transaction_type logo_url website ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 346 def inspect class_name = self.class.name.split('::').last "<#{class_name} account_id: #{@account_id.inspect}, amount: #{@amount.inspect},"\ " iso_currency_code: #{@iso_currency_code.inspect}, unofficial_currency_code:"\ " #{@unofficial_currency_code.inspect}, category: #{@category.inspect}, category_id:"\ " #{@category_id.inspect}, check_number: #{@check_number.inspect}, date: #{@date.inspect},"\ " location: #{@location.inspect}, name: #{@name.inspect}, merchant_name:"\ " #{@merchant_name.inspect}, original_description: #{@original_description.inspect},"\ " payment_meta: #{@payment_meta.inspect}, pending: #{@pending.inspect},"\ " pending_transaction_id: #{@pending_transaction_id.inspect}, account_owner:"\ " #{@account_owner.inspect}, transaction_id: #{@transaction_id.inspect}, transaction_type:"\ " #{@transaction_type.inspect}, logo_url: #{@logo_url.inspect}, website:"\ " #{@website.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
332 333 334 335 336 337 338 339 340 341 342 343 |
# File 'lib/the_plaid_api/models/transaction_base.rb', line 332 def to_s class_name = self.class.name.split('::').last "<#{class_name} account_id: #{@account_id}, amount: #{@amount}, iso_currency_code:"\ " #{@iso_currency_code}, unofficial_currency_code: #{@unofficial_currency_code}, category:"\ " #{@category}, category_id: #{@category_id}, check_number: #{@check_number}, date:"\ " #{@date}, location: #{@location}, name: #{@name}, merchant_name: #{@merchant_name},"\ " original_description: #{@original_description}, payment_meta: #{@payment_meta}, pending:"\ " #{@pending}, pending_transaction_id: #{@pending_transaction_id}, account_owner:"\ " #{@account_owner}, transaction_id: #{@transaction_id}, transaction_type:"\ " #{@transaction_type}, logo_url: #{@logo_url}, website: #{@website}, additional_properties:"\ " #{@additional_properties}>" end |