Class: ThePlaidApi::CustomSandboxTransaction

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/the_plaid_api/models/custom_sandbox_transaction.rb

Overview

Data to populate as test transaction data.

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:, iso_currency_code: SKIP, additional_properties: nil) ⇒ CustomSandboxTransaction

Returns a new instance of CustomSandboxTransaction.



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/the_plaid_api/models/custom_sandbox_transaction.rb', line 61

def initialize(date_transacted:, date_posted:, amount:, description:,
               iso_currency_code: 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
  @iso_currency_code = iso_currency_code unless iso_currency_code == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountFloat

The transaction amount. Can be negative.

Returns:

  • (Float)


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

def amount
  @amount
end

#date_postedDate

The date the transaction posted, in [ISO 8601](wikipedia.org/wiki/ISO_8601) (YYYY-MM-DD) format. Posted date must be the present date or a date up to 14 days in the past. Future dates are not allowed.

Returns:

  • (Date)


24
25
26
# File 'lib/the_plaid_api/models/custom_sandbox_transaction.rb', line 24

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 date must be the present date or a date up to 14 days in the past. Future dates are not allowed.

Returns:

  • (Date)


17
18
19
# File 'lib/the_plaid_api/models/custom_sandbox_transaction.rb', line 17

def date_transacted
  @date_transacted
end

#descriptionString

The transaction description.

Returns:

  • (String)


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

def description
  @description
end

#iso_currency_codeString

The ISO-4217 format currency code for the transaction. Defaults to USD.

Returns:

  • (String)


36
37
38
# File 'lib/the_plaid_api/models/custom_sandbox_transaction.rb', line 36

def iso_currency_code
  @iso_currency_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



75
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/the_plaid_api/models/custom_sandbox_transaction.rb', line 75

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
  iso_currency_code =
    hash.key?('iso_currency_code') ? hash['iso_currency_code'] : 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.
  CustomSandboxTransaction.new(date_transacted: date_transacted,
                               date_posted: date_posted,
                               amount: amount,
                               description: description,
                               iso_currency_code: iso_currency_code,
                               additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



39
40
41
42
43
44
45
46
47
# File 'lib/the_plaid_api/models/custom_sandbox_transaction.rb', line 39

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['date_transacted'] = 'date_transacted'
  @_hash['date_posted'] = 'date_posted'
  @_hash['amount'] = 'amount'
  @_hash['description'] = 'description'
  @_hash['iso_currency_code'] = 'iso_currency_code'
  @_hash
end

.nullablesObject

An array for nullable fields



57
58
59
# File 'lib/the_plaid_api/models/custom_sandbox_transaction.rb', line 57

def self.nullables
  []
end

.optionalsObject

An array for optional fields



50
51
52
53
54
# File 'lib/the_plaid_api/models/custom_sandbox_transaction.rb', line 50

def self.optionals
  %w[
    iso_currency_code
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



112
113
114
115
116
117
118
# File 'lib/the_plaid_api/models/custom_sandbox_transaction.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},"\
  " iso_currency_code: #{@iso_currency_code.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/the_plaid_api/models/custom_sandbox_transaction.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}, iso_currency_code: #{@iso_currency_code},"\
  " additional_properties: #{@additional_properties}>"
end