Class: YNAB::Account
- Inherits:
-
Object
- Object
- YNAB::Account
- Defined in:
- lib/ynab/models/account.rb
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#balance ⇒ Object
The current balance of the account in milliunits format.
-
#cleared_balance ⇒ Object
The current cleared balance of the account in milliunits format.
-
#closed ⇒ Object
Whether this account is closed or not.
-
#debt_escrow_amounts ⇒ Object
Returns the value of attribute debt_escrow_amounts.
-
#debt_interest_rates ⇒ Object
Returns the value of attribute debt_interest_rates.
-
#debt_minimum_payments ⇒ Object
Returns the value of attribute debt_minimum_payments.
-
#debt_original_balance ⇒ Object
The original debt/loan account balance, specified in milliunits format.
-
#deleted ⇒ Object
Whether or not the account has been deleted.
-
#direct_import_in_error ⇒ Object
If an account linked to a financial institution (direct_import_linked=true) and the linked connection is not in a healthy state, this will be true.
-
#direct_import_linked ⇒ Object
Whether or not the account is linked to a financial institution for automatic transaction import.
-
#id ⇒ Object
Returns the value of attribute id.
-
#last_reconciled_at ⇒ Object
A date/time specifying when the account was last reconciled.
-
#name ⇒ Object
Returns the value of attribute name.
-
#note ⇒ Object
Returns the value of attribute note.
-
#on_budget ⇒ Object
Whether this account is on budget or not.
-
#transfer_payee_id ⇒ Object
The payee id which should be used when transferring to this account.
-
#type ⇒ Object
Returns the value of attribute type.
-
#uncleared_balance ⇒ Object
The current uncleared balance of the account in milliunits format.
Class Method Summary collapse
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
-
#build_from_hash(attributes) ⇒ Object
Builds the object from hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ Account
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ Account
Initializes the object
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 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 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/ynab/models/account.rb', line 155 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `YNAB::Account` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `YNAB::Account`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'id') self.id = attributes[:'id'] end if attributes.key?(:'name') self.name = attributes[:'name'] end if attributes.key?(:'type') self.type = attributes[:'type'] end if attributes.key?(:'on_budget') self.on_budget = attributes[:'on_budget'] end if attributes.key?(:'closed') self.closed = attributes[:'closed'] end if attributes.key?(:'note') self.note = attributes[:'note'] end if attributes.key?(:'balance') self.balance = attributes[:'balance'] end if attributes.key?(:'cleared_balance') self.cleared_balance = attributes[:'cleared_balance'] end if attributes.key?(:'uncleared_balance') self.uncleared_balance = attributes[:'uncleared_balance'] end if attributes.key?(:'transfer_payee_id') self.transfer_payee_id = attributes[:'transfer_payee_id'] end if attributes.key?(:'direct_import_linked') self.direct_import_linked = attributes[:'direct_import_linked'] end if attributes.key?(:'direct_import_in_error') self.direct_import_in_error = attributes[:'direct_import_in_error'] end if attributes.key?(:'last_reconciled_at') self.last_reconciled_at = attributes[:'last_reconciled_at'] end if attributes.key?(:'debt_original_balance') self.debt_original_balance = attributes[:'debt_original_balance'] end if attributes.key?(:'debt_interest_rates') if (value = attributes[:'debt_interest_rates']).is_a?(Hash) self.debt_interest_rates = value end end if attributes.key?(:'debt_minimum_payments') if (value = attributes[:'debt_minimum_payments']).is_a?(Hash) self.debt_minimum_payments = value end end if attributes.key?(:'debt_escrow_amounts') if (value = attributes[:'debt_escrow_amounts']).is_a?(Hash) self.debt_escrow_amounts = value end end if attributes.key?(:'deleted') self.deleted = attributes[:'deleted'] end end |
Instance Attribute Details
#balance ⇒ Object
The current balance of the account in milliunits format
33 34 35 |
# File 'lib/ynab/models/account.rb', line 33 def balance @balance end |
#cleared_balance ⇒ Object
The current cleared balance of the account in milliunits format
36 37 38 |
# File 'lib/ynab/models/account.rb', line 36 def cleared_balance @cleared_balance end |
#closed ⇒ Object
Whether this account is closed or not
28 29 30 |
# File 'lib/ynab/models/account.rb', line 28 def closed @closed end |
#debt_escrow_amounts ⇒ Object
Returns the value of attribute debt_escrow_amounts.
60 61 62 |
# File 'lib/ynab/models/account.rb', line 60 def debt_escrow_amounts @debt_escrow_amounts end |
#debt_interest_rates ⇒ Object
Returns the value of attribute debt_interest_rates.
56 57 58 |
# File 'lib/ynab/models/account.rb', line 56 def debt_interest_rates @debt_interest_rates end |
#debt_minimum_payments ⇒ Object
Returns the value of attribute debt_minimum_payments.
58 59 60 |
# File 'lib/ynab/models/account.rb', line 58 def debt_minimum_payments @debt_minimum_payments end |
#debt_original_balance ⇒ Object
The original debt/loan account balance, specified in milliunits format.
54 55 56 |
# File 'lib/ynab/models/account.rb', line 54 def debt_original_balance @debt_original_balance end |
#deleted ⇒ Object
Whether or not the account has been deleted. Deleted accounts will only be included in delta requests.
63 64 65 |
# File 'lib/ynab/models/account.rb', line 63 def deleted @deleted end |
#direct_import_in_error ⇒ Object
If an account linked to a financial institution (direct_import_linked=true) and the linked connection is not in a healthy state, this will be true.
48 49 50 |
# File 'lib/ynab/models/account.rb', line 48 def direct_import_in_error @direct_import_in_error end |
#direct_import_linked ⇒ Object
Whether or not the account is linked to a financial institution for automatic transaction import.
45 46 47 |
# File 'lib/ynab/models/account.rb', line 45 def direct_import_linked @direct_import_linked end |
#id ⇒ Object
Returns the value of attribute id.
18 19 20 |
# File 'lib/ynab/models/account.rb', line 18 def id @id end |
#last_reconciled_at ⇒ Object
A date/time specifying when the account was last reconciled.
51 52 53 |
# File 'lib/ynab/models/account.rb', line 51 def last_reconciled_at @last_reconciled_at end |
#name ⇒ Object
Returns the value of attribute name.
20 21 22 |
# File 'lib/ynab/models/account.rb', line 20 def name @name end |
#note ⇒ Object
Returns the value of attribute note.
30 31 32 |
# File 'lib/ynab/models/account.rb', line 30 def note @note end |
#on_budget ⇒ Object
Whether this account is on budget or not
25 26 27 |
# File 'lib/ynab/models/account.rb', line 25 def on_budget @on_budget end |
#transfer_payee_id ⇒ Object
The payee id which should be used when transferring to this account
42 43 44 |
# File 'lib/ynab/models/account.rb', line 42 def transfer_payee_id @transfer_payee_id end |
#type ⇒ Object
Returns the value of attribute type.
22 23 24 |
# File 'lib/ynab/models/account.rb', line 22 def type @type end |
#uncleared_balance ⇒ Object
The current uncleared balance of the account in milliunits format
39 40 41 |
# File 'lib/ynab/models/account.rb', line 39 def uncleared_balance @uncleared_balance end |
Class Method Details
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
112 113 114 |
# File 'lib/ynab/models/account.rb', line 112 def self.acceptable_attributes attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/ynab/models/account.rb', line 88 def self.attribute_map { :'id' => :'id', :'name' => :'name', :'type' => :'type', :'on_budget' => :'on_budget', :'closed' => :'closed', :'note' => :'note', :'balance' => :'balance', :'cleared_balance' => :'cleared_balance', :'uncleared_balance' => :'uncleared_balance', :'transfer_payee_id' => :'transfer_payee_id', :'direct_import_linked' => :'direct_import_linked', :'direct_import_in_error' => :'direct_import_in_error', :'last_reconciled_at' => :'last_reconciled_at', :'debt_original_balance' => :'debt_original_balance', :'debt_interest_rates' => :'debt_interest_rates', :'debt_minimum_payments' => :'debt_minimum_payments', :'debt_escrow_amounts' => :'debt_escrow_amounts', :'deleted' => :'deleted' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
309 310 311 |
# File 'lib/ynab/models/account.rb', line 309 def self.build_from_hash(attributes) new.build_from_hash(attributes) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/ynab/models/account.rb', line 141 def self.openapi_nullable Set.new([ :'note', :'transfer_payee_id', :'last_reconciled_at', :'debt_original_balance', :'debt_interest_rates', :'debt_minimum_payments', :'debt_escrow_amounts', ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/ynab/models/account.rb', line 117 def self.openapi_types { :'id' => :'String', :'name' => :'String', :'type' => :'AccountType', :'on_budget' => :'Boolean', :'closed' => :'Boolean', :'note' => :'String', :'balance' => :'Integer', :'cleared_balance' => :'Integer', :'uncleared_balance' => :'Integer', :'transfer_payee_id' => :'String', :'direct_import_linked' => :'Boolean', :'direct_import_in_error' => :'Boolean', :'last_reconciled_at' => :'Time', :'debt_original_balance' => :'Integer', :'debt_interest_rates' => :'Hash<String, Integer>', :'debt_minimum_payments' => :'Hash<String, Integer>', :'debt_escrow_amounts' => :'Hash<String, Integer>', :'deleted' => :'Boolean' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/ynab/models/account.rb', line 271 def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && name == o.name && type == o.type && on_budget == o.on_budget && closed == o.closed && note == o.note && balance == o.balance && cleared_balance == o.cleared_balance && uncleared_balance == o.uncleared_balance && transfer_payee_id == o.transfer_payee_id && direct_import_linked == o.direct_import_linked && direct_import_in_error == o.direct_import_in_error && last_reconciled_at == o.last_reconciled_at && debt_original_balance == o.debt_original_balance && debt_interest_rates == o.debt_interest_rates && debt_minimum_payments == o.debt_minimum_payments && debt_escrow_amounts == o.debt_escrow_amounts && deleted == o.deleted end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 |
# File 'lib/ynab/models/account.rb', line 340 def _deserialize(type, value) case type.to_sym when :Time Time.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model # models (e.g. Pet) or oneOf klass = YNAB.const_get(type) klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'lib/ynab/models/account.rb', line 411 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#build_from_hash(attributes) ⇒ Object
Builds the object from hash
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
# File 'lib/ynab/models/account.rb', line 316 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) self.class.openapi_types.each_pair do |key, type| if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) self.send("#{key}=", nil) elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end end self end |
#eql?(o) ⇒ Boolean
296 297 298 |
# File 'lib/ynab/models/account.rb', line 296 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
302 303 304 |
# File 'lib/ynab/models/account.rb', line 302 def hash [id, name, type, on_budget, closed, note, balance, cleared_balance, uncleared_balance, transfer_payee_id, direct_import_linked, direct_import_in_error, last_reconciled_at, debt_original_balance, debt_interest_rates, debt_minimum_payments, debt_escrow_amounts, deleted].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
249 250 251 252 |
# File 'lib/ynab/models/account.rb', line 249 def list_invalid_properties invalid_properties = Array.new invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
387 388 389 |
# File 'lib/ynab/models/account.rb', line 387 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
393 394 395 396 397 398 399 400 401 402 403 404 405 |
# File 'lib/ynab/models/account.rb', line 393 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
381 382 383 |
# File 'lib/ynab/models/account.rb', line 381 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/ynab/models/account.rb', line 256 def valid? return false if @id.nil? return false if @name.nil? return false if @type.nil? return false if @on_budget.nil? return false if @closed.nil? return false if @balance.nil? return false if @cleared_balance.nil? return false if @uncleared_balance.nil? return false if @deleted.nil? true end |