Class: ThePlaidApi::RiskIndicators

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

Overview

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.

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(bank_penalties: SKIP, gambling: SKIP, loan_disbursements: SKIP, loan_payments: SKIP, negative_balance: SKIP, additional_properties: nil) ⇒ RiskIndicators

Returns a new instance of RiskIndicators.



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

def initialize(bank_penalties: SKIP, gambling: SKIP,
               loan_disbursements: SKIP, loan_payments: SKIP,
               negative_balance: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @bank_penalties = bank_penalties unless bank_penalties == SKIP
  @gambling = gambling unless gambling == SKIP
  @loan_disbursements = loan_disbursements unless loan_disbursements == SKIP
  @loan_payments = loan_payments unless loan_payments == SKIP
  @negative_balance = negative_balance unless negative_balance == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#bank_penaltiesBankPenaltiesIndicators

Insights into bank penalties and fees, including overdraft fees, NSF fees, and other bank-imposed charges.



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

def bank_penalties
  @bank_penalties
end

#gamblingGamblingIndicators

Insights into gambling-related transactions, including frequency, amounts, and top merchants.

Returns:



23
24
25
# File 'lib/the_plaid_api/models/risk_indicators.rb', line 23

def gambling
  @gambling
end

#loan_disbursementsLoanDisbursementsIndicators

Insights into loan disbursement transactions received by the user, tracking incoming funds from loan providers.



28
29
30
# File 'lib/the_plaid_api/models/risk_indicators.rb', line 28

def loan_disbursements
  @loan_disbursements
end

#loan_paymentsLoanPaymentsIndicators

Insights into loan payment transactions made by the user, tracking outgoing payments to loan providers.



33
34
35
# File 'lib/the_plaid_api/models/risk_indicators.rb', line 33

def loan_payments
  @loan_payments
end

#negative_balanceNegativeBalanceInsights

Insights into negative balance occurrences, including frequency, duration, and minimum balance details.



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

def negative_balance
  @negative_balance
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/the_plaid_api/models/risk_indicators.rb', line 88

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  bank_penalties = BankPenaltiesIndicators.from_hash(hash['bank_penalties']) if
    hash['bank_penalties']
  gambling = GamblingIndicators.from_hash(hash['gambling']) if hash['gambling']
  loan_disbursements = LoanDisbursementsIndicators.from_hash(hash['loan_disbursements']) if
    hash['loan_disbursements']
  loan_payments = LoanPaymentsIndicators.from_hash(hash['loan_payments']) if
    hash['loan_payments']
  negative_balance = NegativeBalanceInsights.from_hash(hash['negative_balance']) if
    hash['negative_balance']

  # 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.
  RiskIndicators.new(bank_penalties: bank_penalties,
                     gambling: gambling,
                     loan_disbursements: loan_disbursements,
                     loan_payments: loan_payments,
                     negative_balance: negative_balance,
                     additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
48
49
# File 'lib/the_plaid_api/models/risk_indicators.rb', line 41

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['bank_penalties'] = 'bank_penalties'
  @_hash['gambling'] = 'gambling'
  @_hash['loan_disbursements'] = 'loan_disbursements'
  @_hash['loan_payments'] = 'loan_payments'
  @_hash['negative_balance'] = 'negative_balance'
  @_hash
end

.nullablesObject

An array for nullable fields



63
64
65
66
67
68
69
70
71
# File 'lib/the_plaid_api/models/risk_indicators.rb', line 63

def self.nullables
  %w[
    bank_penalties
    gambling
    loan_disbursements
    loan_payments
    negative_balance
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    bank_penalties
    gambling
    loan_disbursements
    loan_payments
    negative_balance
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



127
128
129
130
131
132
133
# File 'lib/the_plaid_api/models/risk_indicators.rb', line 127

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} bank_penalties: #{@bank_penalties.inspect}, gambling: #{@gambling.inspect},"\
  " loan_disbursements: #{@loan_disbursements.inspect}, loan_payments:"\
  " #{@loan_payments.inspect}, negative_balance: #{@negative_balance.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



119
120
121
122
123
124
# File 'lib/the_plaid_api/models/risk_indicators.rb', line 119

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} bank_penalties: #{@bank_penalties}, gambling: #{@gambling},"\
  " loan_disbursements: #{@loan_disbursements}, loan_payments: #{@loan_payments},"\
  " negative_balance: #{@negative_balance}, additional_properties: #{@additional_properties}>"
end