Class: ThePlaidApi::LiabilitiesObject

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

Overview

An object containing liability accounts

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(credit:, mortgage:, student:, additional_properties: nil) ⇒ LiabilitiesObject

Returns a new instance of LiabilitiesObject.



47
48
49
50
51
52
53
54
55
# File 'lib/the_plaid_api/models/liabilities_object.rb', line 47

def initialize(credit:, mortgage:, student:, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @credit = credit
  @mortgage = mortgage
  @student = student
  @additional_properties = additional_properties
end

Instance Attribute Details

#creditArray[CreditCardLiability]

The credit accounts returned.

Returns:



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

def credit
  @credit
end

#mortgageArray[MortgageLiability]

The mortgage accounts returned.

Returns:



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

def mortgage
  @mortgage
end

#studentArray[StudentLoan]

The student loan accounts returned.

Returns:



22
23
24
# File 'lib/the_plaid_api/models/liabilities_object.rb', line 22

def student
  @student
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/the_plaid_api/models/liabilities_object.rb', line 58

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

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

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

  student = nil unless hash.key?('student')

  # 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.
  LiabilitiesObject.new(credit: credit,
                        mortgage: mortgage,
                        student: student,
                        additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/the_plaid_api/models/liabilities_object.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['credit'] = 'credit'
  @_hash['mortgage'] = 'mortgage'
  @_hash['student'] = 'student'
  @_hash
end

.nullablesObject

An array for nullable fields



39
40
41
42
43
44
45
# File 'lib/the_plaid_api/models/liabilities_object.rb', line 39

def self.nullables
  %w[
    credit
    mortgage
    student
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



115
116
117
118
119
# File 'lib/the_plaid_api/models/liabilities_object.rb', line 115

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

#to_sObject

Provides a human-readable string representation of the object.



108
109
110
111
112
# File 'lib/the_plaid_api/models/liabilities_object.rb', line 108

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