Class: ThePlaidApi::CraIncomeTransaction

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

Overview

The transaction data for an income stream.

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(transaction_id:, item_id:, account_id:, amount:, date:, original_description:, iso_currency_code:, unofficial_currency_code:, outlier:, additional_properties: nil) ⇒ CraIncomeTransaction

Returns a new instance of CraIncomeTransaction.



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/the_plaid_api/models/cra_income_transaction.rb', line 97

def initialize(transaction_id:, item_id:, account_id:, amount:, date:,
               original_description:, iso_currency_code:,
               unofficial_currency_code:, outlier:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @transaction_id = transaction_id
  @item_id = item_id
  @account_id = 
  @amount = amount
  @date = date
  @original_description = original_description
  @iso_currency_code = iso_currency_code
  @unofficial_currency_code = unofficial_currency_code
  @outlier = outlier
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_idString

Plaid’s unique identifier for the account. This value will not change unless Plaid can’t reconcile the account with the data returned by the financial institution. This may occur, for example, when the name of the account changes. If this happens a new ‘account_id` will be assigned to the account. If an account with a specific `account_id` disappears instead of changing, the account is likely closed. Closed accounts are not returned by the Plaid API. Like all Plaid identifiers, the `account_id` is case sensitive.

Returns:

  • (String)


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

def 
  @account_id
end

#amountFloat

The settled value of the transaction, denominated in the transaction’s currency as stated in ‘iso_currency_code` or `unofficial_currency_code`. Positive values when money moves out of the account; negative values when money moves in. For example, credit card purchases are positive; credit card payment, direct deposits, and refunds are negative.

Returns:

  • (Float)


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

def amount
  @amount
end

#dateDate

For pending transactions, the date that the transaction occurred; for posted transactions, the date that the transaction posted. Both dates are returned in an ISO 8601 format (YYYY-MM-DD).

Returns:

  • (Date)


46
47
48
# File 'lib/the_plaid_api/models/cra_income_transaction.rb', line 46

def date
  @date
end

#iso_currency_codeString

The ISO 4217 currency code of the amount or balance.

Returns:

  • (String)


55
56
57
# File 'lib/the_plaid_api/models/cra_income_transaction.rb', line 55

def iso_currency_code
  @iso_currency_code
end

#item_idString

The ‘item_id` of the Item associated with this webhook, warning, or error

Returns:

  • (String)


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

def item_id
  @item_id
end

#original_descriptionString

The string returned by the financial institution to describe the transaction.

Returns:

  • (String)


51
52
53
# File 'lib/the_plaid_api/models/cra_income_transaction.rb', line 51

def original_description
  @original_description
end

#outlierCraIncomeTransactionOutlier

Metadata on whether this income transaction is an outlier.



67
68
69
# File 'lib/the_plaid_api/models/cra_income_transaction.rb', line 67

def outlier
  @outlier
end

#transaction_idString

The unique ID of the transaction. Like all Plaid identifiers, the ‘transaction_id` is case sensitive.

Returns:

  • (String)


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

def transaction_id
  @transaction_id
end

#unofficial_currency_codeString

The unofficial currency code associated with the amount or balance. Always ‘null` if `iso_currency_code` is non-null. Unofficial currency codes are used for currencies that do not have official ISO currency codes, such as cryptocurrencies and the currencies of certain countries.

Returns:

  • (String)


63
64
65
# File 'lib/the_plaid_api/models/cra_income_transaction.rb', line 63

def unofficial_currency_code
  @unofficial_currency_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/the_plaid_api/models/cra_income_transaction.rb', line 117

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  transaction_id =
    hash.key?('transaction_id') ? hash['transaction_id'] : nil
  item_id = hash.key?('item_id') ? hash['item_id'] : nil
   = hash.key?('account_id') ? hash['account_id'] : nil
  amount = hash.key?('amount') ? hash['amount'] : nil
  date = hash.key?('date') ? hash['date'] : nil
  original_description =
    hash.key?('original_description') ? hash['original_description'] : nil
  iso_currency_code =
    hash.key?('iso_currency_code') ? hash['iso_currency_code'] : nil
  unofficial_currency_code =
    hash.key?('unofficial_currency_code') ? hash['unofficial_currency_code'] : nil
  outlier = CraIncomeTransactionOutlier.from_hash(hash['outlier']) if hash['outlier']

  # 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.
  CraIncomeTransaction.new(transaction_id: transaction_id,
                           item_id: item_id,
                           account_id: ,
                           amount: amount,
                           date: date,
                           original_description: original_description,
                           iso_currency_code: iso_currency_code,
                           unofficial_currency_code: unofficial_currency_code,
                           outlier: outlier,
                           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/the_plaid_api/models/cra_income_transaction.rb', line 70

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['transaction_id'] = 'transaction_id'
  @_hash['item_id'] = 'item_id'
  @_hash['account_id'] = 'account_id'
  @_hash['amount'] = 'amount'
  @_hash['date'] = 'date'
  @_hash['original_description'] = 'original_description'
  @_hash['iso_currency_code'] = 'iso_currency_code'
  @_hash['unofficial_currency_code'] = 'unofficial_currency_code'
  @_hash['outlier'] = 'outlier'
  @_hash
end

.nullablesObject

An array for nullable fields



90
91
92
93
94
95
# File 'lib/the_plaid_api/models/cra_income_transaction.rb', line 90

def self.nullables
  %w[
    iso_currency_code
    unofficial_currency_code
  ]
end

.optionalsObject

An array for optional fields



85
86
87
# File 'lib/the_plaid_api/models/cra_income_transaction.rb', line 85

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



166
167
168
169
170
171
172
173
174
# File 'lib/the_plaid_api/models/cra_income_transaction.rb', line 166

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} transaction_id: #{@transaction_id.inspect}, item_id: #{@item_id.inspect},"\
  " account_id: #{@account_id.inspect}, amount: #{@amount.inspect}, date: #{@date.inspect},"\
  " original_description: #{@original_description.inspect}, iso_currency_code:"\
  " #{@iso_currency_code.inspect}, unofficial_currency_code:"\
  " #{@unofficial_currency_code.inspect}, outlier: #{@outlier.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



156
157
158
159
160
161
162
163
# File 'lib/the_plaid_api/models/cra_income_transaction.rb', line 156

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} transaction_id: #{@transaction_id}, item_id: #{@item_id}, account_id:"\
  " #{@account_id}, amount: #{@amount}, date: #{@date}, original_description:"\
  " #{@original_description}, iso_currency_code: #{@iso_currency_code},"\
  " unofficial_currency_code: #{@unofficial_currency_code}, outlier: #{@outlier},"\
  " additional_properties: #{@additional_properties}>"
end