Class: ThePlaidApi::TransactionOverride

Inherits:
BaseModel
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#amountFloat

The transaction amount. Can be negative.

Returns:

  • (Float)


32
33
34
# File 'lib/the_plaid_api/models/transaction_override.rb', line 32

def amount
  @amount
end

#currencyString

The ISO-4217 format currency code for the transaction.

Returns:

  • (String)


40
41
42
# File 'lib/the_plaid_api/models/transaction_override.rb', line 40

def currency
  @currency
end

#date_postedDate

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.

Returns:

  • (Date)


28
29
30
# File 'lib/the_plaid_api/models/transaction_override.rb', line 28

def date_posted
  @date_posted
end

#date_transactedDate

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.

Returns:

  • (Date)


21
22
23
# File 'lib/the_plaid_api/models/transaction_override.rb', line 21

def date_transacted
  @date_transacted
end

#descriptionString

The transaction description.

Returns:

  • (String)


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

.namesObject

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

.nullablesObject

An array for nullable fields



61
62
63
# File 'lib/the_plaid_api/models/transaction_override.rb', line 61

def self.nullables
  []
end

.optionalsObject

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

#inspectObject

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_sObject

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