Class: YNAB::Account

Inherits:
ApiModelBase show all
Defined in:
lib/ynab/models/account.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ Account

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



149
150
151
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
# File 'lib/ynab/models/account.rb', line 149

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

#balanceObject

The current available balance of the account in milliunits format



30
31
32
# File 'lib/ynab/models/account.rb', line 30

def balance
  @balance
end

#cleared_balanceObject

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

#closedObject

Whether this account is closed or not



25
26
27
# File 'lib/ynab/models/account.rb', line 25

def closed
  @closed
end

#debt_escrow_amountsObject

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_ratesObject

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_paymentsObject

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_balanceObject

This field is deprecated and will always be null.



51
52
53
# File 'lib/ynab/models/account.rb', line 51

def debt_original_balance
  @debt_original_balance
end

#deletedObject

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_errorObject

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_linkedObject

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

#idObject

Returns the value of attribute id.



15
16
17
# File 'lib/ynab/models/account.rb', line 15

def id
  @id
end

#last_reconciled_atObject

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

#nameObject

Returns the value of attribute name.



17
18
19
# File 'lib/ynab/models/account.rb', line 17

def name
  @name
end

#noteObject

Returns the value of attribute note.



27
28
29
# File 'lib/ynab/models/account.rb', line 27

def note
  @note
end

#on_budgetObject

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_idObject

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

#typeObject

Returns the value of attribute type.



19
20
21
# File 'lib/ynab/models/account.rb', line 19

def type
  @type
end

#uncleared_balanceObject

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

.acceptable_attributesObject

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_mapObject

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

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/ynab/models/account.rb', line 303

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_nullableObject

List of attributes with nullable: true



138
139
140
141
142
143
144
145
# File 'lib/ynab/models/account.rb', line 138

def self.openapi_nullable
  Set.new([
    :'note',
    :'transfer_payee_id',
    :'last_reconciled_at',
    :'debt_original_balance',
  ])
end

.openapi_typesObject

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.

Parameters:

  • Object (Object)

    to be compared



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# File 'lib/ynab/models/account.rb', line 265

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

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


290
291
292
# File 'lib/ynab/models/account.rb', line 290

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



296
297
298
# File 'lib/ynab/models/account.rb', line 296

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_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



243
244
245
246
# File 'lib/ynab/models/account.rb', line 243

def list_invalid_properties
  invalid_properties = Array.new
  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/ynab/models/account.rb', line 325

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

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/ynab/models/account.rb', line 250

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