class XeroGateway::TrackingCategory
Attributes
all_options[RW]
name[RW]
options[RW]
status[RW]
tracking_category_id[RW]
Public Class Methods
from_xml(tracking_category_element)
click to toggle source
# File lib/xero_gateway/tracking_category.rb, line 88 def self.from_xml(tracking_category_element) tracking_category = TrackingCategory.new tracking_category_element.children.each do |element| case(element.name) when "TrackingCategoryID" then tracking_category.tracking_category_id = element.text when "Name" then tracking_category.name = element.text when "Status" then tracking_category.status = element.text when "Options" then element.children.each do |option_child| tracking_category.options << option_child.children.detect {|c| c.name == "Name"}.text tracking_category.all_options << Option.from_xml(option_child) end when "Option" then tracking_category.options << element.text end end tracking_category end
new(params = {})
click to toggle source
# File lib/xero_gateway/tracking_category.rb, line 46 def initialize(params = {}) @options = [] @all_options = [] params.each do |k,v| self.send("#{k}=", v) end end
Public Instance Methods
==(other)
click to toggle source
# File lib/xero_gateway/tracking_category.rb, line 106 def ==(other) [:tracking_category_id, :name, :options].each do |field| return false if send(field) != other.send(field) end return true end
option()
click to toggle source
# File lib/xero_gateway/tracking_category.rb, line 54 def option options[0] if options.size == 1 end
to_xml(b = Builder::XmlMarkup.new)
click to toggle source
# File lib/xero_gateway/tracking_category.rb, line 58 def to_xml(b = Builder::XmlMarkup.new) b.TrackingCategory { b.TrackingCategoryID tracking_category_id unless tracking_category_id.nil? b.Name self.name b.Options { if self.options.is_a?(Array) self.options.each do |option| b.Option { b.Name option } end else b.Option { b.Name self.options.to_s } end } } end
to_xml_for_invoice_messages(b = Builder::XmlMarkup.new)
click to toggle source
When a tracking category is serialized as part of an invoice it may only have a single option, and the Options tag is omitted
# File lib/xero_gateway/tracking_category.rb, line 80 def to_xml_for_invoice_messages(b = Builder::XmlMarkup.new) b.TrackingCategory { b.TrackingCategoryID self.tracking_category_id unless tracking_category_id.nil? b.Name self.name b.Option self.options.is_a?(Array) ? self.options.first : self.options.to_s } end