Class: ThePlaidApi::CraIncomeInsights

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

Overview

The Check Income Insights Report for an end user.

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(report_id: SKIP, generated_time: SKIP, days_requested: SKIP, client_report_id: SKIP, items: SKIP, user_summary: SKIP, income_streams: SKIP, bank_income_summary: SKIP, warnings: SKIP, additional_properties: nil) ⇒ CraIncomeInsights

Returns a new instance of CraIncomeInsights.



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

def initialize(report_id: SKIP, generated_time: SKIP, days_requested: SKIP,
               client_report_id: SKIP, items: SKIP, user_summary: SKIP,
               income_streams: SKIP, bank_income_summary: SKIP,
               warnings: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @report_id = report_id unless report_id == SKIP
  @generated_time = generated_time unless generated_time == SKIP
  @days_requested = days_requested unless days_requested == SKIP
  @client_report_id = client_report_id unless client_report_id == SKIP
  @items = items unless items == SKIP
  @user_summary = user_summary unless user_summary == SKIP
  @income_streams = income_streams unless income_streams == SKIP
  @bank_income_summary = bank_income_summary unless bank_income_summary == SKIP
  @warnings = warnings unless warnings == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#bank_income_summaryCraBankIncomeSummary

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).



48
49
50
# File 'lib/the_plaid_api/models/cra_income_insights.rb', line 48

def bank_income_summary
  @bank_income_summary
end

#client_report_idString

Client-generated identifier, which can be used by lenders to track loan applications.

Returns:

  • (String)


29
30
31
# File 'lib/the_plaid_api/models/cra_income_insights.rb', line 29

def client_report_id
  @client_report_id
end

#days_requestedInteger

The number of days requested by the customer for the Check Income Insights Report.

Returns:

  • (Integer)


24
25
26
# File 'lib/the_plaid_api/models/cra_income_insights.rb', line 24

def days_requested
  @days_requested
end

#generated_timeDateTime

The time when the Check Income Insights Report was generated.

Returns:

  • (DateTime)


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

def generated_time
  @generated_time
end

#income_streamsArray[CraIncomeStream]

The list of income streams for this user.

Returns:



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

def income_streams
  @income_streams
end

#itemsArray[CraBankIncomeItem]

The list of Items in the report along with the associated metadata about the Item.

Returns:



34
35
36
# File 'lib/the_plaid_api/models/cra_income_insights.rb', line 34

def items
  @items
end

#report_idString

The unique identifier associated with the Check Income Insights Report.

Returns:

  • (String)


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

def report_id
  @report_id
end

#user_summaryCraIncomeInsightsUserSummary

Aggregated summary of all income streams for this user.



38
39
40
# File 'lib/the_plaid_api/models/cra_income_insights.rb', line 38

def user_summary
  @user_summary
end

#warningsArray[CraBankIncomeWarning]

If data from the report was unable to be retrieved, the warnings object will contain information about the error that caused the data to be incomplete.

Returns:



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

def warnings
  @warnings
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



114
115
116
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
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
# File 'lib/the_plaid_api/models/cra_income_insights.rb', line 114

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  report_id = hash.key?('report_id') ? hash['report_id'] : SKIP
  generated_time = if hash.key?('generated_time')
                     (DateTimeHelper.from_rfc3339(hash['generated_time']) if hash['generated_time'])
                   else
                     SKIP
                   end
  days_requested =
    hash.key?('days_requested') ? hash['days_requested'] : SKIP
  client_report_id =
    hash.key?('client_report_id') ? hash['client_report_id'] : SKIP
  # Parameter is an array, so we need to iterate through it
  items = nil
  unless hash['items'].nil?
    items = []
    hash['items'].each do |structure|
      items << (CraBankIncomeItem.from_hash(structure) if structure)
    end
  end

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

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

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

  # 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.
  CraIncomeInsights.new(report_id: report_id,
                        generated_time: generated_time,
                        days_requested: days_requested,
                        client_report_id: client_report_id,
                        items: items,
                        user_summary: user_summary,
                        income_streams: income_streams,
                        bank_income_summary: bank_income_summary,
                        warnings: warnings,
                        additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['report_id'] = 'report_id'
  @_hash['generated_time'] = 'generated_time'
  @_hash['days_requested'] = 'days_requested'
  @_hash['client_report_id'] = 'client_report_id'
  @_hash['items'] = 'items'
  @_hash['user_summary'] = 'user_summary'
  @_hash['income_streams'] = 'income_streams'
  @_hash['bank_income_summary'] = 'bank_income_summary'
  @_hash['warnings'] = 'warnings'
  @_hash
end

.nullablesObject

An array for nullable fields



87
88
89
90
91
92
# File 'lib/the_plaid_api/models/cra_income_insights.rb', line 87

def self.nullables
  %w[
    client_report_id
    user_summary
  ]
end

.optionalsObject

An array for optional fields



72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/the_plaid_api/models/cra_income_insights.rb', line 72

def self.optionals
  %w[
    report_id
    generated_time
    days_requested
    client_report_id
    items
    user_summary
    income_streams
    bank_income_summary
    warnings
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



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

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} report_id: #{@report_id.inspect}, generated_time:"\
  " #{@generated_time.inspect}, days_requested: #{@days_requested.inspect}, client_report_id:"\
  " #{@client_report_id.inspect}, items: #{@items.inspect}, user_summary:"\
  " #{@user_summary.inspect}, income_streams: #{@income_streams.inspect}, bank_income_summary:"\
  " #{@bank_income_summary.inspect}, warnings: #{@warnings.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_custom_generated_timeObject



183
184
185
# File 'lib/the_plaid_api/models/cra_income_insights.rb', line 183

def to_custom_generated_time
  DateTimeHelper.to_rfc3339(generated_time)
end

#to_sObject

Provides a human-readable string representation of the object.



188
189
190
191
192
193
194
195
# File 'lib/the_plaid_api/models/cra_income_insights.rb', line 188

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} report_id: #{@report_id}, generated_time: #{@generated_time},"\
  " days_requested: #{@days_requested}, client_report_id: #{@client_report_id}, items:"\
  " #{@items}, user_summary: #{@user_summary}, income_streams: #{@income_streams},"\
  " bank_income_summary: #{@bank_income_summary}, warnings: #{@warnings},"\
  " additional_properties: #{@additional_properties}>"
end