Class: ThePlaidApi::BaseReportAccountBalances

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

Overview

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:, limit:, iso_currency_code:, unofficial_currency_code:, last_updated_datetime: SKIP, average_balance: SKIP, average_monthly_balances: SKIP, most_recent_thirty_day_average_balance: SKIP, additional_properties: nil) ⇒ BaseReportAccountBalances

Returns a new instance of BaseReportAccountBalances.



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/the_plaid_api/models/base_report_account_balances.rb', line 147

def initialize(available:, current:, limit:, iso_currency_code:,
               unofficial_currency_code:, last_updated_datetime: SKIP,
               average_balance: SKIP, average_monthly_balances: SKIP,
               most_recent_thirty_day_average_balance: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @available = available
  @current = current
  @limit = limit
  @iso_currency_code = iso_currency_code
  @unofficial_currency_code = unofficial_currency_code
  @last_updated_datetime = last_updated_datetime unless last_updated_datetime == SKIP
  @average_balance = average_balance unless average_balance == SKIP
  @average_monthly_balances = average_monthly_balances unless average_monthly_balances == SKIP
  unless most_recent_thirty_day_average_balance == SKIP
    @most_recent_thirty_day_average_balance =
      most_recent_thirty_day_average_balance
  end
  @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)


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

def available
  @available
end

#average_balanceFloat

The average historical balance for the entire report

Returns:

  • (Float)


97
98
99
# File 'lib/the_plaid_api/models/base_report_account_balances.rb', line 97

def average_balance
  @average_balance
end

#average_monthly_balancesArray[BaseReportAverageMonthlyBalances]

The average historical balance of each calendar month



101
102
103
# File 'lib/the_plaid_api/models/base_report_account_balances.rb', line 101

def average_monthly_balances
  @average_monthly_balances
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)


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

def current
  @current
end

#iso_currency_codeString

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

Returns:

  • (String)


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

def iso_currency_code
  @iso_currency_code
end

#last_updated_datetimeDateTime

Timestamp in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format (‘YYYY-MM-DDTHH:mm:ssZ`) indicating the oldest acceptable balance when making a request to `/accounts/balance/get`. This field is only used and expected when the institution is `ins_128026` (Capital One) and the Item contains one or more accounts with a non-depository account type, in which case a value must be provided or an `INVALID_REQUEST` error with the code of `INVALID_FIELD` will be returned. For Capital One depository accounts as well as all other account types on all other institutions, this field is ignored. See [account type schema](plaid.com/docs/api/accounts/#account-type-schema) for a full list of account types. If the balance that is pulled is older than the given timestamp for Items with this field required, an `INVALID_REQUEST` error with the code of `LAST_UPDATED_DATETIME_OUT_OF_RANGE` will be returned with the most recent timestamp for the requested account contained in the response.

Returns:

  • (DateTime)


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

def last_updated_datetime
  @last_updated_datetime
end

#limitFloat

For ‘credit`-type accounts, this represents the credit limit. For `depository`-type accounts, this represents the pre-arranged overdraft limit, which is common for current (checking) accounts in Europe. In North America, this field is typically only available for `credit`-type accounts.

Returns:

  • (Float)


60
61
62
# File 'lib/the_plaid_api/models/base_report_account_balances.rb', line 60

def limit
  @limit
end

#most_recent_thirty_day_average_balanceFloat

The average historical balance from the most recent 30 days

Returns:

  • (Float)


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

def most_recent_thirty_day_average_balance
  @most_recent_thirty_day_average_balance
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)


75
76
77
# File 'lib/the_plaid_api/models/base_report_account_balances.rb', line 75

def unofficial_currency_code
  @unofficial_currency_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
218
219
220
# File 'lib/the_plaid_api/models/base_report_account_balances.rb', line 171

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
  limit = hash.key?('limit') ? hash['limit'] : 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
  last_updated_datetime = if hash.key?('last_updated_datetime')
                            (DateTimeHelper.from_rfc3339(hash['last_updated_datetime']) if hash['last_updated_datetime'])
                          else
                            SKIP
                          end
  average_balance =
    hash.key?('average_balance') ? hash['average_balance'] : SKIP
  # Parameter is an array, so we need to iterate through it
  average_monthly_balances = nil
  unless hash['average_monthly_balances'].nil?
    average_monthly_balances = []
    hash['average_monthly_balances'].each do |structure|
      average_monthly_balances << (BaseReportAverageMonthlyBalances.from_hash(structure) if structure)
    end
  end

  average_monthly_balances = SKIP unless hash.key?('average_monthly_balances')
  most_recent_thirty_day_average_balance =
    hash.key?('most_recent_thirty_day_average_balance') ? hash['most_recent_thirty_day_average_balance'] : 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.
  BaseReportAccountBalances.new(available: available,
                                current: current,
                                limit: limit,
                                iso_currency_code: iso_currency_code,
                                unofficial_currency_code: unofficial_currency_code,
                                last_updated_datetime: last_updated_datetime,
                                average_balance: average_balance,
                                average_monthly_balances: average_monthly_balances,
                                most_recent_thirty_day_average_balance: most_recent_thirty_day_average_balance,
                                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/the_plaid_api/models/base_report_account_balances.rb', line 108

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['available'] = 'available'
  @_hash['current'] = 'current'
  @_hash['limit'] = 'limit'
  @_hash['iso_currency_code'] = 'iso_currency_code'
  @_hash['unofficial_currency_code'] = 'unofficial_currency_code'
  @_hash['last_updated_datetime'] = 'last_updated_datetime'
  @_hash['average_balance'] = 'average_balance'
  @_hash['average_monthly_balances'] = 'average_monthly_balances'
  @_hash['most_recent_thirty_day_average_balance'] =
    'most_recent_thirty_day_average_balance'
  @_hash
end

.nullablesObject

An array for nullable fields



134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/the_plaid_api/models/base_report_account_balances.rb', line 134

def self.nullables
  %w[
    available
    current
    limit
    iso_currency_code
    unofficial_currency_code
    last_updated_datetime
    average_balance
    most_recent_thirty_day_average_balance
  ]
end

.optionalsObject

An array for optional fields



124
125
126
127
128
129
130
131
# File 'lib/the_plaid_api/models/base_report_account_balances.rb', line 124

def self.optionals
  %w[
    last_updated_datetime
    average_balance
    average_monthly_balances
    most_recent_thirty_day_average_balance
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



239
240
241
242
243
244
245
246
247
248
249
# File 'lib/the_plaid_api/models/base_report_account_balances.rb', line 239

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} available: #{@available.inspect}, current: #{@current.inspect}, limit:"\
  " #{@limit.inspect}, iso_currency_code: #{@iso_currency_code.inspect},"\
  " unofficial_currency_code: #{@unofficial_currency_code.inspect}, last_updated_datetime:"\
  " #{@last_updated_datetime.inspect}, average_balance: #{@average_balance.inspect},"\
  " average_monthly_balances: #{@average_monthly_balances.inspect},"\
  ' most_recent_thirty_day_average_balance:'\
  " #{@most_recent_thirty_day_average_balance.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_custom_last_updated_datetimeObject



222
223
224
# File 'lib/the_plaid_api/models/base_report_account_balances.rb', line 222

def to_custom_last_updated_datetime
  DateTimeHelper.to_rfc3339(last_updated_datetime)
end

#to_sObject

Provides a human-readable string representation of the object.



227
228
229
230
231
232
233
234
235
236
# File 'lib/the_plaid_api/models/base_report_account_balances.rb', line 227

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} available: #{@available}, current: #{@current}, limit: #{@limit},"\
  " iso_currency_code: #{@iso_currency_code}, unofficial_currency_code:"\
  " #{@unofficial_currency_code}, last_updated_datetime: #{@last_updated_datetime},"\
  " average_balance: #{@average_balance}, average_monthly_balances:"\
  " #{@average_monthly_balances}, most_recent_thirty_day_average_balance:"\
  " #{@most_recent_thirty_day_average_balance}, additional_properties:"\
  " #{@additional_properties}>"
end