Class: ThePlaidApi::ClientProvidedEnhancedTransaction

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

Overview

A client-provided transaction that Plaid has enhanced.

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(id:, description:, amount:, iso_currency_code:, enhancements:, additional_properties: nil) ⇒ ClientProvidedEnhancedTransaction

Returns a new instance of ClientProvidedEnhancedTransaction.



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/the_plaid_api/models/client_provided_enhanced_transaction.rb', line 58

def initialize(id:, description:, amount:, iso_currency_code:,
               enhancements:, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @id = id
  @description = description
  @amount = amount
  @iso_currency_code = iso_currency_code
  @enhancements = enhancements
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountFloat

The value of the transaction, denominated in the account’s currency, as stated in ‘iso_currency_code`. 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.

Returns:

  • (Float)


27
28
29
# File 'lib/the_plaid_api/models/client_provided_enhanced_transaction.rb', line 27

def amount
  @amount
end

#descriptionString

The raw description of the transaction.

Returns:

  • (String)


19
20
21
# File 'lib/the_plaid_api/models/client_provided_enhanced_transaction.rb', line 19

def description
  @description
end

#enhancementsEnhancements

A grouping of the Plaid produced transaction enhancement fields.

Returns:



35
36
37
# File 'lib/the_plaid_api/models/client_provided_enhanced_transaction.rb', line 35

def enhancements
  @enhancements
end

#idString

Unique transaction identifier to tie transactions back to clients’ systems.

Returns:

  • (String)


15
16
17
# File 'lib/the_plaid_api/models/client_provided_enhanced_transaction.rb', line 15

def id
  @id
end

#iso_currency_codeString

The ISO-4217 currency code of the transaction.

Returns:

  • (String)


31
32
33
# File 'lib/the_plaid_api/models/client_provided_enhanced_transaction.rb', line 31

def iso_currency_code
  @iso_currency_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/the_plaid_api/models/client_provided_enhanced_transaction.rb', line 72

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  description = hash.key?('description') ? hash['description'] : nil
  amount = hash.key?('amount') ? hash['amount'] : nil
  iso_currency_code =
    hash.key?('iso_currency_code') ? hash['iso_currency_code'] : nil
  enhancements = Enhancements.from_hash(hash['enhancements']) if hash['enhancements']

  # 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.
  ClientProvidedEnhancedTransaction.new(id: id,
                                        description: description,
                                        amount: amount,
                                        iso_currency_code: iso_currency_code,
                                        enhancements: enhancements,
                                        additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

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

.nullablesObject

An array for nullable fields



54
55
56
# File 'lib/the_plaid_api/models/client_provided_enhanced_transaction.rb', line 54

def self.nullables
  []
end

.optionalsObject

An array for optional fields



49
50
51
# File 'lib/the_plaid_api/models/client_provided_enhanced_transaction.rb', line 49

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



108
109
110
111
112
113
# File 'lib/the_plaid_api/models/client_provided_enhanced_transaction.rb', line 108

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, description: #{@description.inspect}, amount:"\
  " #{@amount.inspect}, iso_currency_code: #{@iso_currency_code.inspect}, enhancements:"\
  " #{@enhancements.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



100
101
102
103
104
105
# File 'lib/the_plaid_api/models/client_provided_enhanced_transaction.rb', line 100

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, description: #{@description}, amount: #{@amount},"\
  " iso_currency_code: #{@iso_currency_code}, enhancements: #{@enhancements},"\
  " additional_properties: #{@additional_properties}>"
end