Class: ThePlaidApi::Party

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

Overview

A collection of information about a single party to a transaction. Included direct participants like the borrower and seller as well as indirect participants such as the flood certificate provider.

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(individual:, roles:, taxpayer_identifiers:, additional_properties: nil) ⇒ Party

Returns a new instance of Party.



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

def initialize(individual:, roles:, taxpayer_identifiers:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @individual = individual
  @roles = roles
  @taxpayer_identifiers = taxpayer_identifiers
  @additional_properties = additional_properties
end

Instance Attribute Details

#individualIndividual

Documentation not found in the MISMO model viewer and not provided by Freddie Mac.

Returns:



17
18
19
# File 'lib/the_plaid_api/models/party.rb', line 17

def individual
  @individual
end

#rolesRoles

Documentation not found in the MISMO model viewer and not provided by Freddie Mac.

Returns:



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

def roles
  @roles
end

#taxpayer_identifiersTaxpayerIdentifiers

The collection of ‘TAXPAYER_IDENTIFICATION` elements

Returns:



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

def taxpayer_identifiers
  @taxpayer_identifiers
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  individual = Individual.from_hash(hash['INDIVIDUAL']) if hash['INDIVIDUAL']
  roles = Roles.from_hash(hash['ROLES']) if hash['ROLES']
  taxpayer_identifiers = TaxpayerIdentifiers.from_hash(hash['TAXPAYER_IDENTIFIERS']) if
    hash['TAXPAYER_IDENTIFIERS']

  # 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.
  Party.new(individual: individual,
            roles: roles,
            taxpayer_identifiers: taxpayer_identifiers,
            additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['individual'] = 'INDIVIDUAL'
  @_hash['roles'] = 'ROLES'
  @_hash['taxpayer_identifiers'] = 'TAXPAYER_IDENTIFIERS'
  @_hash
end

.nullablesObject

An array for nullable fields



43
44
45
# File 'lib/the_plaid_api/models/party.rb', line 43

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



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

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

#to_sObject

Provides a human-readable string representation of the object.



83
84
85
86
87
# File 'lib/the_plaid_api/models/party.rb', line 83

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