Class: ThePlaidApi::AccountAssets

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

Overview

Asset information about an account

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(account_id:, balances:, mask:, name:, official_name:, type:, subtype:, days_available:, transactions:, owners:, historical_balances:, verification_status: SKIP, persistent_account_id: SKIP, investments: SKIP, ownership_type: SKIP, account_insights: SKIP, additional_properties: nil) ⇒ AccountAssets

Returns a new instance of AccountAssets.



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

def initialize(account_id:, balances:, mask:, name:, official_name:, type:,
               subtype:, days_available:, transactions:, owners:,
               historical_balances:, verification_status: SKIP,
               persistent_account_id: SKIP, investments: SKIP,
               ownership_type: SKIP, account_insights: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @account_id = 
  @balances = balances
  @mask = mask
  @name = name
  @official_name = official_name
  @type = type
  @subtype = subtype
  @verification_status = verification_status unless verification_status == SKIP
  @persistent_account_id =  unless  == SKIP
  @days_available = days_available
  @transactions = transactions
  @investments = investments unless investments == SKIP
  @owners = owners
  @ownership_type = ownership_type unless ownership_type == SKIP
  @historical_balances = historical_balances
  @account_insights =  unless  == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_idString

Plaid’s unique identifier for the account. This value will not change unless Plaid can’t reconcile the account with the data returned by the financial institution. This may occur, for example, when the name of the account changes. If this happens a new ‘account_id` will be assigned to the account. The `account_id` can also change if the `access_token` is deleted and the same credentials that were used to generate that `access_token` are used to generate a new `access_token` on a later date. In that case, the new `account_id` will be different from the old `account_id`. If an account with a specific `account_id` disappears instead of changing, the account is likely closed. Closed accounts are not returned by the Plaid API. Like all Plaid identifiers, the `account_id` is case sensitive.

Returns:

  • (String)


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

def 
  @account_id
end

#account_insightsAccountInsights

This is a container object for all lending-related insights. This field will be returned only for European customers.

Returns:



139
140
141
# File 'lib/the_plaid_api/models/account_assets.rb', line 139

def 
  @account_insights
end

#balancesAssetReportAccountBalance

A set of fields describing the balance for an account. Balance information may be cached unless the balance object was returned by ‘/accounts/balance/get`.



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

def balances
  @balances
end

#days_availableFloat

The duration of transaction history available within this report for this Item, typically defined as the time since the date of the earliest transaction in that account.

Returns:

  • (Float)


100
101
102
# File 'lib/the_plaid_api/models/account_assets.rb', line 100

def days_available
  @days_available
end

#historical_balancesArray[HistoricalBalance]

Calculated data about the historical balances on the account. Available for ‘credit` and `depository` type accounts.

Returns:



134
135
136
# File 'lib/the_plaid_api/models/account_assets.rb', line 134

def historical_balances
  @historical_balances
end

#investmentsAssetReportInvestments

A set of fields describing the investments data on an account.



108
109
110
# File 'lib/the_plaid_api/models/account_assets.rb', line 108

def investments
  @investments
end

#maskString

The last 2-4 alphanumeric characters of an account’s official account number. Note that the mask may be non-unique between an Item’s accounts, and it may also not match the mask that the bank displays to the user.

Returns:

  • (String)


38
39
40
# File 'lib/the_plaid_api/models/account_assets.rb', line 38

def mask
  @mask
end

#nameString

The name of the account, either assigned by the user or by the financial institution itself

Returns:

  • (String)


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

def name
  @name
end

#official_nameString

The official name of the account as given by the financial institution

Returns:

  • (String)


47
48
49
# File 'lib/the_plaid_api/models/account_assets.rb', line 47

def official_name
  @official_name
end

#ownersArray[Owner]

Data returned by the financial institution about the account owner or owners.For business accounts, the name reported may be either the name of the individual or the name of the business, depending on the institution. Multiple owners on a single account will be represented in the same ‘owner` object, not in multiple owner objects within the array. In API versions 2018-05-22 and earlier, the `owners` object is not returned, and instead identity information is returned in the top level `identity` object. For more details, see [Plaid API versioning](plaid.com/docs/api/versioning/#version-2019-05-29)

Returns:



120
121
122
# File 'lib/the_plaid_api/models/account_assets.rb', line 120

def owners
  @owners
end

#ownership_typeOwnershipType

How an asset is owned. ‘association`: Ownership by a corporation, partnership, or unincorporated association, including for-profit and not-for-profit organizations. `individual`: Ownership by an individual. `joint`: Joint ownership by multiple parties. `trust`: Ownership by a revocable or irrevocable trust.

Returns:



129
130
131
# File 'lib/the_plaid_api/models/account_assets.rb', line 129

def ownership_type
  @ownership_type
end

#persistent_account_idString

A unique and persistent identifier for accounts that can be used to trace multiple instances of the same account across different Items for depository accounts. This is currently an opt-in field and only supported for Chase Items.

Returns:

  • (String)


94
95
96
# File 'lib/the_plaid_api/models/account_assets.rb', line 94

def 
  @persistent_account_id
end

#subtypeAccountSubtype

See the [Account type schema](plaid.com/docs/api/accounts/#account-type-schema) for a full listing of account types and corresponding subtypes.

Returns:



65
66
67
# File 'lib/the_plaid_api/models/account_assets.rb', line 65

def subtype
  @subtype
end

#transactionsArray[AssetReportTransaction]

Transaction history associated with the account.

Returns:



104
105
106
# File 'lib/the_plaid_api/models/account_assets.rb', line 104

def transactions
  @transactions
end

#typeAccountType

‘investment:` Investment account. In API versions 2018-05-22 and earlier, this type is called `brokerage` instead. `credit:` Credit card `depository:` Depository account `loan:` Loan account `other:` Non-specified account type See the [Account type schema](plaid.com/docs/api/accounts#account-type-schema) for a full listing of account types and corresponding subtypes.

Returns:



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

def type
  @type
end

#verification_statusVerificationStatus4

The current verification status of an Auth Item initiated through Automated or Manual micro-deposits. Returned for Auth Items only. ‘pending_automatic_verification`: The Item is pending automatic verification `pending_manual_verification`: The Item is pending manual micro-deposit verification. Items remain in this state until the user successfully verifies the micro-deposit. `automatically_verified`: The Item has successfully been automatically verified `manually_verified`: The Item has successfully been manually verified `verification_expired`: Plaid was unable to automatically verify the deposit within 7 calendar days and will no longer attempt to validate the Item. Users may retry by submitting their information again through Link. `verification_failed`: The Item failed manual micro-deposit verification because the user exhausted all 3 verification attempts. Users may retry by submitting their information again through Link. `database_matched`: The Item has successfully been verified using Plaid’s data sources. Note: Database Match is currently a beta feature, please contact your account manager for more information.

Returns:



87
88
89
# File 'lib/the_plaid_api/models/account_assets.rb', line 87

def verification_status
  @verification_status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/the_plaid_api/models/account_assets.rb', line 214

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
   = hash.key?('account_id') ? hash['account_id'] : nil
  balances = AssetReportAccountBalance.from_hash(hash['balances']) if hash['balances']
  mask = hash.key?('mask') ? hash['mask'] : nil
  name = hash.key?('name') ? hash['name'] : nil
  official_name = hash.key?('official_name') ? hash['official_name'] : nil
  type = hash.key?('type') ? hash['type'] : nil
  subtype = hash.key?('subtype') ? hash['subtype'] : nil
  days_available =
    hash.key?('days_available') ? hash['days_available'] : nil
  # Parameter is an array, so we need to iterate through it
  transactions = nil
  unless hash['transactions'].nil?
    transactions = []
    hash['transactions'].each do |structure|
      transactions << (AssetReportTransaction.from_hash(structure) if structure)
    end
  end

  transactions = nil unless hash.key?('transactions')
  # Parameter is an array, so we need to iterate through it
  owners = nil
  unless hash['owners'].nil?
    owners = []
    hash['owners'].each do |structure|
      owners << (Owner.from_hash(structure) if structure)
    end
  end

  owners = nil unless hash.key?('owners')
  # Parameter is an array, so we need to iterate through it
  historical_balances = nil
  unless hash['historical_balances'].nil?
    historical_balances = []
    hash['historical_balances'].each do |structure|
      historical_balances << (HistoricalBalance.from_hash(structure) if structure)
    end
  end

  historical_balances = nil unless hash.key?('historical_balances')
  verification_status =
    hash.key?('verification_status') ? hash['verification_status'] : SKIP
   =
    hash.key?('persistent_account_id') ? hash['persistent_account_id'] : SKIP
  investments = AssetReportInvestments.from_hash(hash['investments']) if hash['investments']
  ownership_type =
    hash.key?('ownership_type') ? hash['ownership_type'] : SKIP
   = AccountInsights.from_hash(hash['account_insights']) if
    hash['account_insights']

  # 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.
  AccountAssets.new(account_id: ,
                    balances: balances,
                    mask: mask,
                    name: name,
                    official_name: official_name,
                    type: type,
                    subtype: subtype,
                    days_available: days_available,
                    transactions: transactions,
                    owners: owners,
                    historical_balances: historical_balances,
                    verification_status: verification_status,
                    persistent_account_id: ,
                    investments: investments,
                    ownership_type: ownership_type,
                    account_insights: ,
                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['account_id'] = 'account_id'
  @_hash['balances'] = 'balances'
  @_hash['mask'] = 'mask'
  @_hash['name'] = 'name'
  @_hash['official_name'] = 'official_name'
  @_hash['type'] = 'type'
  @_hash['subtype'] = 'subtype'
  @_hash['verification_status'] = 'verification_status'
  @_hash['persistent_account_id'] = 'persistent_account_id'
  @_hash['days_available'] = 'days_available'
  @_hash['transactions'] = 'transactions'
  @_hash['investments'] = 'investments'
  @_hash['owners'] = 'owners'
  @_hash['ownership_type'] = 'ownership_type'
  @_hash['historical_balances'] = 'historical_balances'
  @_hash['account_insights'] = 'account_insights'
  @_hash
end

.nullablesObject

An array for nullable fields



175
176
177
178
179
180
181
182
183
# File 'lib/the_plaid_api/models/account_assets.rb', line 175

def self.nullables
  %w[
    mask
    official_name
    subtype
    ownership_type
    account_insights
  ]
end

.optionalsObject

An array for optional fields



164
165
166
167
168
169
170
171
172
# File 'lib/the_plaid_api/models/account_assets.rb', line 164

def self.optionals
  %w[
    verification_status
    persistent_account_id
    investments
    ownership_type
    account_insights
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/the_plaid_api/models/account_assets.rb', line 307

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} account_id: #{@account_id.inspect}, balances: #{@balances.inspect}, mask:"\
  " #{@mask.inspect}, name: #{@name.inspect}, official_name: #{@official_name.inspect}, type:"\
  " #{@type.inspect}, subtype: #{@subtype.inspect}, verification_status:"\
  " #{@verification_status.inspect}, persistent_account_id: #{@persistent_account_id.inspect},"\
  " days_available: #{@days_available.inspect}, transactions: #{@transactions.inspect},"\
  " investments: #{@investments.inspect}, owners: #{@owners.inspect}, ownership_type:"\
  " #{@ownership_type.inspect}, historical_balances: #{@historical_balances.inspect},"\
  " account_insights: #{@account_insights.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



295
296
297
298
299
300
301
302
303
304
# File 'lib/the_plaid_api/models/account_assets.rb', line 295

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} account_id: #{@account_id}, balances: #{@balances}, mask: #{@mask}, name:"\
  " #{@name}, official_name: #{@official_name}, type: #{@type}, subtype: #{@subtype},"\
  " verification_status: #{@verification_status}, persistent_account_id:"\
  " #{@persistent_account_id}, days_available: #{@days_available}, transactions:"\
  " #{@transactions}, investments: #{@investments}, owners: #{@owners}, ownership_type:"\
  " #{@ownership_type}, historical_balances: #{@historical_balances}, account_insights:"\
  " #{@account_insights}, additional_properties: #{@additional_properties}>"
end