Class: Plaid::AccountBalance
- Defined in:
- lib/plaid/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`.
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](wikipedia.org/wiki/ISO_8601) format (‘YYYY-MM-DDTHH:mm:ssZ`) indicating the last time that the balance for the given account has been updated This is currently only provided when the `min_last_updated_datetime` is passed when calling `/accounts/balance/get` for `ins_128026` (Capital One).
-
#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.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/plaid/models/account_balance.rb', line 117 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, 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`.
33 34 35 |
# File 'lib/plaid/models/account_balance.rb', line 33 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. For ‘investment`-type accounts, 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`.
52 53 54 |
# File 'lib/plaid/models/account_balance.rb', line 52 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.
65 66 67 |
# File 'lib/plaid/models/account_balance.rb', line 65 def iso_currency_code @iso_currency_code end |
#last_updated_datetime ⇒ DateTime
Timestamp in [ISO 8601](wikipedia.org/wiki/ISO_8601) format (‘YYYY-MM-DDTHH:mm:ssZ`) indicating the last time that the balance for the given account has been updated This is currently only provided when the `min_last_updated_datetime` is passed when calling `/accounts/balance/get` for `ins_128026` (Capital One).
84 85 86 |
# File 'lib/plaid/models/account_balance.rb', line 84 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.
60 61 62 |
# File 'lib/plaid/models/account_balance.rb', line 60 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.
75 76 77 |
# File 'lib/plaid/models/account_balance.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.
133 134 135 136 137 138 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 |
# File 'lib/plaid/models/account_balance.rb', line 133 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.
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/plaid/models/account_balance.rb', line 87 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
106 107 108 109 110 111 112 113 114 115 |
# File 'lib/plaid/models/account_balance.rb', line 106 def self.nullables %w[ available current limit iso_currency_code unofficial_currency_code last_updated_datetime ] end |
.optionals ⇒ Object
An array for optional fields
99 100 101 102 103 |
# File 'lib/plaid/models/account_balance.rb', line 99 def self.optionals %w[ last_updated_datetime ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
181 182 183 184 185 186 187 |
# File 'lib/plaid/models/account_balance.rb', line 181 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
167 168 169 |
# File 'lib/plaid/models/account_balance.rb', line 167 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.
172 173 174 175 176 177 178 |
# File 'lib/plaid/models/account_balance.rb', line 172 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 |