Class: ThePlaidApi::ClientProvidedTransaction

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

Overview

A client-provided transaction for Plaid to enrich.

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(id:, description:, amount:, direction:, iso_currency_code:, user_id: SKIP, client_user_id: SKIP, client_account_id: SKIP, account_type: SKIP, account_subtype: SKIP, location: SKIP, mcc: SKIP, date_posted: SKIP, additional_properties: nil) ⇒ ClientProvidedTransaction

Returns a new instance of ClientProvidedTransaction.



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/the_plaid_api/models/client_provided_transaction.rb', line 131

def initialize(id:, description:, amount:, direction:, iso_currency_code:,
               user_id: SKIP, client_user_id: SKIP, client_account_id: SKIP,
               account_type: SKIP, account_subtype: SKIP, location: SKIP,
               mcc: SKIP, date_posted: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @id = id
  @user_id = user_id unless user_id == SKIP
  @client_user_id = client_user_id unless client_user_id == SKIP
  @client_account_id =  unless  == SKIP
  @account_type =  unless  == SKIP
  @account_subtype =  unless  == SKIP
  @description = description
  @amount = amount
  @direction = direction
  @iso_currency_code = iso_currency_code
  @location = location unless location == SKIP
  @mcc = mcc unless mcc == SKIP
  @date_posted = date_posted unless date_posted == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_subtypeString

The account subtype associated with the transaction. For a full list of valid types and subtypes, see the [Account schema](plaid.com/docs/api/accounts#account-type-schema).

Returns:

  • (String)


46
47
48
# File 'lib/the_plaid_api/models/client_provided_transaction.rb', line 46

def 
  @account_subtype
end

#account_typeString

The account type associated with the transaction. For a full list of valid types and subtypes, see the [Account schema](plaid.com/docs/api/accounts#account-type-schema).

Returns:

  • (String)


40
41
42
# File 'lib/the_plaid_api/models/client_provided_transaction.rb', line 40

def 
  @account_type
end

#amountFloat

The absolute value of the transaction (>= 0). When testing Enrich, note that ‘amount` data should be realistic. Unrealistic or inaccurate `amount` data may result in reduced quality output.

Returns:

  • (Float)


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

def amount
  @amount
end

#client_account_idString

A unique account id used to group transactions for a given account, as a unique identifier from your application. Personally identifiable information, such as an email address or phone number, should not be used in the ‘client_account_id`.

Returns:

  • (String)


34
35
36
# File 'lib/the_plaid_api/models/client_provided_transaction.rb', line 34

def 
  @client_account_id
end

#client_user_idString

A unique user id used to group transactions for a given user, as a unique identifier from your application. Personally identifiable information, such as an email address or phone number, should not be used in the ‘client_user_id`.

Returns:

  • (String)


27
28
29
# File 'lib/the_plaid_api/models/client_provided_transaction.rb', line 27

def client_user_id
  @client_user_id
end

#date_postedDate

The date the transaction posted, in [ISO 8601](wikipedia.org/wiki/ISO_8601) (YYYY-MM-DD) format.

Returns:

  • (Date)


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

def date_posted
  @date_posted
end

#descriptionString

The raw description of the transaction. If you have location data in available an unstructured format, it may be appended to the ‘description` field.

Returns:

  • (String)


52
53
54
# File 'lib/the_plaid_api/models/client_provided_transaction.rb', line 52

def description
  @description
end

#directionEnrichTransactionDirection

The direction of the transaction from the perspective of the account holder: ‘OUTFLOW` - Includes outgoing transfers, purchases, and fees. (Typically represented as a negative value on checking accounts and debit cards and a positive value on credit cards.) `INFLOW` - Includes incoming transfers, refunds, and income. (Typically represented as a positive value on checking accounts and debit cards and a negative value on credit cards.)



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

def direction
  @direction
end

#idString

A unique ID for the transaction used to help you tie data back to your systems.

Returns:

  • (String)


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

def id
  @id
end

#iso_currency_codeString

The ISO-4217 currency code of the transaction e.g. USD.

Returns:

  • (String)


73
74
75
# File 'lib/the_plaid_api/models/client_provided_transaction.rb', line 73

def iso_currency_code
  @iso_currency_code
end

#locationClientProvidedTransactionLocation

A representation of where a transaction took place. Use this field to pass in structured location information you may have about your transactions. Providing location data is optional but can increase result quality. If you have unstructured location information, it may be appended to the ‘description` field.



81
82
83
# File 'lib/the_plaid_api/models/client_provided_transaction.rb', line 81

def location
  @location
end

#mccString

Merchant category codes (MCCs) are four-digit numbers that describe a merchant’s primary business activities.

Returns:

  • (String)


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

def mcc
  @mcc
end

#user_idString

The Plaid generated ID that identifies the end user for whom you would like to enrich transactions.

Returns:

  • (String)


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

def user_id
  @user_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  description = hash.key?('description') ? hash['description'] : nil
  amount = hash.key?('amount') ? hash['amount'] : nil
  direction = hash.key?('direction') ? hash['direction'] : nil
  iso_currency_code =
    hash.key?('iso_currency_code') ? hash['iso_currency_code'] : nil
  user_id = hash.key?('user_id') ? hash['user_id'] : SKIP
  client_user_id =
    hash.key?('client_user_id') ? hash['client_user_id'] : SKIP
   =
    hash.key?('client_account_id') ? hash['client_account_id'] : SKIP
   = hash.key?('account_type') ? hash['account_type'] : SKIP
   =
    hash.key?('account_subtype') ? hash['account_subtype'] : SKIP
  location = ClientProvidedTransactionLocation.from_hash(hash['location']) if hash['location']
  mcc = hash.key?('mcc') ? hash['mcc'] : SKIP
  date_posted = hash.key?('date_posted') ? hash['date_posted'] : 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.
  ClientProvidedTransaction.new(id: id,
                                description: description,
                                amount: amount,
                                direction: direction,
                                iso_currency_code: iso_currency_code,
                                user_id: user_id,
                                client_user_id: client_user_id,
                                client_account_id: ,
                                account_type: ,
                                account_subtype: ,
                                location: location,
                                mcc: mcc,
                                date_posted: date_posted,
                                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['user_id'] = 'user_id'
  @_hash['client_user_id'] = 'client_user_id'
  @_hash['client_account_id'] = 'client_account_id'
  @_hash['account_type'] = 'account_type'
  @_hash['account_subtype'] = 'account_subtype'
  @_hash['description'] = 'description'
  @_hash['amount'] = 'amount'
  @_hash['direction'] = 'direction'
  @_hash['iso_currency_code'] = 'iso_currency_code'
  @_hash['location'] = 'location'
  @_hash['mcc'] = 'mcc'
  @_hash['date_posted'] = 'date_posted'
  @_hash
end

.nullablesObject

An array for nullable fields



127
128
129
# File 'lib/the_plaid_api/models/client_provided_transaction.rb', line 127

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    user_id
    client_user_id
    client_account_id
    account_type
    account_subtype
    location
    mcc
    date_posted
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



212
213
214
215
216
217
218
219
220
221
# File 'lib/the_plaid_api/models/client_provided_transaction.rb', line 212

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, user_id: #{@user_id.inspect}, client_user_id:"\
  " #{@client_user_id.inspect}, client_account_id: #{@client_account_id.inspect},"\
  " account_type: #{@account_type.inspect}, account_subtype: #{@account_subtype.inspect},"\
  " description: #{@description.inspect}, amount: #{@amount.inspect}, direction:"\
  " #{@direction.inspect}, iso_currency_code: #{@iso_currency_code.inspect}, location:"\
  " #{@location.inspect}, mcc: #{@mcc.inspect}, date_posted: #{@date_posted.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



202
203
204
205
206
207
208
209
# File 'lib/the_plaid_api/models/client_provided_transaction.rb', line 202

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, user_id: #{@user_id}, client_user_id: #{@client_user_id},"\
  " client_account_id: #{@client_account_id}, account_type: #{@account_type}, account_subtype:"\
  " #{@account_subtype}, description: #{@description}, amount: #{@amount}, direction:"\
  " #{@direction}, iso_currency_code: #{@iso_currency_code}, location: #{@location}, mcc:"\
  " #{@mcc}, date_posted: #{@date_posted}, additional_properties: #{@additional_properties}>"
end