Class: ThePlaidApi::CraBankIncomeSummary

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

Overview

This is a V1 (II1) schema. For the V2 (II2) equivalent, use ‘CraIncomeInsightsUserSummary`. Summary for 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_amounts: SKIP, start_date: SKIP, end_date: SKIP, income_sources_count: SKIP, income_categories_count: SKIP, income_transactions_count: SKIP, historical_average_monthly_gross_income: SKIP, historical_average_monthly_income: SKIP, forecasted_average_monthly_income: SKIP, historical_annual_gross_income: SKIP, historical_annual_income: SKIP, forecasted_annual_income: SKIP, historical_summary: SKIP, additional_properties: nil) ⇒ CraBankIncomeSummary

Returns a new instance of CraBankIncomeSummary.



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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/the_plaid_api/models/cra_bank_income_summary.rb', line 129

def initialize(total_amounts: SKIP, start_date: SKIP, end_date: SKIP,
               income_sources_count: SKIP, income_categories_count: SKIP,
               income_transactions_count: SKIP,
               historical_average_monthly_gross_income: SKIP,
               historical_average_monthly_income: SKIP,
               forecasted_average_monthly_income: SKIP,
               historical_annual_gross_income: SKIP,
               historical_annual_income: SKIP,
               forecasted_annual_income: SKIP, historical_summary: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @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
  unless historical_average_monthly_gross_income == SKIP
    @historical_average_monthly_gross_income =
      historical_average_monthly_gross_income
  end
  unless historical_average_monthly_income == SKIP
    @historical_average_monthly_income =
      historical_average_monthly_income
  end
  unless forecasted_average_monthly_income == SKIP
    @forecasted_average_monthly_income =
      forecasted_average_monthly_income
  end
  unless historical_annual_gross_income == SKIP
    @historical_annual_gross_income =
      historical_annual_gross_income
  end
  @historical_annual_income = historical_annual_income unless historical_annual_income == SKIP
  @forecasted_annual_income = forecasted_annual_income unless forecasted_annual_income == SKIP
  @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)


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

def end_date
  @end_date
end

#forecasted_annual_incomeArray[CreditAmountWithCurrency]

The predicted average annual income amount for the income source(s).

Returns:



76
77
78
# File 'lib/the_plaid_api/models/cra_bank_income_summary.rb', line 76

def forecasted_annual_income
  @forecasted_annual_income
end

#forecasted_average_monthly_incomeArray[CreditAmountWithCurrency]

The predicted average monthly income amount for the income source(s).

Returns:



62
63
64
# File 'lib/the_plaid_api/models/cra_bank_income_summary.rb', line 62

def forecasted_average_monthly_income
  @forecasted_average_monthly_income
end

#historical_annual_gross_incomeArray[CreditAmountWithCurrency]

An estimate of the annual gross income for the income source, calculated by multiplying the ‘historical_average_monthly_gross_income` by 12.

Returns:



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

def historical_annual_gross_income
  @historical_annual_gross_income
end

#historical_annual_incomeArray[CreditAmountWithCurrency]

An estimate of the annual net income for the income source, calculated by multiplying the ‘historical_average_monthly_income` by 12.

Returns:



72
73
74
# File 'lib/the_plaid_api/models/cra_bank_income_summary.rb', line 72

def historical_annual_income
  @historical_annual_income
end

#historical_average_monthly_gross_incomeArray[CreditAmountWithCurrency]

An estimate of the average gross monthly income based on the historical net amount and income category for the income source(s). The average monthly income is calculated based on the lifetime of the income stream, rather than the entire historical period included in the scope of the report.

Returns:



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

def historical_average_monthly_gross_income
  @historical_average_monthly_gross_income
end

#historical_average_monthly_incomeArray[CreditAmountWithCurrency]

The average monthly income amount estimated based on the historical data for the income source(s). The average monthly income is calculated based on the lifetime of the income stream, rather than the entire historical period included in the scope of the report.

Returns:



58
59
60
# File 'lib/the_plaid_api/models/cra_bank_income_summary.rb', line 58

def historical_average_monthly_income
  @historical_average_monthly_income
end

#historical_summaryArray[CraBankIncomeHistoricalSummary]

The predicted average annual income amount for the income source(s).

Returns:



80
81
82
# File 'lib/the_plaid_api/models/cra_bank_income_summary.rb', line 80

def historical_summary
  @historical_summary
end

#income_categories_countInteger

Number of income categories per end user.

Returns:

  • (Integer)


39
40
41
# File 'lib/the_plaid_api/models/cra_bank_income_summary.rb', line 39

def income_categories_count
  @income_categories_count
end

#income_sources_countInteger

Number of income sources per end user.

Returns:

  • (Integer)


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

def income_sources_count
  @income_sources_count
end

#income_transactions_countInteger

Number of income transactions per end user.

Returns:

  • (Integer)


43
44
45
# File 'lib/the_plaid_api/models/cra_bank_income_summary.rb', line 43

def income_transactions_count
  @income_transactions_count
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)


25
26
27
# File 'lib/the_plaid_api/models/cra_bank_income_summary.rb', line 25

def start_date
  @start_date
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:



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

def total_amounts
  @total_amounts
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/the_plaid_api/models/cra_bank_income_summary.rb', line 174

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  # 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_average_monthly_gross_income = nil
  unless hash['historical_average_monthly_gross_income'].nil?
    historical_average_monthly_gross_income = []
    hash['historical_average_monthly_gross_income'].each do |structure|
      historical_average_monthly_gross_income << (CreditAmountWithCurrency.from_hash(structure) if structure)
    end
  end

  historical_average_monthly_gross_income = SKIP unless hash.key?('historical_average_monthly_gross_income')
  # Parameter is an array, so we need to iterate through it
  historical_average_monthly_income = nil
  unless hash['historical_average_monthly_income'].nil?
    historical_average_monthly_income = []
    hash['historical_average_monthly_income'].each do |structure|
      historical_average_monthly_income << (CreditAmountWithCurrency.from_hash(structure) if structure)
    end
  end

  historical_average_monthly_income = SKIP unless hash.key?('historical_average_monthly_income')
  # Parameter is an array, so we need to iterate through it
  forecasted_average_monthly_income = nil
  unless hash['forecasted_average_monthly_income'].nil?
    forecasted_average_monthly_income = []
    hash['forecasted_average_monthly_income'].each do |structure|
      forecasted_average_monthly_income << (CreditAmountWithCurrency.from_hash(structure) if structure)
    end
  end

  forecasted_average_monthly_income = SKIP unless hash.key?('forecasted_average_monthly_income')
  # Parameter is an array, so we need to iterate through it
  historical_annual_gross_income = nil
  unless hash['historical_annual_gross_income'].nil?
    historical_annual_gross_income = []
    hash['historical_annual_gross_income'].each do |structure|
      historical_annual_gross_income << (CreditAmountWithCurrency.from_hash(structure) if structure)
    end
  end

  historical_annual_gross_income = SKIP unless hash.key?('historical_annual_gross_income')
  # Parameter is an array, so we need to iterate through it
  historical_annual_income = nil
  unless hash['historical_annual_income'].nil?
    historical_annual_income = []
    hash['historical_annual_income'].each do |structure|
      historical_annual_income << (CreditAmountWithCurrency.from_hash(structure) if structure)
    end
  end

  historical_annual_income = SKIP unless hash.key?('historical_annual_income')
  # Parameter is an array, so we need to iterate through it
  forecasted_annual_income = nil
  unless hash['forecasted_annual_income'].nil?
    forecasted_annual_income = []
    hash['forecasted_annual_income'].each do |structure|
      forecasted_annual_income << (CreditAmountWithCurrency.from_hash(structure) if structure)
    end
  end

  forecasted_annual_income = SKIP unless hash.key?('forecasted_annual_income')
  # 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 << (CraBankIncomeHistoricalSummary.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.
  CraBankIncomeSummary.new(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_average_monthly_gross_income: historical_average_monthly_gross_income,
                           historical_average_monthly_income: historical_average_monthly_income,
                           forecasted_average_monthly_income: forecasted_average_monthly_income,
                           historical_annual_gross_income: historical_annual_gross_income,
                           historical_annual_income: historical_annual_income,
                           forecasted_annual_income: forecasted_annual_income,
                           historical_summary: historical_summary,
                           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/the_plaid_api/models/cra_bank_income_summary.rb', line 83

def self.names
  @_hash = {} if @_hash.nil?
  @_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_average_monthly_gross_income'] =
    'historical_average_monthly_gross_income'
  @_hash['historical_average_monthly_income'] =
    'historical_average_monthly_income'
  @_hash['forecasted_average_monthly_income'] =
    'forecasted_average_monthly_income'
  @_hash['historical_annual_gross_income'] =
    'historical_annual_gross_income'
  @_hash['historical_annual_income'] = 'historical_annual_income'
  @_hash['forecasted_annual_income'] = 'forecasted_annual_income'
  @_hash['historical_summary'] = 'historical_summary'
  @_hash
end

.nullablesObject

An array for nullable fields



125
126
127
# File 'lib/the_plaid_api/models/cra_bank_income_summary.rb', line 125

def self.nullables
  []
end

.optionalsObject

An array for optional fields



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/the_plaid_api/models/cra_bank_income_summary.rb', line 106

def self.optionals
  %w[
    total_amounts
    start_date
    end_date
    income_sources_count
    income_categories_count
    income_transactions_count
    historical_average_monthly_gross_income
    historical_average_monthly_income
    forecasted_average_monthly_income
    historical_annual_gross_income
    historical_annual_income
    forecasted_annual_income
    historical_summary
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/the_plaid_api/models/cra_bank_income_summary.rb', line 307

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} 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_average_monthly_gross_income:"\
  " #{@historical_average_monthly_gross_income.inspect}, historical_average_monthly_income:"\
  " #{@historical_average_monthly_income.inspect}, forecasted_average_monthly_income:"\
  " #{@forecasted_average_monthly_income.inspect}, historical_annual_gross_income:"\
  " #{@historical_annual_gross_income.inspect}, historical_annual_income:"\
  " #{@historical_annual_income.inspect}, forecasted_annual_income:"\
  " #{@forecasted_annual_income.inspect}, historical_summary: #{@historical_summary.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/the_plaid_api/models/cra_bank_income_summary.rb', line 292

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} 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_average_monthly_gross_income: #{@historical_average_monthly_gross_income},"\
  " historical_average_monthly_income: #{@historical_average_monthly_income},"\
  " forecasted_average_monthly_income: #{@forecasted_average_monthly_income},"\
  " historical_annual_gross_income: #{@historical_annual_gross_income},"\
  " historical_annual_income: #{@historical_annual_income}, forecasted_annual_income:"\
  " #{@forecasted_annual_income}, historical_summary: #{@historical_summary},"\
  " additional_properties: #{@additional_properties}>"
end