Class: ThePlaidApi::CraBankIncomeSource

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

Overview

Detailed information for the income source.

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(forecasted_average_monthly_income_prediction_intervals:, income_provider:, account_id: SKIP, income_source_id: SKIP, income_description: SKIP, income_category: SKIP, start_date: SKIP, end_date: SKIP, pay_frequency: SKIP, total_amount: SKIP, iso_currency_code: SKIP, unofficial_currency_code: SKIP, transaction_count: SKIP, next_payment_date: SKIP, status: SKIP, historical_average_monthly_gross_income: SKIP, historical_average_monthly_income: SKIP, forecasted_average_monthly_income: SKIP, employer: SKIP, historical_summary: SKIP, additional_properties: nil) ⇒ CraBankIncomeSource

Returns a new instance of CraBankIncomeSource.



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
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 209

def initialize(forecasted_average_monthly_income_prediction_intervals:,
               income_provider:, account_id: SKIP, income_source_id: SKIP,
               income_description: SKIP, income_category: SKIP,
               start_date: SKIP, end_date: SKIP, pay_frequency: SKIP,
               total_amount: SKIP, iso_currency_code: SKIP,
               unofficial_currency_code: SKIP, transaction_count: SKIP,
               next_payment_date: SKIP, status: SKIP,
               historical_average_monthly_gross_income: SKIP,
               historical_average_monthly_income: SKIP,
               forecasted_average_monthly_income: SKIP, employer: SKIP,
               historical_summary: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @account_id =  unless  == SKIP
  @income_source_id = income_source_id unless income_source_id == SKIP
  @income_description = income_description unless income_description == SKIP
  @income_category = income_category unless income_category == SKIP
  @start_date = start_date unless start_date == SKIP
  @end_date = end_date unless end_date == SKIP
  @pay_frequency = pay_frequency unless pay_frequency == SKIP
  @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
  @transaction_count = transaction_count unless transaction_count == SKIP
  @next_payment_date = next_payment_date unless next_payment_date == SKIP
  @status = status unless status == SKIP
  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
  @forecasted_average_monthly_income_prediction_intervals = forecasted_average_monthly_income_prediction_intervals
  @employer = employer unless employer == SKIP
  @income_provider = income_provider
  @historical_summary = historical_summary unless historical_summary == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_idString

The account ID with which this income source is associated.

Returns:

  • (String)


14
15
16
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 14

def 
  @account_id
end

#employerCraBankIncomeEmployer

The object containing employer data.



132
133
134
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 132

def employer
  @employer
end

#end_dateDate

Maximum of all dates within the specific income sources in the user’s bank account for days requested by the client. The date will be returned in an ISO 8601 format (YYYY-MM-DD).

Returns:

  • (Date)


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

def end_date
  @end_date
end

#forecasted_average_monthly_incomeFloat

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

Returns:

  • (Float)


124
125
126
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 124

def forecasted_average_monthly_income
  @forecasted_average_monthly_income
end

#forecasted_average_monthly_income_prediction_intervalsArray[CraPredictionInterval]

The prediction interval(s) for the forecasted average monthly income.

Returns:



128
129
130
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 128

def forecasted_average_monthly_income_prediction_intervals
  @forecasted_average_monthly_income_prediction_intervals
end

#historical_average_monthly_gross_incomeFloat

An estimate of the average gross monthly income based on the historical net amount and income category for the income source(s).

Returns:

  • (Float)


115
116
117
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 115

def historical_average_monthly_gross_income
  @historical_average_monthly_gross_income
end

#historical_average_monthly_incomeFloat

The average monthly net income amount estimated based on the historical data for the income source(s).

Returns:

  • (Float)


120
121
122
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 120

def historical_average_monthly_income
  @historical_average_monthly_income
end

#historical_summaryArray[CraBankIncomeHistoricalSummary]

The object containing data about the income provider.

Returns:



140
141
142
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 140

def historical_summary
  @historical_summary
end

#income_categoryCreditBankIncomeCategory

The income category. ‘BANK_INTEREST`: Interest earned from a bank account. `BENEFIT_OTHER`: Government benefits other than retirement, unemployment, child support, or disability. Currently used only in the UK, to represent benefits such as Cost of Living Payments. `CASH`: Deprecated and used only for existing legacy implementations. Has been replaced by `CASH_DEPOSIT` and `TRANSFER_FROM_APPLICATION`. `CASH_DEPOSIT`: A cash or check deposit. `CHILD_SUPPORT`: Child support payments received. `GIG_ECONOMY`: Income earned as a gig economy worker, e.g. driving for Uber, Lyft, Postmates, DoorDash, etc. `LONG_TERM_DISABILITY`: Disability payments, including Social Security disability benefits. `OTHER`: Income that could not be categorized as any other income category. `MILITARY`: Veterans benefits. Income earned as salary for serving in the military (e.g. through DFAS) will be classified as `SALARY` rather than `MILITARY`. `RENTAL`: Income earned from a rental property. Income may be identified as rental when the payment is received through a rental platform, e.g. Airbnb; rent paid directly by the tenant to the property owner (e.g. via cash, check, or ACH) will typically not be classified as rental income. `RETIREMENT`: Payments from private retirement systems, pensions, and government retirement programs, including Social Security retirement benefits. `SALARY`: Payment from an employer to an earner or other form of permanent employment. `TAX_REFUND`: A tax refund. `TRANSFER_FROM_APPLICATION`: Deposits from a money transfer app, such as Venmo, Cash App, or Zelle. `UNEMPLOYMENT`: Unemployment benefits. In the UK, includes certain low-income benefits such as the Universal Credit.



60
61
62
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 60

def income_category
  @income_category
end

#income_descriptionString

The most common name or original description for the underlying income transactions.

Returns:

  • (String)


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

def income_description
  @income_description
end

#income_providerCraBankIncomeIncomeProvider

The object containing data about the income provider.



136
137
138
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 136

def income_provider
  @income_provider
end

#income_source_idString

A unique identifier for an income source. If the report is regenerated and a new ‘report_id` is created, the new report will have a new set of `income_source_id`s.

Returns:

  • (String)


20
21
22
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 20

def income_source_id
  @income_source_id
end

#iso_currency_codeString

The ISO 4217 currency code of the amount or balance.

Returns:

  • (String)


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

def iso_currency_code
  @iso_currency_code
end

#next_payment_dateDate

The expected date of the end user’s next paycheck for the income source. The date will be returned in an ISO 8601 format (YYYY-MM-DD).

Returns:

  • (Date)


103
104
105
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 103

def next_payment_date
  @next_payment_date
end

#pay_frequencyCreditBankIncomePayFrequency

The income pay frequency.



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

def pay_frequency
  @pay_frequency
end

#start_dateDate

Minimum of all dates within the specific income sources in the user’s bank account for days requested by the client. The date will be returned in an ISO 8601 format (YYYY-MM-DD).

Returns:

  • (Date)


66
67
68
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 66

def start_date
  @start_date
end

#statusCraBankIncomeStatus

The status of the income sources. ‘ACTIVE`: The income source is active. `INACTIVE`: The income source is inactive. `UNKNOWN`: The income source status is unknown.

Returns:



110
111
112
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 110

def status
  @status
end

#total_amountFloat

Total amount of earnings in the user’s bank account for the specific income source for days requested by the client.

Returns:

  • (Float)


81
82
83
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 81

def total_amount
  @total_amount
end

#transaction_countInteger

Number of transactions for the income source within the start and end date.

Returns:

  • (Integer)


98
99
100
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 98

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


93
94
95
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 93

def unofficial_currency_code
  @unofficial_currency_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 256

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
  forecasted_average_monthly_income_prediction_intervals = nil
  unless hash['forecasted_average_monthly_income_prediction_intervals'].nil?
    forecasted_average_monthly_income_prediction_intervals = []
    hash['forecasted_average_monthly_income_prediction_intervals'].each do |structure|
      forecasted_average_monthly_income_prediction_intervals << (CraPredictionInterval.from_hash(structure) if structure)
    end
  end

  forecasted_average_monthly_income_prediction_intervals = nil unless hash.key?('forecasted_average_monthly_income_prediction_intervals')
  income_provider = CraBankIncomeIncomeProvider.from_hash(hash['income_provider']) if
    hash['income_provider']
   = hash.key?('account_id') ? hash['account_id'] : SKIP
  income_source_id =
    hash.key?('income_source_id') ? hash['income_source_id'] : SKIP
  income_description =
    hash.key?('income_description') ? hash['income_description'] : SKIP
  income_category =
    hash.key?('income_category') ? hash['income_category'] : SKIP
  start_date = hash.key?('start_date') ? hash['start_date'] : SKIP
  end_date = hash.key?('end_date') ? hash['end_date'] : SKIP
  pay_frequency = hash.key?('pay_frequency') ? hash['pay_frequency'] : SKIP
  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
  transaction_count =
    hash.key?('transaction_count') ? hash['transaction_count'] : SKIP
  next_payment_date =
    hash.key?('next_payment_date') ? hash['next_payment_date'] : SKIP
  status = hash.key?('status') ? hash['status'] : SKIP
  historical_average_monthly_gross_income =
    hash.key?('historical_average_monthly_gross_income') ? hash['historical_average_monthly_gross_income'] : SKIP
  historical_average_monthly_income =
    hash.key?('historical_average_monthly_income') ? hash['historical_average_monthly_income'] : SKIP
  forecasted_average_monthly_income =
    hash.key?('forecasted_average_monthly_income') ? hash['forecasted_average_monthly_income'] : SKIP
  employer = CraBankIncomeEmployer.from_hash(hash['employer']) if hash['employer']
  # 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.
  CraBankIncomeSource.new(forecasted_average_monthly_income_prediction_intervals: forecasted_average_monthly_income_prediction_intervals,
                          income_provider: income_provider,
                          account_id: ,
                          income_source_id: income_source_id,
                          income_description: income_description,
                          income_category: income_category,
                          start_date: start_date,
                          end_date: end_date,
                          pay_frequency: pay_frequency,
                          total_amount: total_amount,
                          iso_currency_code: iso_currency_code,
                          unofficial_currency_code: unofficial_currency_code,
                          transaction_count: transaction_count,
                          next_payment_date: next_payment_date,
                          status: status,
                          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,
                          employer: employer,
                          historical_summary: historical_summary,
                          additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 143

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['account_id'] = 'account_id'
  @_hash['income_source_id'] = 'income_source_id'
  @_hash['income_description'] = 'income_description'
  @_hash['income_category'] = 'income_category'
  @_hash['start_date'] = 'start_date'
  @_hash['end_date'] = 'end_date'
  @_hash['pay_frequency'] = 'pay_frequency'
  @_hash['total_amount'] = 'total_amount'
  @_hash['iso_currency_code'] = 'iso_currency_code'
  @_hash['unofficial_currency_code'] = 'unofficial_currency_code'
  @_hash['transaction_count'] = 'transaction_count'
  @_hash['next_payment_date'] = 'next_payment_date'
  @_hash['status'] = 'status'
  @_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['forecasted_average_monthly_income_prediction_intervals'] =
    'forecasted_average_monthly_income_prediction_intervals'
  @_hash['employer'] = 'employer'
  @_hash['income_provider'] = 'income_provider'
  @_hash['historical_summary'] = 'historical_summary'
  @_hash
end

.nullablesObject

An array for nullable fields



197
198
199
200
201
202
203
204
205
206
207
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 197

def self.nullables
  %w[
    iso_currency_code
    unofficial_currency_code
    next_payment_date
    historical_average_monthly_gross_income
    historical_average_monthly_income
    forecasted_average_monthly_income
    income_provider
  ]
end

.optionalsObject

An array for optional fields



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 173

def self.optionals
  %w[
    account_id
    income_source_id
    income_description
    income_category
    start_date
    end_date
    pay_frequency
    total_amount
    iso_currency_code
    unofficial_currency_code
    transaction_count
    next_payment_date
    status
    historical_average_monthly_gross_income
    historical_average_monthly_income
    forecasted_average_monthly_income
    employer
    historical_summary
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 360

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} account_id: #{@account_id.inspect}, income_source_id:"\
  " #{@income_source_id.inspect}, income_description: #{@income_description.inspect},"\
  " income_category: #{@income_category.inspect}, start_date: #{@start_date.inspect},"\
  " end_date: #{@end_date.inspect}, pay_frequency: #{@pay_frequency.inspect}, total_amount:"\
  " #{@total_amount.inspect}, iso_currency_code: #{@iso_currency_code.inspect},"\
  " unofficial_currency_code: #{@unofficial_currency_code.inspect}, transaction_count:"\
  " #{@transaction_count.inspect}, next_payment_date: #{@next_payment_date.inspect}, status:"\
  " #{@status.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},"\
  ' forecasted_average_monthly_income_prediction_intervals:'\
  " #{@forecasted_average_monthly_income_prediction_intervals.inspect}, employer:"\
  " #{@employer.inspect}, income_provider: #{@income_provider.inspect}, historical_summary:"\
  " #{@historical_summary.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/the_plaid_api/models/cra_bank_income_source.rb', line 342

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} account_id: #{@account_id}, income_source_id: #{@income_source_id},"\
  " income_description: #{@income_description}, income_category: #{@income_category},"\
  " start_date: #{@start_date}, end_date: #{@end_date}, pay_frequency: #{@pay_frequency},"\
  " total_amount: #{@total_amount}, iso_currency_code: #{@iso_currency_code},"\
  " unofficial_currency_code: #{@unofficial_currency_code}, transaction_count:"\
  " #{@transaction_count}, next_payment_date: #{@next_payment_date}, status: #{@status},"\
  " 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},"\
  ' forecasted_average_monthly_income_prediction_intervals:'\
  " #{@forecasted_average_monthly_income_prediction_intervals}, employer: #{@employer},"\
  " income_provider: #{@income_provider}, historical_summary: #{@historical_summary},"\
  " additional_properties: #{@additional_properties}>"
end