Class: ThePlaidApi::AccountBalance
- Defined in:
- lib/the_plaid_api/models/account_balance.rb
Overview
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` or `/signal/evaluate` (using a Balance-only ruleset).
Instance Attribute Summary collapse
-
#available ⇒ Float
The amount of funds available to be withdrawn from the account, as determined by the financial institution.
-
#current ⇒ Float
The total amount of funds in or owed by the account.
-
#iso_currency_code ⇒ String
The ISO-4217 currency code of the balance.
-
#last_updated_datetime ⇒ DateTime
Timestamp in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format (‘YYYY-MM-DDTHH:mm:ssZ`) indicating the last time the balance was updated.
-
#limit ⇒ Float
For ‘credit`-type accounts, this represents the credit limit.
-
#unofficial_currency_code ⇒ String
The unofficial currency code associated with the balance.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(available:, current:, limit:, iso_currency_code:, unofficial_currency_code:, last_updated_datetime: SKIP, additional_properties: nil) ⇒ AccountBalance
constructor
A new instance of AccountBalance.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_last_updated_datetime ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
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, additional_properties: nil) ⇒ AccountBalance
Returns a new instance of AccountBalance.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/the_plaid_api/models/account_balance.rb', line 123 def initialize(available:, current:, limit:, iso_currency_code:, unofficial_currency_code:, last_updated_datetime: 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 @additional_properties = additional_properties end |
Instance Attribute Details
#available ⇒ Float
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`, or by `/signal/evaluate` with a Balance-only ruleset. If `current` is `null` this field is guaranteed not to be `null`.
36 37 38 |
# File 'lib/the_plaid_api/models/account_balance.rb', line 36 def available @available end |
#current ⇒ Float
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. Similar to ‘credit`-type accounts, a positive balance is typically expected, while a negative amount indicates the lender owing the account holder. 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` or by `/signal/evaluate` with a Balance-only ruleset; 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` or `/signal/evaluate` called with a Balance-only `ruleset_key`. When returned by `/accounts/balance/get`, this field may be `null`. When this happens, `available` is guaranteed not to be `null`.
60 61 62 |
# File 'lib/the_plaid_api/models/account_balance.rb', line 60 def current @current end |
#iso_currency_code ⇒ String
The ISO-4217 currency code of the balance. Always null if ‘unofficial_currency_code` is non-null.
73 74 75 |
# File 'lib/the_plaid_api/models/account_balance.rb', line 73 def iso_currency_code @iso_currency_code end |
#last_updated_datetime ⇒ DateTime
Timestamp in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format (‘YYYY-MM-DDTHH:mm:ssZ`) indicating the last time the balance was updated. This field is returned only when the institution is `ins_128026` (Capital One).
90 91 92 |
# File 'lib/the_plaid_api/models/account_balance.rb', line 90 def last_updated_datetime @last_updated_datetime end |
#limit ⇒ Float
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.
68 69 70 |
# File 'lib/the_plaid_api/models/account_balance.rb', line 68 def limit @limit end |
#unofficial_currency_code ⇒ String
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.
83 84 85 |
# File 'lib/the_plaid_api/models/account_balance.rb', line 83 def unofficial_currency_code @unofficial_currency_code end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
139 140 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 |
# File 'lib/the_plaid_api/models/account_balance.rb', line 139 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 # 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. AccountBalance.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, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/the_plaid_api/models/account_balance.rb', line 93 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 end |
.nullables ⇒ Object
An array for nullable fields
112 113 114 115 116 117 118 119 120 121 |
# File 'lib/the_plaid_api/models/account_balance.rb', line 112 def self.nullables %w[ available current limit iso_currency_code unofficial_currency_code last_updated_datetime ] end |
.optionals ⇒ Object
An array for optional fields
105 106 107 108 109 |
# File 'lib/the_plaid_api/models/account_balance.rb', line 105 def self.optionals %w[ last_updated_datetime ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
187 188 189 190 191 192 193 |
# File 'lib/the_plaid_api/models/account_balance.rb', line 187 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}, additional_properties: #{@additional_properties}>" end |
#to_custom_last_updated_datetime ⇒ Object
173 174 175 |
# File 'lib/the_plaid_api/models/account_balance.rb', line 173 def to_custom_last_updated_datetime DateTimeHelper.to_rfc3339(last_updated_datetime) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
178 179 180 181 182 183 184 |
# File 'lib/the_plaid_api/models/account_balance.rb', line 178 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},"\ " additional_properties: #{@additional_properties}>" end |