949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
|
# File 'lib/active_shipping/carriers/ups.rb', line 949
def parse_delivery_dates_response(origin, destination, packages, response, options={})
xml = build_document(response, 'TimeInTransitResponse')
success = response_success?(xml)
message = response_message(xml)
delivery_estimates = []
if success
xml.css('ServiceSummary').each do |service_summary|
service_name = service_summary.at('Service/Description').text
service_code = UPS::DEFAULT_SERVICE_NAME_TO_CODE[service_name]
date = Date.strptime(service_summary.at('EstimatedArrival/Date').text, '%Y-%m-%d')
business_transit_days = service_summary.at('EstimatedArrival/BusinessTransitDays').text.to_i
delivery_estimates << DeliveryDateEstimate.new(origin, destination, self.class.class_variable_get(:@@name),
service_name,
:service_code => service_code,
:guaranteed => service_summary.at('Guaranteed/Code').text == 'Y',
:date => date,
:business_transit_days => business_transit_days)
end
end
response = DeliveryDateEstimatesResponse.new(success, message, Hash.from_xml(response).values.first, :delivery_estimates => delivery_estimates, :xml => response, :request => last_request)
end
|