class YNAB::Category
Attributes
Activity amount in milliunits format
Balance in milliunits format
Budgeted amount in milliunits format
Whether or not the category has been deleted. Deleted categories will only be included in delta requests.
The month a goal was created
The number of months, including the current month, left in the current goal period.
The total amount funded towards the goal within the current goal period.
The amount of funding still needed to complete the goal within the current goal period.
The percentage completion of the goal
The goal target amount in milliunits
The original target month for the goal to be completed. Only some goal types specify this date.
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.
If category is hidden this is the id of the category group it originally belonged to before it was hidden.
Public Class Methods
Attribute mapping from ruby-style variable name to JSON key.
# File lib/ynab/models/category.rb, line 93 def self.attribute_map { :'id' => :'id', :'category_group_id' => :'category_group_id', :'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_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
Initializes the object @param [Hash] attributes Model attributes in the form of hash
# File lib/ynab/models/category.rb, line 144 def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } if attributes.has_key?(:'id') self.id = attributes[:'id'] end if attributes.has_key?(:'category_group_id') self.category_group_id = attributes[:'category_group_id'] end if attributes.has_key?(:'name') self.name = attributes[:'name'] end if attributes.has_key?(:'hidden') self.hidden = attributes[:'hidden'] end if attributes.has_key?(:'original_category_group_id') self.original_category_group_id = attributes[:'original_category_group_id'] end if attributes.has_key?(:'note') self.note = attributes[:'note'] end if attributes.has_key?(:'budgeted') self.budgeted = attributes[:'budgeted'] end if attributes.has_key?(:'activity') self.activity = attributes[:'activity'] end if attributes.has_key?(:'balance') self.balance = attributes[:'balance'] end if attributes.has_key?(:'goal_type') self.goal_type = attributes[:'goal_type'] end if attributes.has_key?(:'goal_creation_month') self.goal_creation_month = attributes[:'goal_creation_month'] end if attributes.has_key?(:'goal_target') self.goal_target = attributes[:'goal_target'] end if attributes.has_key?(:'goal_target_month') self.goal_target_month = attributes[:'goal_target_month'] end if attributes.has_key?(:'goal_percentage_complete') self.goal_percentage_complete = attributes[:'goal_percentage_complete'] end if attributes.has_key?(:'goal_months_to_budget') self.goal_months_to_budget = attributes[:'goal_months_to_budget'] end if attributes.has_key?(:'goal_under_funded') self.goal_under_funded = attributes[:'goal_under_funded'] end if attributes.has_key?(:'goal_overall_funded') self.goal_overall_funded = attributes[:'goal_overall_funded'] end if attributes.has_key?(:'goal_overall_left') self.goal_overall_left = attributes[:'goal_overall_left'] end if attributes.has_key?(:'deleted') self.deleted = attributes[:'deleted'] end end
Attribute type mapping.
# File lib/ynab/models/category.rb, line 118 def self.swagger_types { :'id' => :'String', :'category_group_id' => :'String', :'name' => :'String', :'hidden' => :'BOOLEAN', :'original_category_group_id' => :'String', :'note' => :'String', :'budgeted' => :'Integer', :'activity' => :'Integer', :'balance' => :'Integer', :'goal_type' => :'String', :'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
Public Instance Methods
Checks equality by comparing each attribute. @param [Object] Object to be compared
# File lib/ynab/models/category.rb, line 290 def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && category_group_id == o.category_group_id && 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_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
Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data
# File lib/ynab/models/category.rb, line 349 def _deserialize(type, value) case type.to_sym when :DateTime DateTime.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 temp_model = YNAB.const_get(type).new temp_model.build_from_hash(value) end end
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash
# File lib/ynab/models/category.rb, line 415 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
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/ynab/models/category.rb, line 328 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if 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 # or else data not found in attributes(hash), not an issue as the data can be optional end self end
@see the `==` method @param [Object] Object to be compared
# File lib/ynab/models/category.rb, line 316 def eql?(o) self == o end
Custom attribute writer method checking allowed values (enum). @param [Object] goal_type
Object to be assigned
# File lib/ynab/models/category.rb, line 284 def goal_type=(goal_type) @goal_type = goal_type end
Calculates hash code according to all attributes. @return [Fixnum] Hash code
# File lib/ynab/models/category.rb, line 322 def hash [id, category_group_id, name, hidden, original_category_group_id, note, budgeted, activity, balance, goal_type, 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
Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons
# File lib/ynab/models/category.rb, line 229 def list_invalid_properties invalid_properties = Array.new if @id.nil? invalid_properties.push('invalid value for "id", id cannot be nil.') end if @category_group_id.nil? invalid_properties.push('invalid value for "category_group_id", category_group_id cannot be nil.') end if @name.nil? invalid_properties.push('invalid value for "name", name cannot be nil.') end if @hidden.nil? invalid_properties.push('invalid value for "hidden", hidden cannot be nil.') end if @budgeted.nil? invalid_properties.push('invalid value for "budgeted", budgeted cannot be nil.') end if @activity.nil? invalid_properties.push('invalid value for "activity", activity cannot be nil.') end if @balance.nil? invalid_properties.push('invalid value for "balance", balance cannot be nil.') end if @deleted.nil? invalid_properties.push('invalid value for "deleted", deleted cannot be nil.') end invalid_properties end
Returns the object in the form of hash @return [Hash] Returns the object in the form of hash
# File lib/ynab/models/category.rb, line 401 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end hash end
Returns the string representation of the object @return [String] String presentation of the object
# File lib/ynab/models/category.rb, line 389 def to_s to_hash.to_s end
Check to see if the all the properties in the model are valid @return true if the model is valid
# File lib/ynab/models/category.rb, line 268 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']) return false unless goal_type_validator.valid?(@goal_type) return false if @deleted.nil? true end