Class: ThePlaidApi::Enhancements

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

Overview

A grouping of the Plaid produced transaction enhancement 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(payment_channel:, category_id:, category:, location:, merchant_name: SKIP, website: SKIP, logo_url: SKIP, check_number: SKIP, personal_finance_category: SKIP, personal_finance_category_icon_url: SKIP, counterparties: SKIP, additional_properties: nil) ⇒ Enhancements

Returns a new instance of Enhancements.



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

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

  @merchant_name = merchant_name unless merchant_name == SKIP
  @website = website unless website == SKIP
  @logo_url = logo_url unless logo_url == SKIP
  @check_number = check_number unless check_number == SKIP
  @payment_channel = payment_channel
  @category_id = category_id
  @category = category
  @location = location
  unless personal_finance_category == SKIP
    @personal_finance_category =
      personal_finance_category
  end
  unless personal_finance_category_icon_url == SKIP
    @personal_finance_category_icon_url =
      personal_finance_category_icon_url
  end
  @counterparties = counterparties unless counterparties == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#categoryArray[String]

A hierarchical array of the categories to which this transaction belongs. For a full list of categories, see [‘/categories/get`](plaid.com/docs/api/products/transactions/#cate goriesget).

Returns:

  • (Array[String])


50
51
52
# File 'lib/the_plaid_api/models/enhancements.rb', line 50

def category
  @category
end

#category_idString

The ID of the category to which this transaction belongs. For a full list of categories, see [‘/categories/get`](plaid.com/docs/api/products/transactions/#cate goriesget).

Returns:

  • (String)


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

def category_id
  @category_id
end

#check_numberString

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

Returns:

  • (String)


29
30
31
# File 'lib/the_plaid_api/models/enhancements.rb', line 29

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:



80
81
82
# File 'lib/the_plaid_api/models/enhancements.rb', line 80

def counterparties
  @counterparties
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:



59
60
61
# File 'lib/the_plaid_api/models/enhancements.rb', line 59

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)


24
25
26
# File 'lib/the_plaid_api/models/enhancements.rb', line 24

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)


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

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.



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

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/).



69
70
71
# File 'lib/the_plaid_api/models/enhancements.rb', line 69

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)


74
75
76
# File 'lib/the_plaid_api/models/enhancements.rb', line 74

def personal_finance_category_icon_url
  @personal_finance_category_icon_url
end

#websiteString

The website associated with this transaction, if available.

Returns:

  • (String)


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

def website
  @website
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



154
155
156
157
158
159
160
161
162
163
164
165
166
167
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
# File 'lib/the_plaid_api/models/enhancements.rb', line 154

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  payment_channel =
    hash.key?('payment_channel') ? hash['payment_channel'] : nil
  category_id = hash.key?('category_id') ? hash['category_id'] : nil
  category = hash.key?('category') ? hash['category'] : nil
  location = TransactionLocation.from_hash(hash['location']) if hash['location']
  merchant_name = hash.key?('merchant_name') ? hash['merchant_name'] : SKIP
  website = hash.key?('website') ? hash['website'] : SKIP
  logo_url = hash.key?('logo_url') ? hash['logo_url'] : SKIP
  check_number = hash.key?('check_number') ? hash['check_number'] : SKIP
  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'] : SKIP
  # 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 = SKIP unless hash.key?('counterparties')

  # 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.
  Enhancements.new(payment_channel: payment_channel,
                   category_id: category_id,
                   category: category,
                   location: location,
                   merchant_name: merchant_name,
                   website: website,
                   logo_url: logo_url,
                   check_number: check_number,
                   personal_finance_category: personal_finance_category,
                   personal_finance_category_icon_url: personal_finance_category_icon_url,
                   counterparties: counterparties,
                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/the_plaid_api/models/enhancements.rb', line 83

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

.nullablesObject

An array for nullable fields



114
115
116
117
118
119
120
121
122
123
# File 'lib/the_plaid_api/models/enhancements.rb', line 114

def self.nullables
  %w[
    merchant_name
    website
    logo_url
    check_number
    category_id
    personal_finance_category
  ]
end

.optionalsObject

An array for optional fields



101
102
103
104
105
106
107
108
109
110
111
# File 'lib/the_plaid_api/models/enhancements.rb', line 101

def self.optionals
  %w[
    merchant_name
    website
    logo_url
    check_number
    personal_finance_category
    personal_finance_category_icon_url
    counterparties
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



217
218
219
220
221
222
223
224
225
226
# File 'lib/the_plaid_api/models/enhancements.rb', line 217

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

#to_sObject

Provides a human-readable string representation of the object.



206
207
208
209
210
211
212
213
214
# File 'lib/the_plaid_api/models/enhancements.rb', line 206

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