Class: XeroKiwi::Accounting::TrackingCategory

Inherits:
Object
  • Object
show all
Defined in:
lib/xero_kiwi/accounting/tracking_category.rb

Overview

Represents a tracking category assignment on a line item or contact.

See: developer.xero.com/documentation/api/accounting/invoices

Constant Summary collapse

ATTRIBUTES =
{
  tracking_category_id: "TrackingCategoryID",
  tracking_option_id:   "TrackingOptionID",
  name:                 "Name",
  option:               "Option"
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ TrackingCategory

Returns a new instance of TrackingCategory.



18
19
20
21
22
23
24
# File 'lib/xero_kiwi/accounting/tracking_category.rb', line 18

def initialize(attrs)
  attrs                 = attrs.transform_keys(&:to_s)
  @tracking_category_id = attrs["TrackingCategoryID"]
  @tracking_option_id   = attrs["TrackingOptionID"]
  @name                 = attrs["Name"]
  @option               = attrs["Option"]
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



30
31
32
# File 'lib/xero_kiwi/accounting/tracking_category.rb', line 30

def ==(other)
  other.is_a?(TrackingCategory) && to_h == other.to_h
end

#hashObject



35
# File 'lib/xero_kiwi/accounting/tracking_category.rb', line 35

def hash = to_h.hash

#inspectObject



37
38
39
# File 'lib/xero_kiwi/accounting/tracking_category.rb', line 37

def inspect
  "#<#{self.class} name=#{name.inspect} option=#{option.inspect}>"
end

#to_hObject



26
27
28
# File 'lib/xero_kiwi/accounting/tracking_category.rb', line 26

def to_h
  ATTRIBUTES.keys.to_h { |key| [key, public_send(key)] }
end