module NetSuite
  module Records
    class PricingMatrix
      include Namespaces::PlatformCore

      def initialize(attributes = {})
        attributes[:pricing] = [attributes[:pricing]] unless
          attributes[:pricing].is_a? Array
        attributes[:pricing].each do |pricing|
          prices << RecordRef.new(pricing)
        end if attributes[:pricing]
      end

      def prices
        @prices ||= []
      end

      def to_record
        { "#{record_namespace}:item" => prices.map(&:to_record) }
      end
    end
  end
end

module NetSuite
  module Records
    class PricingMatrix < Support::Sublist
      include Namespaces::PlatformCore

      sublist :pricing, RecordRef

      alias :prices :pricing
    end
  end
end

Use sublist for pricing matrix
Use sublist for pricing matrix

If pricing matrix was nil in the XML response, a corrupted pricing matrix item
would be contained in `prices`
