Class: Plaid::TransactionOverride

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/plaid/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.



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/plaid/models/transaction_override.rb', line 62

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)


29
30
31
# File 'lib/plaid/models/transaction_override.rb', line 29

def amount
  @amount
end

#currencyString

The ISO-4217 format currency code for the transaction.

Returns:

  • (String)


37
38
39
# File 'lib/plaid/models/transaction_override.rb', line 37

def currency
  @currency
end

#date_postedDate

The date the transaction posted, in [ISO 8601](wikipedia.org/wiki/ISO_8601) (YYYY-MM-DD) format

Returns:

  • (Date)


25
26
27
# File 'lib/plaid/models/transaction_override.rb', line 25

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. Transaction dates in the past or present will result in posted transactions; transaction dates in the future will result in pending transactions. Transactions in Sandbox will move from pending to posted once their transaction date has been reached.

Returns:

  • (Date)


20
21
22
# File 'lib/plaid/models/transaction_override.rb', line 20

def date_transacted
  @date_transacted
end

#descriptionString

The transaction description.

Returns:

  • (String)


33
34
35
# File 'lib/plaid/models/transaction_override.rb', line 33

def description
  @description
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/plaid/models/transaction_override.rb', line 76

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.



40
41
42
43
44
45
46
47
48
# File 'lib/plaid/models/transaction_override.rb', line 40

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



58
59
60
# File 'lib/plaid/models/transaction_override.rb', line 58

def self.nullables
  []
end

.optionalsObject

An array for optional fields



51
52
53
54
55
# File 'lib/plaid/models/transaction_override.rb', line 51

def self.optionals
  %w[
    currency
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



112
113
114
115
116
117
# File 'lib/plaid/models/transaction_override.rb', line 112

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.



104
105
106
107
108
109
# File 'lib/plaid/models/transaction_override.rb', line 104

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