Class: ThePlaidApi::Counterparty

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/the_plaid_api/models/counterparty.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:, entity_id: SKIP, confidence_level: SKIP, account_numbers: SKIP, additional_properties: nil) ⇒ Counterparty

Returns a new instance of Counterparty.



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/the_plaid_api/models/counterparty.rb', line 96

def initialize(name:, type:, website:, logo_url:, 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
  @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:



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

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/counterparty.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/counterparty.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/counterparty.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/counterparty.rb', line 16

def name
  @name
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/counterparty.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/counterparty.rb', line 36

def website
  @website
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/the_plaid_api/models/counterparty.rb', line 113

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
  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.
  Counterparty.new(name: name,
                   type: type,
                   website: website,
                   logo_url: logo_url,
                   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.



64
65
66
67
68
69
70
71
72
73
74
# File 'lib/the_plaid_api/models/counterparty.rb', line 64

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['account_numbers'] = 'account_numbers'
  @_hash
end

.nullablesObject

An array for nullable fields



86
87
88
89
90
91
92
93
94
# File 'lib/the_plaid_api/models/counterparty.rb', line 86

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

.optionalsObject

An array for optional fields



77
78
79
80
81
82
83
# File 'lib/the_plaid_api/models/counterparty.rb', line 77

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



154
155
156
157
158
159
160
# File 'lib/the_plaid_api/models/counterparty.rb', line 154

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}, account_numbers:"\
  " #{@account_numbers.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



146
147
148
149
150
151
# File 'lib/the_plaid_api/models/counterparty.rb', line 146

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},"\
  " account_numbers: #{@account_numbers}, additional_properties: #{@additional_properties}>"
end