Class: ThePlaidApi::CreditBankIncomeSummary

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

Overview

Summary for bank income across all income sources and items (max history of 730 days).

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(total_amount: SKIP, iso_currency_code: SKIP, unofficial_currency_code: SKIP, total_amounts: SKIP, start_date: SKIP, end_date: SKIP, income_sources_count: SKIP, income_categories_count: SKIP, income_transactions_count: SKIP, historical_summary: SKIP, additional_properties: nil) ⇒ CreditBankIncomeSummary

Returns a new instance of CreditBankIncomeSummary.



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/the_plaid_api/models/credit_bank_income_summary.rb', line 119

def initialize(total_amount: SKIP, iso_currency_code: SKIP,
               unofficial_currency_code: SKIP, total_amounts: SKIP,
               start_date: SKIP, end_date: SKIP, income_sources_count: SKIP,
               income_categories_count: SKIP,
               income_transactions_count: SKIP, historical_summary: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @total_amount = total_amount unless total_amount == SKIP
  @iso_currency_code = iso_currency_code unless iso_currency_code == SKIP
  @unofficial_currency_code = unofficial_currency_code unless unofficial_currency_code == SKIP
  @total_amounts = total_amounts unless total_amounts == SKIP
  @start_date = start_date unless start_date == SKIP
  @end_date = end_date unless end_date == SKIP
  @income_sources_count = income_sources_count unless income_sources_count == SKIP
  @income_categories_count = income_categories_count unless income_categories_count == SKIP
  unless income_transactions_count == SKIP
    @income_transactions_count =
      income_transactions_count
  end
  @historical_summary = historical_summary unless historical_summary == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#end_dateDate

The latest date in which all income sources identified by Plaid appear in the user’s account. The date will be returned in an ISO 8601 format (YYYY-MM-DD).

Returns:

  • (Date)


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

def end_date
  @end_date
end

#historical_summaryArray[CreditBankIncomeHistoricalSummary]

Number of income transactions per end user.



77
78
79
# File 'lib/the_plaid_api/models/credit_bank_income_summary.rb', line 77

def historical_summary
  @historical_summary
end

#income_categories_countInteger

Number of income categories per end user.

Returns:

  • (Integer)


69
70
71
# File 'lib/the_plaid_api/models/credit_bank_income_summary.rb', line 69

def income_categories_count
  @income_categories_count
end

#income_sources_countInteger

Number of income sources per end user.

Returns:

  • (Integer)


65
66
67
# File 'lib/the_plaid_api/models/credit_bank_income_summary.rb', line 65

def income_sources_count
  @income_sources_count
end

#income_transactions_countInteger

Number of income transactions per end user.

Returns:

  • (Integer)


73
74
75
# File 'lib/the_plaid_api/models/credit_bank_income_summary.rb', line 73

def income_transactions_count
  @income_transactions_count
end

#iso_currency_codeString

The ISO 4217 currency code of the amount or balance. Please use [‘total_amounts`](plaid.com/docs/api/products/income/#credit-bank_ income-get-response-bank-income-bank-income-summary-total-amounts) instead.

Returns:

  • (String)


30
31
32
# File 'lib/the_plaid_api/models/credit_bank_income_summary.rb', line 30

def iso_currency_code
  @iso_currency_code
end

#start_dateDate

The earliest date within the days requested in which all income sources identified by Plaid appear in a user’s account. The date will be returned in an ISO 8601 format (YYYY-MM-DD).

Returns:

  • (Date)


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

def start_date
  @start_date
end

#total_amountFloat

Total amount of earnings across all the income sources in the end user’s Items for the days requested by the client. This may return an incorrect value if the summary includes income sources in multiple currencies. Please use [‘total_amounts`](plaid.com/docs/api/products/income/#credit-bank_ income-get-response-bank-income-bank-income-summary-total-amounts) instead.

Returns:

  • (Float)


22
23
24
# File 'lib/the_plaid_api/models/credit_bank_income_summary.rb', line 22

def total_amount
  @total_amount
end

#total_amountsArray[CreditAmountWithCurrency]

Total amount of earnings across all the income sources in the end user’s Items for the days requested by the client. This can contain multiple amounts, with each amount denominated in one unique currency.

Returns:



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

def total_amounts
  @total_amounts
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. Please use [`total_amounts`](plaid.com/docs/api/products/income/#credit-bank_ income-get-response-bank-income-bank-income-summary-total-amounts) instead.

Returns:

  • (String)


42
43
44
# File 'lib/the_plaid_api/models/credit_bank_income_summary.rb', line 42

def unofficial_currency_code
  @unofficial_currency_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/the_plaid_api/models/credit_bank_income_summary.rb', line 145

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  total_amount = hash.key?('total_amount') ? hash['total_amount'] : SKIP
  iso_currency_code =
    hash.key?('iso_currency_code') ? hash['iso_currency_code'] : SKIP
  unofficial_currency_code =
    hash.key?('unofficial_currency_code') ? hash['unofficial_currency_code'] : SKIP
  # Parameter is an array, so we need to iterate through it
  total_amounts = nil
  unless hash['total_amounts'].nil?
    total_amounts = []
    hash['total_amounts'].each do |structure|
      total_amounts << (CreditAmountWithCurrency.from_hash(structure) if structure)
    end
  end

  total_amounts = SKIP unless hash.key?('total_amounts')
  start_date = hash.key?('start_date') ? hash['start_date'] : SKIP
  end_date = hash.key?('end_date') ? hash['end_date'] : SKIP
  income_sources_count =
    hash.key?('income_sources_count') ? hash['income_sources_count'] : SKIP
  income_categories_count =
    hash.key?('income_categories_count') ? hash['income_categories_count'] : SKIP
  income_transactions_count =
    hash.key?('income_transactions_count') ? hash['income_transactions_count'] : SKIP
  # Parameter is an array, so we need to iterate through it
  historical_summary = nil
  unless hash['historical_summary'].nil?
    historical_summary = []
    hash['historical_summary'].each do |structure|
      historical_summary << (CreditBankIncomeHistoricalSummary.from_hash(structure) if structure)
    end
  end

  historical_summary = SKIP unless hash.key?('historical_summary')

  # 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.
  CreditBankIncomeSummary.new(total_amount: total_amount,
                              iso_currency_code: iso_currency_code,
                              unofficial_currency_code: unofficial_currency_code,
                              total_amounts: total_amounts,
                              start_date: start_date,
                              end_date: end_date,
                              income_sources_count: income_sources_count,
                              income_categories_count: income_categories_count,
                              income_transactions_count: income_transactions_count,
                              historical_summary: historical_summary,
                              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/the_plaid_api/models/credit_bank_income_summary.rb', line 80

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['total_amount'] = 'total_amount'
  @_hash['iso_currency_code'] = 'iso_currency_code'
  @_hash['unofficial_currency_code'] = 'unofficial_currency_code'
  @_hash['total_amounts'] = 'total_amounts'
  @_hash['start_date'] = 'start_date'
  @_hash['end_date'] = 'end_date'
  @_hash['income_sources_count'] = 'income_sources_count'
  @_hash['income_categories_count'] = 'income_categories_count'
  @_hash['income_transactions_count'] = 'income_transactions_count'
  @_hash['historical_summary'] = 'historical_summary'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  %w[
    iso_currency_code
    unofficial_currency_code
  ]
end

.optionalsObject

An array for optional fields



96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/the_plaid_api/models/credit_bank_income_summary.rb', line 96

def self.optionals
  %w[
    total_amount
    iso_currency_code
    unofficial_currency_code
    total_amounts
    start_date
    end_date
    income_sources_count
    income_categories_count
    income_transactions_count
    historical_summary
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



216
217
218
219
220
221
222
223
224
225
226
# File 'lib/the_plaid_api/models/credit_bank_income_summary.rb', line 216

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} total_amount: #{@total_amount.inspect}, iso_currency_code:"\
  " #{@iso_currency_code.inspect}, unofficial_currency_code:"\
  " #{@unofficial_currency_code.inspect}, total_amounts: #{@total_amounts.inspect},"\
  " start_date: #{@start_date.inspect}, end_date: #{@end_date.inspect}, income_sources_count:"\
  " #{@income_sources_count.inspect}, income_categories_count:"\
  " #{@income_categories_count.inspect}, income_transactions_count:"\
  " #{@income_transactions_count.inspect}, historical_summary: #{@historical_summary.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



205
206
207
208
209
210
211
212
213
# File 'lib/the_plaid_api/models/credit_bank_income_summary.rb', line 205

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} total_amount: #{@total_amount}, iso_currency_code: #{@iso_currency_code},"\
  " unofficial_currency_code: #{@unofficial_currency_code}, total_amounts: #{@total_amounts},"\
  " start_date: #{@start_date}, end_date: #{@end_date}, income_sources_count:"\
  " #{@income_sources_count}, income_categories_count: #{@income_categories_count},"\
  " income_transactions_count: #{@income_transactions_count}, historical_summary:"\
  " #{@historical_summary}, additional_properties: #{@additional_properties}>"
end