Class: ThePlaidApi::FinancialInstitutionInsights

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

Overview

Insights surrounding external financial institution counterparties associated with a 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(name:, website:, detected_accounts:, entity_id: SKIP, additional_properties: nil) ⇒ FinancialInstitutionInsights

Returns a new instance of FinancialInstitutionInsights.



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/the_plaid_api/models/financial_institution_insights.rb', line 55

def initialize(name:, website:, detected_accounts:, entity_id: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @name = name
  @entity_id = entity_id unless entity_id == SKIP
  @website = website
  @detected_accounts = detected_accounts
  @additional_properties = additional_properties
end

Instance Attribute Details

#detected_accountsArray[DetectedAccount]

Associated accounts, detected based on the nature of transfers to/from this institution.

Returns:



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

def detected_accounts
  @detected_accounts
end

#entity_idString

A unique, stable, Plaid-generated id that maps to the counterparty.

Returns:

  • (String)


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

def entity_id
  @entity_id
end

#nameString

Name of the financial institution counterparty.

Returns:

  • (String)


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

def name
  @name
end

#websiteString

The website associated with the counterparty.

Returns:

  • (String)


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

def website
  @website
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : nil
  website = hash.key?('website') ? hash['website'] : nil
  # Parameter is an array, so we need to iterate through it
  detected_accounts = nil
  unless hash['detected_accounts'].nil?
    detected_accounts = []
    hash['detected_accounts'].each do |structure|
      detected_accounts << (DetectedAccount.from_hash(structure) if structure)
    end
  end

  detected_accounts = nil unless hash.key?('detected_accounts')
  entity_id = hash.key?('entity_id') ? hash['entity_id'] : SKIP

  # 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.
  FinancialInstitutionInsights.new(name: name,
                                   website: website,
                                   detected_accounts: detected_accounts,
                                   entity_id: entity_id,
                                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



31
32
33
34
35
36
37
38
# File 'lib/the_plaid_api/models/financial_institution_insights.rb', line 31

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['name'] = 'name'
  @_hash['entity_id'] = 'entity_id'
  @_hash['website'] = 'website'
  @_hash['detected_accounts'] = 'detected_accounts'
  @_hash
end

.nullablesObject

An array for nullable fields



48
49
50
51
52
53
# File 'lib/the_plaid_api/models/financial_institution_insights.rb', line 48

def self.nullables
  %w[
    entity_id
    website
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    entity_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



110
111
112
113
114
115
# File 'lib/the_plaid_api/models/financial_institution_insights.rb', line 110

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

#to_sObject

Provides a human-readable string representation of the object.



102
103
104
105
106
107
# File 'lib/the_plaid_api/models/financial_institution_insights.rb', line 102

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