Class: ThePlaidApi::Enrichments

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

Overview

A grouping of the Plaid produced transaction enrichment fields.

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(counterparties:, location:, logo_url:, merchant_name:, payment_channel:, phone_number:, personal_finance_category:, personal_finance_category_icon_url:, website:, check_number: SKIP, entity_id: SKIP, legacy_category_id: SKIP, legacy_category: SKIP, additional_properties: nil) ⇒ Enrichments

Returns a new instance of Enrichments.



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/the_plaid_api/models/enrichments.rb', line 142

def initialize(counterparties:, location:, logo_url:, merchant_name:,
               payment_channel:, phone_number:, personal_finance_category:,
               personal_finance_category_icon_url:, website:,
               check_number: SKIP, entity_id: SKIP,
               legacy_category_id: SKIP, legacy_category: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @check_number = check_number unless check_number == SKIP
  @counterparties = counterparties
  @entity_id = entity_id unless entity_id == SKIP
  @legacy_category_id = legacy_category_id unless legacy_category_id == SKIP
  @legacy_category = legacy_category unless legacy_category == SKIP
  @location = location
  @logo_url = logo_url
  @merchant_name = merchant_name
  @payment_channel = payment_channel
  @phone_number = phone_number
  @personal_finance_category = personal_finance_category
  @personal_finance_category_icon_url = personal_finance_category_icon_url
  @website = website
  @additional_properties = additional_properties
end

Instance Attribute Details

#check_numberString

The check number of the transaction. This field is only populated for check transactions.

Returns:

  • (String)


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

def check_number
  @check_number
end

#counterpartiesArray[Counterparty1]

The counterparties present in the transaction. Counterparties, such as the merchant or the financial institution, are extracted by Plaid from the raw description.

Returns:



21
22
23
# File 'lib/the_plaid_api/models/enrichments.rb', line 21

def counterparties
  @counterparties
end

#entity_idString

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

Returns:

  • (String)


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

def entity_id
  @entity_id
end

#legacy_categoryArray[String]

A hierarchical array of the legacy categories to which this transaction belongs. For a full list of legacy categories, see [‘/categories/get`](plaid.com/docs/api/products/transactions/#cate goriesget). We recommend using the `personal_finance_category` for transaction categorization to obtain the best results.

Returns:

  • (Array[String])


44
45
46
# File 'lib/the_plaid_api/models/enrichments.rb', line 44

def legacy_category
  @legacy_category
end

#legacy_category_idString

The ID of the legacy category to which this transaction belongs. For a full list of legacy categories, see [‘/categories/get`](plaid.com/docs/api/products/transactions/#cate goriesget). We recommend using the `personal_finance_category` for transaction categorization to obtain the best results.

Returns:

  • (String)


35
36
37
# File 'lib/the_plaid_api/models/enrichments.rb', line 35

def legacy_category_id
  @legacy_category_id
end

#locationTransactionLocation

A representation of where a transaction took place. Location data is provided only for transactions at physical locations, not for online transactions. Location data availability depends primarily on the merchant and is most likely to be populated for transactions at large retail chains; small, local businesses are less likely to have location data available.

Returns:



53
54
55
# File 'lib/the_plaid_api/models/enrichments.rb', line 53

def location
  @location
end

#logo_urlString

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

Returns:

  • (String)


58
59
60
# File 'lib/the_plaid_api/models/enrichments.rb', line 58

def logo_url
  @logo_url
end

#merchant_nameString

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

Returns:

  • (String)


63
64
65
# File 'lib/the_plaid_api/models/enrichments.rb', line 63

def merchant_name
  @merchant_name
end

#payment_channelTransactionPaymentChannel

The channel used to make a payment. ‘online:` transactions that took place online. `in store:` transactions that were made at a physical location. `other:` transactions that relate to banks, e.g. fees or deposits.



70
71
72
# File 'lib/the_plaid_api/models/enrichments.rb', line 70

def payment_channel
  @payment_channel
end

#personal_finance_categoryPersonalFinanceCategory

Information describing the intent of the transaction. Most relevant for personal finance use cases, but not limited to such use cases. See the [taxonomy CSV file](plaid.com/documents/pfc-taxonomy-all.csv) for a full list of personal finance categories. If you are migrating to personal finance categories from the legacy categories, also refer to the [migration guide](plaid.com/docs/transactions/pfc-migration/).



86
87
88
# File 'lib/the_plaid_api/models/enrichments.rb', line 86

def personal_finance_category
  @personal_finance_category
end

#personal_finance_category_icon_urlString

The URL of an icon associated with the primary personal finance category. The icon will always be 100×100 pixel PNG file.

Returns:

  • (String)


91
92
93
# File 'lib/the_plaid_api/models/enrichments.rb', line 91

def personal_finance_category_icon_url
  @personal_finance_category_icon_url
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)


76
77
78
# File 'lib/the_plaid_api/models/enrichments.rb', line 76

def phone_number
  @phone_number
end

#websiteString

The website associated with this transaction.

Returns:

  • (String)


95
96
97
# File 'lib/the_plaid_api/models/enrichments.rb', line 95

def website
  @website
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/the_plaid_api/models/enrichments.rb', line 168

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

  counterparties = nil unless hash.key?('counterparties')
  location = TransactionLocation.from_hash(hash['location']) if hash['location']
  logo_url = hash.key?('logo_url') ? hash['logo_url'] : nil
  merchant_name = hash.key?('merchant_name') ? hash['merchant_name'] : nil
  payment_channel =
    hash.key?('payment_channel') ? hash['payment_channel'] : nil
  phone_number = hash.key?('phone_number') ? hash['phone_number'] : nil
  if hash['personal_finance_category']
    personal_finance_category = PersonalFinanceCategory.from_hash(hash['personal_finance_category'])
  end
  personal_finance_category_icon_url =
    hash.key?('personal_finance_category_icon_url') ? hash['personal_finance_category_icon_url'] : nil
  website = hash.key?('website') ? hash['website'] : nil
  check_number = hash.key?('check_number') ? hash['check_number'] : SKIP
  entity_id = hash.key?('entity_id') ? hash['entity_id'] : SKIP
  legacy_category_id =
    hash.key?('legacy_category_id') ? hash['legacy_category_id'] : SKIP
  legacy_category =
    hash.key?('legacy_category') ? hash['legacy_category'] : 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.
  Enrichments.new(counterparties: counterparties,
                  location: location,
                  logo_url: logo_url,
                  merchant_name: merchant_name,
                  payment_channel: payment_channel,
                  phone_number: phone_number,
                  personal_finance_category: personal_finance_category,
                  personal_finance_category_icon_url: personal_finance_category_icon_url,
                  website: website,
                  check_number: check_number,
                  entity_id: entity_id,
                  legacy_category_id: legacy_category_id,
                  legacy_category: legacy_category,
                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/the_plaid_api/models/enrichments.rb', line 98

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['check_number'] = 'check_number'
  @_hash['counterparties'] = 'counterparties'
  @_hash['entity_id'] = 'entity_id'
  @_hash['legacy_category_id'] = 'legacy_category_id'
  @_hash['legacy_category'] = 'legacy_category'
  @_hash['location'] = 'location'
  @_hash['logo_url'] = 'logo_url'
  @_hash['merchant_name'] = 'merchant_name'
  @_hash['payment_channel'] = 'payment_channel'
  @_hash['phone_number'] = 'phone_number'
  @_hash['personal_finance_category'] = 'personal_finance_category'
  @_hash['personal_finance_category_icon_url'] =
    'personal_finance_category_icon_url'
  @_hash['website'] = 'website'
  @_hash
end

.nullablesObject

An array for nullable fields



128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/the_plaid_api/models/enrichments.rb', line 128

def self.nullables
  %w[
    check_number
    entity_id
    legacy_category_id
    legacy_category
    logo_url
    merchant_name
    phone_number
    personal_finance_category
    website
  ]
end

.optionalsObject

An array for optional fields



118
119
120
121
122
123
124
125
# File 'lib/the_plaid_api/models/enrichments.rb', line 118

def self.optionals
  %w[
    check_number
    entity_id
    legacy_category_id
    legacy_category
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/the_plaid_api/models/enrichments.rb', line 238

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} check_number: #{@check_number.inspect}, counterparties:"\
  " #{@counterparties.inspect}, entity_id: #{@entity_id.inspect}, legacy_category_id:"\
  " #{@legacy_category_id.inspect}, legacy_category: #{@legacy_category.inspect}, location:"\
  " #{@location.inspect}, logo_url: #{@logo_url.inspect}, merchant_name:"\
  " #{@merchant_name.inspect}, payment_channel: #{@payment_channel.inspect}, phone_number:"\
  " #{@phone_number.inspect}, personal_finance_category:"\
  " #{@personal_finance_category.inspect}, personal_finance_category_icon_url:"\
  " #{@personal_finance_category_icon_url.inspect}, website: #{@website.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



226
227
228
229
230
231
232
233
234
235
# File 'lib/the_plaid_api/models/enrichments.rb', line 226

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} check_number: #{@check_number}, counterparties: #{@counterparties},"\
  " entity_id: #{@entity_id}, legacy_category_id: #{@legacy_category_id}, legacy_category:"\
  " #{@legacy_category}, location: #{@location}, logo_url: #{@logo_url}, merchant_name:"\
  " #{@merchant_name}, payment_channel: #{@payment_channel}, phone_number: #{@phone_number},"\
  " personal_finance_category: #{@personal_finance_category},"\
  " personal_finance_category_icon_url: #{@personal_finance_category_icon_url}, website:"\
  " #{@website}, additional_properties: #{@additional_properties}>"
end