Class: ThePlaidApi::CraVoaReportAccountBalances

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

Overview

VOA Report information about an account’s balances.

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(available:, current:, iso_currency_code:, unofficial_currency_code:, historical_balances:, average_balance_30_days:, average_balance_60_days:, nsf_overdraft_transactions_count:, additional_properties: nil) ⇒ CraVoaReportAccountBalances

Returns a new instance of CraVoaReportAccountBalances.



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/the_plaid_api/models/cra_voa_report_account_balances.rb', line 121

def initialize(available:, current:, iso_currency_code:,
               unofficial_currency_code:, historical_balances:,
               average_balance_30_days:, average_balance_60_days:,
               nsf_overdraft_transactions_count:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @available = available
  @current = current
  @iso_currency_code = iso_currency_code
  @unofficial_currency_code = unofficial_currency_code
  @historical_balances = historical_balances
  @average_balance_30_days = average_balance_30_days
  @average_balance_60_days = average_balance_60_days
  @nsf_overdraft_transactions_count = nsf_overdraft_transactions_count
  @additional_properties = additional_properties
end

Instance Attribute Details

#availableFloat

The amount of funds available to be withdrawn from the account, as determined by the financial institution. For ‘credit`-type accounts, the `available` balance typically equals the `limit` less the `current` balance, less any pending outflows plus any pending inflows. For `depository`-type accounts, the `available` balance typically equals the `current` balance less any pending outflows plus any pending inflows. For `depository`-type accounts, the `available` balance does not include the overdraft limit. For `investment`-type accounts (or `brokerage`-type accounts for API versions 2018-05-22 and earlier), the `available` balance is the total cash available to withdraw as presented by the institution. Note that not all institutions calculate the `available` balance. In the event that `available` balance is unavailable, Plaid will return an `available` balance value of `null`. Available balance may be cached and is not guaranteed to be up-to-date in realtime unless the value was returned by `/accounts/balance/get`. If `current` is `null` this field is guaranteed not to be `null`.

Returns:

  • (Float)


31
32
33
# File 'lib/the_plaid_api/models/cra_voa_report_account_balances.rb', line 31

def available
  @available
end

#average_balance_30_daysFloat

The average balance in the account over the last 30 days. Calculated using the derived historical balances.

Returns:

  • (Float)


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

def average_balance_30_days
  @average_balance_30_days
end

#average_balance_60_daysFloat

The average balance in the account over the last 60 days. Calculated using the derived historical balances.

Returns:

  • (Float)


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

def average_balance_60_days
  @average_balance_60_days
end

#currentFloat

The total amount of funds in or owed by the account. For ‘credit`-type accounts, a positive balance indicates the amount owed; a negative amount indicates the lender owing the account holder. For `loan`-type accounts, the current balance is the principal remaining on the loan, except in the case of student loan accounts at Sallie Mae (`ins_116944`). For Sallie Mae student loans, the account’s balance includes both principal and any outstanding interest. For ‘investment`-type accounts (or `brokerage`-type accounts for API versions 2018-05-22 and earlier), the current balance is the total value of assets as presented by the institution. Note that balance information may be cached unless the value was returned by `/accounts/balance/get`; if the Item is enabled for Transactions, the balance will be at least as recent as the most recent Transaction update. If you require realtime balance information, use the `available` balance as provided by `/accounts/balance/get`. When returned by `/accounts/balance/get`, this field may be `null`. When this happens, `available` is guaranteed not to be `null`.

Returns:

  • (Float)


51
52
53
# File 'lib/the_plaid_api/models/cra_voa_report_account_balances.rb', line 51

def current
  @current
end

#historical_balancesArray[CraVoaReportAccountHistoricalBalance]

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



71
72
73
# File 'lib/the_plaid_api/models/cra_voa_report_account_balances.rb', line 71

def historical_balances
  @historical_balances
end

#iso_currency_codeString

The ISO-4217 currency code of the balance. Always null if ‘unofficial_currency_code` is non-null.

Returns:

  • (String)


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

def iso_currency_code
  @iso_currency_code
end

#nsf_overdraft_transactions_countFloat

The number of net NSF fee transactions in the time range for the report in the given account (not counting any fees that were reversed within the time range).

Returns:

  • (Float)


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

def nsf_overdraft_transactions_count
  @nsf_overdraft_transactions_count
end

#unofficial_currency_codeString

The unofficial currency code associated with the balance. Always null if ‘iso_currency_code` is non-null. Unofficial currency codes are used for currencies that do not have official ISO currency codes, such as cryptocurrencies and the currencies of certain countries. See the [currency code schema](plaid.com/docs/api/accounts#currency-code-schema) for a full listing of supported `unofficial_currency_code`s.

Returns:

  • (String)


66
67
68
# File 'lib/the_plaid_api/models/cra_voa_report_account_balances.rb', line 66

def unofficial_currency_code
  @unofficial_currency_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



141
142
143
144
145
146
147
148
149
150
151
152
153
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
# File 'lib/the_plaid_api/models/cra_voa_report_account_balances.rb', line 141

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  available = hash.key?('available') ? hash['available'] : nil
  current = hash.key?('current') ? hash['current'] : nil
  iso_currency_code =
    hash.key?('iso_currency_code') ? hash['iso_currency_code'] : nil
  unofficial_currency_code =
    hash.key?('unofficial_currency_code') ? hash['unofficial_currency_code'] : nil
  # 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 << (CraVoaReportAccountHistoricalBalance.from_hash(structure) if structure)
    end
  end

  historical_balances = nil unless hash.key?('historical_balances')
  average_balance_30_days =
    hash.key?('average_balance_30_days') ? hash['average_balance_30_days'] : nil
  average_balance_60_days =
    hash.key?('average_balance_60_days') ? hash['average_balance_60_days'] : nil
  nsf_overdraft_transactions_count =
    hash.key?('nsf_overdraft_transactions_count') ? hash['nsf_overdraft_transactions_count'] : nil

  # 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.
  CraVoaReportAccountBalances.new(available: available,
                                  current: current,
                                  iso_currency_code: iso_currency_code,
                                  unofficial_currency_code: unofficial_currency_code,
                                  historical_balances: historical_balances,
                                  average_balance_30_days: average_balance_30_days,
                                  average_balance_60_days: average_balance_60_days,
                                  nsf_overdraft_transactions_count: nsf_overdraft_transactions_count,
                                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/the_plaid_api/models/cra_voa_report_account_balances.rb', line 90

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['available'] = 'available'
  @_hash['current'] = 'current'
  @_hash['iso_currency_code'] = 'iso_currency_code'
  @_hash['unofficial_currency_code'] = 'unofficial_currency_code'
  @_hash['historical_balances'] = 'historical_balances'
  @_hash['average_balance_30_days'] = 'average_balance_30_days'
  @_hash['average_balance_60_days'] = 'average_balance_60_days'
  @_hash['nsf_overdraft_transactions_count'] =
    'nsf_overdraft_transactions_count'
  @_hash
end

.nullablesObject

An array for nullable fields



110
111
112
113
114
115
116
117
118
119
# File 'lib/the_plaid_api/models/cra_voa_report_account_balances.rb', line 110

def self.nullables
  %w[
    available
    current
    iso_currency_code
    unofficial_currency_code
    average_balance_30_days
    average_balance_60_days
  ]
end

.optionalsObject

An array for optional fields



105
106
107
# File 'lib/the_plaid_api/models/cra_voa_report_account_balances.rb', line 105

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



199
200
201
202
203
204
205
206
207
208
209
# File 'lib/the_plaid_api/models/cra_voa_report_account_balances.rb', line 199

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} available: #{@available.inspect}, current: #{@current.inspect},"\
  " iso_currency_code: #{@iso_currency_code.inspect}, unofficial_currency_code:"\
  " #{@unofficial_currency_code.inspect}, historical_balances:"\
  " #{@historical_balances.inspect}, average_balance_30_days:"\
  " #{@average_balance_30_days.inspect}, average_balance_60_days:"\
  " #{@average_balance_60_days.inspect}, nsf_overdraft_transactions_count:"\
  " #{@nsf_overdraft_transactions_count.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



188
189
190
191
192
193
194
195
196
# File 'lib/the_plaid_api/models/cra_voa_report_account_balances.rb', line 188

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} available: #{@available}, current: #{@current}, iso_currency_code:"\
  " #{@iso_currency_code}, unofficial_currency_code: #{@unofficial_currency_code},"\
  " historical_balances: #{@historical_balances}, average_balance_30_days:"\
  " #{@average_balance_30_days}, average_balance_60_days: #{@average_balance_60_days},"\
  " nsf_overdraft_transactions_count: #{@nsf_overdraft_transactions_count},"\
  " additional_properties: #{@additional_properties}>"
end