def parse_tracking_response(response)
      doc = Nokogiri.XML(response)
      doc.remove_namespaces!
      raise ActiveShipping::ResponseError, "No Tracking" unless doc.at('tracking-detail')

      events = doc.root.xpath('significant-events/occurrence')

      shipment_events  = build_tracking_events(events)
      change_date      = doc.root.at('changed-expected-date').text
      expected_date    = doc.root.at('expected-delivery-date').text
      dest_postal_code = doc.root.at('destination-postal-id').text
      destination      = Location.new(:postal_code => dest_postal_code)
      origin           = Location.new(origin_hash_for(doc.root))
      options = {
        :carrier                 => @@name,
        :service_name            => doc.root.at('service-name').text,
        :expected_date           => expected_date.blank? ? nil : Date.parse(expected_date),
        :changed_date            => change_date.blank? ? nil : Date.parse(change_date),
        :change_reason           => doc.root.at('changed-expected-delivery-reason').text.strip,
        :destination_postal_code => doc.root.at('destination-postal-id').text,
        :shipment_events         => shipment_events,
        :tracking_number         => doc.root.at('pin').text,
        :origin                  => origin,
        :destination             => destination,
        :customer_number         => doc.root.at('mailed-by-customer-number').text
      }

      CPPWSTrackingResponse.new(true, "", {}, options)
    end
def parse_tracking_response(response)
      doc = Nokogiri.XML(response)
      doc.remove_namespaces!
      raise ActiveShipping::ResponseError, "No Tracking" unless doc.at('tracking-detail')

      events = doc.root.xpath('significant-events/occurrence')

      shipment_events  = build_tracking_events(events)
      change_date      = doc.root.at('changed-expected-date').text
      expected_date    = doc.root.at('expected-delivery-date').text
      dest_postal_code = doc.root.at('destination-postal-id').text
      destination      = Location.new(:postal_code => dest_postal_code)
      origin           = Location.new(origin_hash_for(doc.root))
      options = {
        :carrier                 => @@name,
        :service_name            => doc.root.at('service-name').text,
        :expected_date           => expected_date.blank? ? nil : Date.parse(expected_date),
        :changed_date            => change_date.blank? ? nil : Date.parse(change_date),
        :change_reason           => doc.root.at('changed-expected-delivery-reason').text.strip,
        :destination_postal_code => doc.root.at('destination-postal-id').text,
        :shipment_events         => shipment_events,
        :tracking_number         => doc.root.at('pin').text,
        :origin                  => origin,
        :destination             => destination,
        :customer_number         => doc.root.at('mailed-by-customer-number').text
      }

      CPPWSTrackingResponse.new(true, "", {}, options)
    end
tracking