Class: YNAB::Category
- Inherits:
-
Object
- Object
- YNAB::Category
- Defined in:
- lib/ynab/models/category.rb
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#activity ⇒ Object
Activity amount in milliunits format.
-
#balance ⇒ Object
Balance in milliunits format.
-
#budgeted ⇒ Object
Budgeted amount in milliunits format.
-
#category_group_id ⇒ Object
Returns the value of attribute category_group_id.
-
#category_group_name ⇒ Object
Returns the value of attribute category_group_name.
-
#deleted ⇒ Object
Whether or not the category has been deleted.
-
#goal_cadence ⇒ Object
The goal cadence.
-
#goal_cadence_frequency ⇒ Object
The goal cadence frequency.
-
#goal_creation_month ⇒ Object
The month a goal was created.
-
#goal_day ⇒ Object
A day offset modifier for the goal’s due date.
-
#goal_months_to_budget ⇒ Object
The number of months, including the current month, left in the current goal period.
-
#goal_overall_funded ⇒ Object
The total amount funded towards the goal within the current goal period.
-
#goal_overall_left ⇒ Object
The amount of funding still needed to complete the goal within the current goal period.
-
#goal_percentage_complete ⇒ Object
The percentage completion of the goal.
-
#goal_target ⇒ Object
The goal target amount in milliunits.
-
#goal_target_month ⇒ Object
The original target month for the goal to be completed.
-
#goal_type ⇒ Object
The type of goal, if the category has a goal (TB=‘Target Category Balance’, TBD=‘Target Category Balance by Date’, MF=‘Monthly Funding’, NEED=‘Plan Your Spending’).
-
#goal_under_funded ⇒ Object
The amount of funding still needed in the current month to stay on track towards completing the goal within the current goal period.
-
#hidden ⇒ Object
Whether or not the category is hidden.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#note ⇒ Object
Returns the value of attribute note.
-
#original_category_group_id ⇒ Object
DEPRECATED: No longer used.
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 = {}) ⇒ Category
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 = {}) ⇒ Category
Initializes the object
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 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/ynab/models/category.rb', line 189 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `YNAB::Category` 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::Category`. 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?(:'category_group_id') self.category_group_id = attributes[:'category_group_id'] end if attributes.key?(:'category_group_name') self.category_group_name = attributes[:'category_group_name'] end if attributes.key?(:'name') self.name = attributes[:'name'] end if attributes.key?(:'hidden') self.hidden = attributes[:'hidden'] end if attributes.key?(:'original_category_group_id') self.original_category_group_id = attributes[:'original_category_group_id'] end if attributes.key?(:'note') self.note = attributes[:'note'] end if attributes.key?(:'budgeted') self.budgeted = attributes[:'budgeted'] end if attributes.key?(:'activity') self.activity = attributes[:'activity'] end if attributes.key?(:'balance') self.balance = attributes[:'balance'] end if attributes.key?(:'goal_type') self.goal_type = attributes[:'goal_type'] end if attributes.key?(:'goal_day') self.goal_day = attributes[:'goal_day'] end if attributes.key?(:'goal_cadence') self.goal_cadence = attributes[:'goal_cadence'] end if attributes.key?(:'goal_cadence_frequency') self.goal_cadence_frequency = attributes[:'goal_cadence_frequency'] end if attributes.key?(:'goal_creation_month') self.goal_creation_month = attributes[:'goal_creation_month'] end if attributes.key?(:'goal_target') self.goal_target = attributes[:'goal_target'] end if attributes.key?(:'goal_target_month') self.goal_target_month = attributes[:'goal_target_month'] end if attributes.key?(:'goal_percentage_complete') self.goal_percentage_complete = attributes[:'goal_percentage_complete'] end if attributes.key?(:'goal_months_to_budget') self.goal_months_to_budget = attributes[:'goal_months_to_budget'] end if attributes.key?(:'goal_under_funded') self.goal_under_funded = attributes[:'goal_under_funded'] end if attributes.key?(:'goal_overall_funded') self.goal_overall_funded = attributes[:'goal_overall_funded'] end if attributes.key?(:'goal_overall_left') self.goal_overall_left = attributes[:'goal_overall_left'] end if attributes.key?(:'deleted') self.deleted = attributes[:'deleted'] end end |
Instance Attribute Details
#activity ⇒ Object
Activity amount in milliunits format
38 39 40 |
# File 'lib/ynab/models/category.rb', line 38 def activity @activity end |
#balance ⇒ Object
Balance in milliunits format
41 42 43 |
# File 'lib/ynab/models/category.rb', line 41 def balance @balance end |
#budgeted ⇒ Object
Budgeted amount in milliunits format
35 36 37 |
# File 'lib/ynab/models/category.rb', line 35 def budgeted @budgeted end |
#category_group_id ⇒ Object
Returns the value of attribute category_group_id.
20 21 22 |
# File 'lib/ynab/models/category.rb', line 20 def category_group_id @category_group_id end |
#category_group_name ⇒ Object
Returns the value of attribute category_group_name.
22 23 24 |
# File 'lib/ynab/models/category.rb', line 22 def category_group_name @category_group_name end |
#deleted ⇒ Object
Whether or not the category has been deleted. Deleted categories will only be included in delta requests.
80 81 82 |
# File 'lib/ynab/models/category.rb', line 80 def deleted @deleted end |
#goal_cadence ⇒ Object
The goal cadence. Value in range 0-14. There are two subsets of these values which behave differently. For values 0, 1, 2, and 13, the goal’s due date repeats every goal_cadence * goal_cadence_frequency, where 0 = None, 1 = Monthly, 2 = Weekly, and 13 = Yearly. For example, goal_cadence 1 with goal_cadence_frequency 2 means the goal is due every other month. For values 3-12 and 14, goal_cadence_frequency is ignored and the goal’s due date repeats every goal_cadence, where 3 = Every 2 Months, 4 = Every 3 Months, …, 12 = Every 11 Months, and 14 = Every 2 Years.
50 51 52 |
# File 'lib/ynab/models/category.rb', line 50 def goal_cadence @goal_cadence end |
#goal_cadence_frequency ⇒ Object
The goal cadence frequency. When goal_cadence is 0, 1, 2, or 13, a goal’s due date repeats every goal_cadence * goal_cadence_frequency. For example, goal_cadence 1 with goal_cadence_frequency 2 means the goal is due every other month. When goal_cadence is 3-12 or 14, goal_cadence_frequency is ignored.
53 54 55 |
# File 'lib/ynab/models/category.rb', line 53 def goal_cadence_frequency @goal_cadence_frequency end |
#goal_creation_month ⇒ Object
The month a goal was created
56 57 58 |
# File 'lib/ynab/models/category.rb', line 56 def goal_creation_month @goal_creation_month end |
#goal_day ⇒ Object
A day offset modifier for the goal’s due date. When goal_cadence is 2 (Weekly), this value specifies which day of the week the goal is due (0 = Sunday, 6 = Saturday). Otherwise, this value specifies which day of the month the goal is due (1 = 1st, 31 = 31st, null = Last day of Month).
47 48 49 |
# File 'lib/ynab/models/category.rb', line 47 def goal_day @goal_day end |
#goal_months_to_budget ⇒ Object
The number of months, including the current month, left in the current goal period.
68 69 70 |
# File 'lib/ynab/models/category.rb', line 68 def goal_months_to_budget @goal_months_to_budget end |
#goal_overall_funded ⇒ Object
The total amount funded towards the goal within the current goal period.
74 75 76 |
# File 'lib/ynab/models/category.rb', line 74 def goal_overall_funded @goal_overall_funded end |
#goal_overall_left ⇒ Object
The amount of funding still needed to complete the goal within the current goal period.
77 78 79 |
# File 'lib/ynab/models/category.rb', line 77 def goal_overall_left @goal_overall_left end |
#goal_percentage_complete ⇒ Object
The percentage completion of the goal
65 66 67 |
# File 'lib/ynab/models/category.rb', line 65 def goal_percentage_complete @goal_percentage_complete end |
#goal_target ⇒ Object
The goal target amount in milliunits
59 60 61 |
# File 'lib/ynab/models/category.rb', line 59 def goal_target @goal_target end |
#goal_target_month ⇒ Object
The original target month for the goal to be completed. Only some goal types specify this date.
62 63 64 |
# File 'lib/ynab/models/category.rb', line 62 def goal_target_month @goal_target_month end |
#goal_type ⇒ Object
The type of goal, if the category has a goal (TB=‘Target Category Balance’, TBD=‘Target Category Balance by Date’, MF=‘Monthly Funding’, NEED=‘Plan Your Spending’)
44 45 46 |
# File 'lib/ynab/models/category.rb', line 44 def goal_type @goal_type end |
#goal_under_funded ⇒ Object
The amount of funding still needed in the current month to stay on track towards completing the goal within the current goal period. This amount will generally correspond to the ‘Underfunded’ amount in the web and mobile clients except when viewing a category with a Needed for Spending Goal in a future month. The web and mobile clients will ignore any funding from a prior goal period when viewing category with a Needed for Spending Goal in a future month.
71 72 73 |
# File 'lib/ynab/models/category.rb', line 71 def goal_under_funded @goal_under_funded end |
#hidden ⇒ Object
Whether or not the category is hidden
27 28 29 |
# File 'lib/ynab/models/category.rb', line 27 def hidden @hidden end |
#id ⇒ Object
Returns the value of attribute id.
18 19 20 |
# File 'lib/ynab/models/category.rb', line 18 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
24 25 26 |
# File 'lib/ynab/models/category.rb', line 24 def name @name end |
#note ⇒ Object
Returns the value of attribute note.
32 33 34 |
# File 'lib/ynab/models/category.rb', line 32 def note @note end |
#original_category_group_id ⇒ Object
DEPRECATED: No longer used. Value will always be null.
30 31 32 |
# File 'lib/ynab/models/category.rb', line 30 def original_category_group_id @original_category_group_id end |
Class Method Details
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
134 135 136 |
# File 'lib/ynab/models/category.rb', line 134 def self.acceptable_attributes attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/ynab/models/category.rb', line 105 def self.attribute_map { :'id' => :'id', :'category_group_id' => :'category_group_id', :'category_group_name' => :'category_group_name', :'name' => :'name', :'hidden' => :'hidden', :'original_category_group_id' => :'original_category_group_id', :'note' => :'note', :'budgeted' => :'budgeted', :'activity' => :'activity', :'balance' => :'balance', :'goal_type' => :'goal_type', :'goal_day' => :'goal_day', :'goal_cadence' => :'goal_cadence', :'goal_cadence_frequency' => :'goal_cadence_frequency', :'goal_creation_month' => :'goal_creation_month', :'goal_target' => :'goal_target', :'goal_target_month' => :'goal_target_month', :'goal_percentage_complete' => :'goal_percentage_complete', :'goal_months_to_budget' => :'goal_months_to_budget', :'goal_under_funded' => :'goal_under_funded', :'goal_overall_funded' => :'goal_overall_funded', :'goal_overall_left' => :'goal_overall_left', :'deleted' => :'deleted' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
369 370 371 |
# File 'lib/ynab/models/category.rb', line 369 def self.build_from_hash(attributes) new.build_from_hash(attributes) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/ynab/models/category.rb', line 168 def self.openapi_nullable Set.new([ :'original_category_group_id', :'note', :'goal_type', :'goal_day', :'goal_cadence', :'goal_cadence_frequency', :'goal_creation_month', :'goal_target', :'goal_target_month', :'goal_percentage_complete', :'goal_months_to_budget', :'goal_under_funded', :'goal_overall_funded', :'goal_overall_left', ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
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/ynab/models/category.rb', line 139 def self.openapi_types { :'id' => :'String', :'category_group_id' => :'String', :'category_group_name' => :'String', :'name' => :'String', :'hidden' => :'Boolean', :'original_category_group_id' => :'String', :'note' => :'String', :'budgeted' => :'Integer', :'activity' => :'Integer', :'balance' => :'Integer', :'goal_type' => :'String', :'goal_day' => :'Integer', :'goal_cadence' => :'Integer', :'goal_cadence_frequency' => :'Integer', :'goal_creation_month' => :'Date', :'goal_target' => :'Integer', :'goal_target_month' => :'Date', :'goal_percentage_complete' => :'Integer', :'goal_months_to_budget' => :'Integer', :'goal_under_funded' => :'Integer', :'goal_overall_funded' => :'Integer', :'goal_overall_left' => :'Integer', :'deleted' => :'Boolean' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
# File 'lib/ynab/models/category.rb', line 326 def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && category_group_id == o.category_group_id && category_group_name == o.category_group_name && name == o.name && hidden == o.hidden && original_category_group_id == o.original_category_group_id && note == o.note && budgeted == o.budgeted && activity == o.activity && balance == o.balance && goal_type == o.goal_type && goal_day == o.goal_day && goal_cadence == o.goal_cadence && goal_cadence_frequency == o.goal_cadence_frequency && goal_creation_month == o.goal_creation_month && goal_target == o.goal_target && goal_target_month == o.goal_target_month && goal_percentage_complete == o.goal_percentage_complete && goal_months_to_budget == o.goal_months_to_budget && goal_under_funded == o.goal_under_funded && goal_overall_funded == o.goal_overall_funded && goal_overall_left == o.goal_overall_left && deleted == o.deleted end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
# File 'lib/ynab/models/category.rb', line 400 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
471 472 473 474 475 476 477 478 479 480 481 482 483 |
# File 'lib/ynab/models/category.rb', line 471 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
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
# File 'lib/ynab/models/category.rb', line 376 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
356 357 358 |
# File 'lib/ynab/models/category.rb', line 356 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
362 363 364 |
# File 'lib/ynab/models/category.rb', line 362 def hash [id, category_group_id, category_group_name, name, hidden, original_category_group_id, note, budgeted, activity, balance, goal_type, goal_day, goal_cadence, goal_cadence_frequency, goal_creation_month, goal_target, goal_target_month, goal_percentage_complete, goal_months_to_budget, goal_under_funded, goal_overall_funded, goal_overall_left, deleted].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
297 298 299 300 |
# File 'lib/ynab/models/category.rb', line 297 def list_invalid_properties invalid_properties = Array.new invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
447 448 449 |
# File 'lib/ynab/models/category.rb', line 447 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
453 454 455 456 457 458 459 460 461 462 463 464 465 |
# File 'lib/ynab/models/category.rb', line 453 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
441 442 443 |
# File 'lib/ynab/models/category.rb', line 441 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
304 305 306 307 308 309 310 311 312 313 314 315 316 |
# File 'lib/ynab/models/category.rb', line 304 def valid? return false if @id.nil? return false if @category_group_id.nil? return false if @name.nil? return false if @hidden.nil? return false if @budgeted.nil? return false if @activity.nil? return false if @balance.nil? goal_type_validator = EnumAttributeValidator.new('String', ["TB", "TBD", "MF", "NEED", "DEBT", "null"]) return false unless goal_type_validator.valid?(@goal_type) return false if @deleted.nil? true end |