Class: ThePlaidApi::OverrideAccounts

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

Overview

Data to use to set values of test accounts. Some values cannot be specified in the schema and will instead will be calculated from other test data in order to achieve more consistent, realistic test data.

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(type:, subtype:, starting_balance:, force_available_balance:, has_null_available_balance:, currency:, meta:, numbers:, transactions:, identity:, liability:, inflow_model:, holdings: SKIP, investment_transactions: SKIP, income: SKIP, additional_properties: nil) ⇒ OverrideAccounts

Returns a new instance of OverrideAccounts.



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

def initialize(type:, subtype:, starting_balance:, force_available_balance:,
               has_null_available_balance:, currency:, meta:, numbers:,
               transactions:, identity:, liability:, inflow_model:,
               holdings: SKIP, investment_transactions: SKIP, income: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @type = type
  @subtype = subtype
  @starting_balance = starting_balance
  @force_available_balance = force_available_balance
  @has_null_available_balance = has_null_available_balance
  @currency = currency
  @meta = meta
  @numbers = numbers
  @transactions = transactions
  @holdings = holdings unless holdings == SKIP
  @investment_transactions = investment_transactions unless investment_transactions == SKIP
  @identity = identity
  @liability = liability
  @inflow_model = inflow_model
  @income = income unless income == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#currencyString

ISO-4217 currency code. If provided, the account will be denominated in the given currency. Transactions will also be in this currency by default.

Returns:

  • (String)


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

def currency
  @currency
end

#force_available_balanceFloat

If provided, the account will always have this amount as its available balance, regardless of current balance or changes in transactions over time. Cannot be set together with ‘has_null_available_balance`.

Returns:

  • (Float)


41
42
43
# File 'lib/the_plaid_api/models/override_accounts.rb', line 41

def force_available_balance
  @force_available_balance
end

#has_null_available_balanceTrueClass | FalseClass

If set to ‘true`, the account will always have null as its available balance, regardless of current balance or changes in transactions over time. Cannot be set together with `force_available_balance`.

Returns:

  • (TrueClass | FalseClass)


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

def has_null_available_balance
  @has_null_available_balance
end

#holdingsHoldingsOverride

Specify the holdings on the account.

Returns:



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

def holdings
  @holdings
end

#identityOwnerOverride

Data about the owner or owners of an account. Any fields not specified will be filled in with default Sandbox information.

Returns:



78
79
80
# File 'lib/the_plaid_api/models/override_accounts.rb', line 78

def identity
  @identity
end

#incomeIncomeOverride

Specify payroll data on the account.

Returns:



93
94
95
# File 'lib/the_plaid_api/models/override_accounts.rb', line 93

def income
  @income
end

#inflow_modelInflowModel

The ‘inflow_model` allows you to model a test account that receives regular income or make regular payments on a loan. Any transactions generated by the `inflow_model` will appear in addition to randomly generated test data or transactions specified by `override_accounts`.

Returns:



89
90
91
# File 'lib/the_plaid_api/models/override_accounts.rb', line 89

def inflow_model
  @inflow_model
end

#investment_transactionsInvestmentsTransactionsOverride

Specify the list of investments transactions on the account.



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

def investment_transactions
  @investment_transactions
end

#liabilityLiabilityOverride

Used to configure Sandbox test data for the Liabilities product

Returns:



82
83
84
# File 'lib/the_plaid_api/models/override_accounts.rb', line 82

def liability
  @liability
end

#metaMeta

Allows specifying the metadata of the test account

Returns:



56
57
58
# File 'lib/the_plaid_api/models/override_accounts.rb', line 56

def meta
  @meta
end

#numbersNumbers

Account and bank identifier number data used to configure the test account. All values are optional.

Returns:



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

def numbers
  @numbers
end

#starting_balanceFloat

If provided, the account will start with this amount as the current balance.

Returns:

  • (Float)


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

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



30
31
32
# File 'lib/the_plaid_api/models/override_accounts.rb', line 30

def subtype
  @subtype
end

#transactionsArray[TransactionOverride]

Specify the list of transactions on the account.

Returns:



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

def transactions
  @transactions
end

#typeOverrideAccountType

‘investment:` Investment account. `credit:` Credit card `depository:` Depository account `loan:` Loan account `payroll:` Payroll 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:



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

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/the_plaid_api/models/override_accounts.rb', line 159

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  type = hash.key?('type') ? hash['type'] : nil
  subtype = hash.key?('subtype') ? hash['subtype'] : nil
  starting_balance =
    hash.key?('starting_balance') ? hash['starting_balance'] : nil
  force_available_balance =
    hash.key?('force_available_balance') ? hash['force_available_balance'] : nil
  has_null_available_balance =
    hash.key?('has_null_available_balance') ? hash['has_null_available_balance'] : nil
  currency = hash.key?('currency') ? hash['currency'] : nil
  meta = Meta.from_hash(hash['meta']) if hash['meta']
  numbers = Numbers.from_hash(hash['numbers']) if hash['numbers']
  # Parameter is an array, so we need to iterate through it
  transactions = nil
  unless hash['transactions'].nil?
    transactions = []
    hash['transactions'].each do |structure|
      transactions << (TransactionOverride.from_hash(structure) if structure)
    end
  end

  transactions = nil unless hash.key?('transactions')
  identity = OwnerOverride.from_hash(hash['identity']) if hash['identity']
  liability = LiabilityOverride.from_hash(hash['liability']) if hash['liability']
  inflow_model = InflowModel.from_hash(hash['inflow_model']) if hash['inflow_model']
  holdings = HoldingsOverride.from_hash(hash['holdings']) if hash['holdings']
  if hash['investment_transactions']
    investment_transactions = InvestmentsTransactionsOverride.from_hash(hash['investment_transactions'])
  end
  income = IncomeOverride.from_hash(hash['income']) if hash['income']

  # 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.
  OverrideAccounts.new(type: type,
                       subtype: subtype,
                       starting_balance: starting_balance,
                       force_available_balance: force_available_balance,
                       has_null_available_balance: has_null_available_balance,
                       currency: currency,
                       meta: meta,
                       numbers: numbers,
                       transactions: transactions,
                       identity: identity,
                       liability: liability,
                       inflow_model: inflow_model,
                       holdings: holdings,
                       investment_transactions: investment_transactions,
                       income: income,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['type'] = 'type'
  @_hash['subtype'] = 'subtype'
  @_hash['starting_balance'] = 'starting_balance'
  @_hash['force_available_balance'] = 'force_available_balance'
  @_hash['has_null_available_balance'] = 'has_null_available_balance'
  @_hash['currency'] = 'currency'
  @_hash['meta'] = 'meta'
  @_hash['numbers'] = 'numbers'
  @_hash['transactions'] = 'transactions'
  @_hash['holdings'] = 'holdings'
  @_hash['investment_transactions'] = 'investment_transactions'
  @_hash['identity'] = 'identity'
  @_hash['liability'] = 'liability'
  @_hash['inflow_model'] = 'inflow_model'
  @_hash['income'] = 'income'
  @_hash
end

.nullablesObject

An array for nullable fields



126
127
128
129
130
# File 'lib/the_plaid_api/models/override_accounts.rb', line 126

def self.nullables
  %w[
    subtype
  ]
end

.optionalsObject

An array for optional fields



117
118
119
120
121
122
123
# File 'lib/the_plaid_api/models/override_accounts.rb', line 117

def self.optionals
  %w[
    holdings
    investment_transactions
    income
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/the_plaid_api/models/override_accounts.rb', line 232

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} type: #{@type.inspect}, subtype: #{@subtype.inspect}, starting_balance:"\
  " #{@starting_balance.inspect}, force_available_balance:"\
  " #{@force_available_balance.inspect}, has_null_available_balance:"\
  " #{@has_null_available_balance.inspect}, currency: #{@currency.inspect}, meta:"\
  " #{@meta.inspect}, numbers: #{@numbers.inspect}, transactions: #{@transactions.inspect},"\
  " holdings: #{@holdings.inspect}, investment_transactions:"\
  " #{@investment_transactions.inspect}, identity: #{@identity.inspect}, liability:"\
  " #{@liability.inspect}, inflow_model: #{@inflow_model.inspect}, income: #{@income.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



220
221
222
223
224
225
226
227
228
229
# File 'lib/the_plaid_api/models/override_accounts.rb', line 220

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} type: #{@type}, subtype: #{@subtype}, starting_balance:"\
  " #{@starting_balance}, force_available_balance: #{@force_available_balance},"\
  " has_null_available_balance: #{@has_null_available_balance}, currency: #{@currency}, meta:"\
  " #{@meta}, numbers: #{@numbers}, transactions: #{@transactions}, holdings: #{@holdings},"\
  " investment_transactions: #{@investment_transactions}, identity: #{@identity}, liability:"\
  " #{@liability}, inflow_model: #{@inflow_model}, income: #{@income}, additional_properties:"\
  " #{@additional_properties}>"
end