Class: ThePlaidApi::TransactionOverride
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ThePlaidApi::TransactionOverride
- Defined in:
- lib/the_plaid_api/models/transaction_override.rb
Overview
Data to populate as test transaction data. If not specified, random transactions will be generated instead.
Instance Attribute Summary collapse
-
#amount ⇒ Float
The transaction amount.
-
#currency ⇒ String
The ISO-4217 format currency code for the transaction.
-
#date_posted ⇒ Date
The date the transaction posted, in [ISO 8601](wikipedia.org/wiki/ISO_8601) (YYYY-MM-DD) format.
-
#date_transacted ⇒ Date
The date of the transaction, in [ISO 8601](wikipedia.org/wiki/ISO_8601) (YYYY-MM-DD) format.
-
#description ⇒ String
The transaction description.
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(date_transacted:, date_posted:, amount:, description:, currency: SKIP, additional_properties: nil) ⇒ TransactionOverride
constructor
A new instance of TransactionOverride.
-
#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(date_transacted:, date_posted:, amount:, description:, currency: SKIP, additional_properties: nil) ⇒ TransactionOverride
Returns a new instance of TransactionOverride.
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/the_plaid_api/models/transaction_override.rb', line 65 def initialize(date_transacted:, date_posted:, amount:, description:, currency: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @date_transacted = date_transacted @date_posted = date_posted @amount = amount @description = description @currency = currency unless currency == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#amount ⇒ Float
The transaction amount. Can be negative.
32 33 34 |
# File 'lib/the_plaid_api/models/transaction_override.rb', line 32 def amount @amount end |
#currency ⇒ String
The ISO-4217 format currency code for the transaction.
40 41 42 |
# File 'lib/the_plaid_api/models/transaction_override.rb', line 40 def currency @currency end |
#date_posted ⇒ Date
The date the transaction posted, in [ISO 8601](wikipedia.org/wiki/ISO_8601) (YYYY-MM-DD) format. Posted dates in the past or present will result in posted transactions; posted dates in the future will result in pending transactions.
28 29 30 |
# File 'lib/the_plaid_api/models/transaction_override.rb', line 28 def date_posted @date_posted end |
#date_transacted ⇒ Date
The date of the transaction, in [ISO 8601](wikipedia.org/wiki/ISO_8601) (YYYY-MM-DD) format. Transactions in Sandbox will move from pending to posted once their transaction date has been reached. If a ‘date_transacted` is not provided by the institution, a transaction date may be available in the [`authorized_date`](plaid.com/docs/api/products/transactions/#tran sactions-get-response-transactions-authorized-date) field.
21 22 23 |
# File 'lib/the_plaid_api/models/transaction_override.rb', line 21 def date_transacted @date_transacted end |
#description ⇒ String
The transaction description.
36 37 38 |
# File 'lib/the_plaid_api/models/transaction_override.rb', line 36 def description @description end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/the_plaid_api/models/transaction_override.rb', line 79 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. date_transacted = hash.key?('date_transacted') ? hash['date_transacted'] : nil date_posted = hash.key?('date_posted') ? hash['date_posted'] : nil amount = hash.key?('amount') ? hash['amount'] : nil description = hash.key?('description') ? hash['description'] : nil currency = hash.key?('currency') ? hash['currency'] : 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. TransactionOverride.new(date_transacted: date_transacted, date_posted: date_posted, amount: amount, description: description, currency: currency, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
43 44 45 46 47 48 49 50 51 |
# File 'lib/the_plaid_api/models/transaction_override.rb', line 43 def self.names @_hash = {} if @_hash.nil? @_hash['date_transacted'] = 'date_transacted' @_hash['date_posted'] = 'date_posted' @_hash['amount'] = 'amount' @_hash['description'] = 'description' @_hash['currency'] = 'currency' @_hash end |
.nullables ⇒ Object
An array for nullable fields
61 62 63 |
# File 'lib/the_plaid_api/models/transaction_override.rb', line 61 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
54 55 56 57 58 |
# File 'lib/the_plaid_api/models/transaction_override.rb', line 54 def self.optionals %w[ currency ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
115 116 117 118 119 120 |
# File 'lib/the_plaid_api/models/transaction_override.rb', line 115 def inspect class_name = self.class.name.split('::').last "<#{class_name} date_transacted: #{@date_transacted.inspect}, date_posted:"\ " #{@date_posted.inspect}, amount: #{@amount.inspect}, description: #{@description.inspect},"\ " currency: #{@currency.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
107 108 109 110 111 112 |
# File 'lib/the_plaid_api/models/transaction_override.rb', line 107 def to_s class_name = self.class.name.split('::').last "<#{class_name} date_transacted: #{@date_transacted}, date_posted: #{@date_posted}, amount:"\ " #{@amount}, description: #{@description}, currency: #{@currency}, additional_properties:"\ " #{@additional_properties}>" end |