Class: ThePlaidApi::AccountInsights

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

Overview

This is a container object for all lending-related insights. This field will be returned only for European customers.

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(risk: SKIP, affordability: SKIP, additional_properties: nil) ⇒ AccountInsights

Returns a new instance of AccountInsights.



52
53
54
55
56
57
58
59
# File 'lib/the_plaid_api/models/account_insights.rb', line 52

def initialize(risk: SKIP, affordability: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @risk = risk unless risk == SKIP
  @affordability = affordability unless affordability == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#affordabilityAffordabilityInsights

Affordability insights focus on providing signal on the ability of a borrower to repay their loan without experiencing financial strain. It provides insights on factors such a user’s monthly income and expenses, disposable income, average expenditure, etc., helping lenders gauge the level of affordability of a borrower.



26
27
28
# File 'lib/the_plaid_api/models/account_insights.rb', line 26

def affordability
  @affordability
end

#riskRiskIndicators

Risk indicators focus on providing signal on the possibility of a borrower defaulting on their loan repayments by providing data points related to its payment behavior, debt, and other relevant financial information, helping lenders gauge the level of risk involved in a certain operation.

Returns:



18
19
20
# File 'lib/the_plaid_api/models/account_insights.rb', line 18

def risk
  @risk
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/the_plaid_api/models/account_insights.rb', line 62

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  risk = RiskIndicators.from_hash(hash['risk']) if hash['risk']
  affordability = AffordabilityInsights.from_hash(hash['affordability']) if
    hash['affordability']

  # 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.
  AccountInsights.new(risk: risk,
                      affordability: affordability,
                      additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
# File 'lib/the_plaid_api/models/account_insights.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['risk'] = 'risk'
  @_hash['affordability'] = 'affordability'
  @_hash
end

.nullablesObject

An array for nullable fields



45
46
47
48
49
50
# File 'lib/the_plaid_api/models/account_insights.rb', line 45

def self.nullables
  %w[
    risk
    affordability
  ]
end

.optionalsObject

An array for optional fields



37
38
39
40
41
42
# File 'lib/the_plaid_api/models/account_insights.rb', line 37

def self.optionals
  %w[
    risk
    affordability
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



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

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} risk: #{@risk.inspect}, affordability: #{@affordability.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



84
85
86
87
88
# File 'lib/the_plaid_api/models/account_insights.rb', line 84

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} risk: #{@risk}, affordability: #{@affordability}, additional_properties:"\
  " #{@additional_properties}>"
end