Class: ThePlaidApi::Counterparty1

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

Overview

The counterparty, such as the merchant or financial institution, is extracted by Plaid from the raw description.

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:, type:, website:, logo_url:, phone_number:, entity_id: SKIP, confidence_level: SKIP, account_numbers: SKIP, additional_properties: nil) ⇒ Counterparty1

Returns a new instance of Counterparty1.



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/the_plaid_api/models/counterparty1.rb', line 104

def initialize(name:, type:, website:, logo_url:, phone_number:,
               entity_id: SKIP, confidence_level: SKIP,
               account_numbers: 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
  @type = type
  @website = website
  @logo_url = logo_url
  @confidence_level = confidence_level unless confidence_level == SKIP
  @phone_number = phone_number
  @account_numbers =  unless  == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_numbersCounterpartyNumbers

Account numbers associated with the counterparty, when available. This field is currently only filled in for select financial institutions in Europe.

Returns:



67
68
69
# File 'lib/the_plaid_api/models/counterparty1.rb', line 67

def 
  @account_numbers
end

#confidence_levelString

A description of how confident we are that the provided counterparty is involved in the transaction. ‘VERY_HIGH`: We recognize this counterparty and we are more than 98% confident that it is involved in this transaction. `HIGH`: We recognize this counterparty and we are more than 90% confident that it is involved in this transaction. `MEDIUM`: We are moderately confident that this counterparty was involved in this transaction, but some details may differ from our records. `LOW`: We didn’t find a matching counterparty in our records, so we are returning a cleansed name parsed out of the request description. `UNKNOWN`: We don’t know the confidence level for this counterparty.

Returns:

  • (String)


55
56
57
# File 'lib/the_plaid_api/models/counterparty1.rb', line 55

def confidence_level
  @confidence_level
end

#entity_idString

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

Returns:

  • (String)


20
21
22
# File 'lib/the_plaid_api/models/counterparty1.rb', line 20

def entity_id
  @entity_id
end

#logo_urlString

The URL of a logo associated with the counterparty, if available. The logo will always be 100×100 pixel PNG file.

Returns:

  • (String)


41
42
43
# File 'lib/the_plaid_api/models/counterparty1.rb', line 41

def logo_url
  @logo_url
end

#nameString

The name of the counterparty, such as the merchant or the financial institution, as extracted by Plaid from the raw description.

Returns:

  • (String)


16
17
18
# File 'lib/the_plaid_api/models/counterparty1.rb', line 16

def name
  @name
end

#phone_numberString

The phone number associated with the counterparty in E. 164 format. If there is a location match (i.e. a street address is returned in the location object), the phone number will be location specific.

Returns:

  • (String)


61
62
63
# File 'lib/the_plaid_api/models/counterparty1.rb', line 61

def phone_number
  @phone_number
end

#typeCounterpartyType

The counterparty type. ‘merchant`: a provider of goods or services for purchase `financial_institution`: a financial entity (bank, credit union, BNPL, fintech) `payment_app`: a transfer or P2P app (e.g. Zelle) `marketplace`: a marketplace (e.g DoorDash, Google Play Store) `payment_terminal`: a point-of-sale payment terminal (e.g Square, Toast) `income_source`: the payer in an income transaction (e.g., an employer, client, or government agency)

Returns:



32
33
34
# File 'lib/the_plaid_api/models/counterparty1.rb', line 32

def type
  @type
end

#websiteString

The website associated with the counterparty.

Returns:

  • (String)


36
37
38
# File 'lib/the_plaid_api/models/counterparty1.rb', line 36

def website
  @website
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/the_plaid_api/models/counterparty1.rb', line 122

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : nil
  type = hash.key?('type') ? hash['type'] : nil
  website = hash.key?('website') ? hash['website'] : nil
  logo_url = hash.key?('logo_url') ? hash['logo_url'] : nil
  phone_number = hash.key?('phone_number') ? hash['phone_number'] : nil
  entity_id = hash.key?('entity_id') ? hash['entity_id'] : SKIP
  confidence_level =
    hash.key?('confidence_level') ? hash['confidence_level'] : SKIP
   = CounterpartyNumbers.from_hash(hash['account_numbers']) if
    hash['account_numbers']

  # 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.
  Counterparty1.new(name: name,
                    type: type,
                    website: website,
                    logo_url: logo_url,
                    phone_number: phone_number,
                    entity_id: entity_id,
                    confidence_level: confidence_level,
                    account_numbers: ,
                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/the_plaid_api/models/counterparty1.rb', line 70

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['name'] = 'name'
  @_hash['entity_id'] = 'entity_id'
  @_hash['type'] = 'type'
  @_hash['website'] = 'website'
  @_hash['logo_url'] = 'logo_url'
  @_hash['confidence_level'] = 'confidence_level'
  @_hash['phone_number'] = 'phone_number'
  @_hash['account_numbers'] = 'account_numbers'
  @_hash
end

.nullablesObject

An array for nullable fields



93
94
95
96
97
98
99
100
101
102
# File 'lib/the_plaid_api/models/counterparty1.rb', line 93

def self.nullables
  %w[
    entity_id
    website
    logo_url
    confidence_level
    phone_number
    account_numbers
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    entity_id
    confidence_level
    account_numbers
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



166
167
168
169
170
171
172
173
# File 'lib/the_plaid_api/models/counterparty1.rb', line 166

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

#to_sObject

Provides a human-readable string representation of the object.



157
158
159
160
161
162
163
# File 'lib/the_plaid_api/models/counterparty1.rb', line 157

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