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
-
._deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
.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.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_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
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 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 |
# File 'lib/ynab/models/account.rb', line 152 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
30 31 32 |
# File 'lib/ynab/models/account.rb', line 30 def balance @balance end |
#cleared_balance ⇒ Object
The current cleared balance of the account in milliunits format
33 34 35 |
# File 'lib/ynab/models/account.rb', line 33 def cleared_balance @cleared_balance end |
#closed ⇒ Object
Whether this account is closed or not
25 26 27 |
# File 'lib/ynab/models/account.rb', line 25 def closed @closed end |
#debt_escrow_amounts ⇒ Object
Returns the value of attribute debt_escrow_amounts.
57 58 59 |
# File 'lib/ynab/models/account.rb', line 57 def debt_escrow_amounts @debt_escrow_amounts end |
#debt_interest_rates ⇒ Object
Returns the value of attribute debt_interest_rates.
53 54 55 |
# File 'lib/ynab/models/account.rb', line 53 def debt_interest_rates @debt_interest_rates end |
#debt_minimum_payments ⇒ Object
Returns the value of attribute debt_minimum_payments.
55 56 57 |
# File 'lib/ynab/models/account.rb', line 55 def debt_minimum_payments @debt_minimum_payments end |
#debt_original_balance ⇒ Object
The original debt/loan account balance, specified in milliunits format.
51 52 53 |
# File 'lib/ynab/models/account.rb', line 51 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.
60 61 62 |
# File 'lib/ynab/models/account.rb', line 60 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.
45 46 47 |
# File 'lib/ynab/models/account.rb', line 45 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.
42 43 44 |
# File 'lib/ynab/models/account.rb', line 42 def direct_import_linked @direct_import_linked end |
#id ⇒ Object
Returns the value of attribute id.
15 16 17 |
# File 'lib/ynab/models/account.rb', line 15 def id @id end |
#last_reconciled_at ⇒ Object
A date/time specifying when the account was last reconciled.
48 49 50 |
# File 'lib/ynab/models/account.rb', line 48 def last_reconciled_at @last_reconciled_at end |
#name ⇒ Object
Returns the value of attribute name.
17 18 19 |
# File 'lib/ynab/models/account.rb', line 17 def name @name end |
#note ⇒ Object
Returns the value of attribute note.
27 28 29 |
# File 'lib/ynab/models/account.rb', line 27 def note @note end |
#on_budget ⇒ Object
Whether this account is on budget or not
22 23 24 |
# File 'lib/ynab/models/account.rb', line 22 def on_budget @on_budget end |
#transfer_payee_id ⇒ Object
The payee id which should be used when transferring to this account
39 40 41 |
# File 'lib/ynab/models/account.rb', line 39 def transfer_payee_id @transfer_payee_id end |
#type ⇒ Object
Returns the value of attribute type.
19 20 21 |
# File 'lib/ynab/models/account.rb', line 19 def type @type end |
#uncleared_balance ⇒ Object
The current uncleared balance of the account in milliunits format
36 37 38 |
# File 'lib/ynab/models/account.rb', line 36 def uncleared_balance @uncleared_balance end |
Class Method Details
._deserialize(type, value) ⇒ Object
Deserializes the data based on type
330 331 332 333 334 335 336 337 338 339 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 |
# File 'lib/ynab/models/account.rb', line 330 def self._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_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
109 110 111 |
# File 'lib/ynab/models/account.rb', line 109 def self.acceptable_attributes attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/ynab/models/account.rb', line 85 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
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/ynab/models/account.rb', line 306 def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) transformed_hash = {} openapi_types.each_pair do |key, type| if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? transformed_hash["#{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[attribute_map[key]].is_a?(Array) transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end elsif !attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end end new(transformed_hash) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/ynab/models/account.rb', line 138 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.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/ynab/models/account.rb', line 114 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.
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/ynab/models/account.rb', line 268 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 |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
401 402 403 404 405 406 407 408 409 410 411 412 413 |
# File 'lib/ynab/models/account.rb', line 401 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 |
#eql?(o) ⇒ Boolean
293 294 295 |
# File 'lib/ynab/models/account.rb', line 293 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
299 300 301 |
# File 'lib/ynab/models/account.rb', line 299 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?
246 247 248 249 |
# File 'lib/ynab/models/account.rb', line 246 def list_invalid_properties invalid_properties = Array.new invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
377 378 379 |
# File 'lib/ynab/models/account.rb', line 377 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
383 384 385 386 387 388 389 390 391 392 393 394 395 |
# File 'lib/ynab/models/account.rb', line 383 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
371 372 373 |
# File 'lib/ynab/models/account.rb', line 371 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/ynab/models/account.rb', line 253 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 |