Sha256: 7cd78047118146f3c4396317410259cd42b76f21b69a92e70749c5b4f05323a6

Contents?: true

Size: 915 Bytes

Versions: 1

Compression:

Stored size: 915 Bytes

Contents

module XeroGateway
  module Messages
    class TrackingCategoryMessage      
      
      def self.build_xml(tracking_category)
        b = Builder::XmlMarkup.new
        
        b.TrackingCategory {
          b.Name tracking_category.name
          b.Options {
            tracking_category.options.each do |option|
              b.Option {
                b.Name option
              }
            end
          }
        }
      end
      
      def self.from_xml(tracking_category_element)
        tracking_category = TrackingCategory.new
        tracking_category_element.children.each do |element|
          case(element.name)
            when "Name" then tracking_category.name = element.text
            when "Options" then element.children.each {|option| tracking_category.options << option.children.first.text}
          end
        end
        tracking_category              
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tlconnor-xero_gateway-1.0.2 lib/xero_gateway/messages/tracking_category_message.rb