lib/active_shipping/carriers/ups.rb in active_shipping-1.4.2 vs lib/active_shipping/carriers/ups.rb in active_shipping-1.4.3

- old
+ new

@@ -648,15 +648,23 @@ xml.public_send(axis.to_s.capitalize, [value, 0.1].max) end end xml.PackageWeight do + if (options[:service] || options[:service_code]) == DEFAULT_SERVICE_NAME_TO_CODE["UPS SurePost (USPS) < 1lb"] + # SurePost < 1lb uses OZS, not LBS + code = options[:imperial] ? 'OZS' : 'KGS' + weight = options[:imperial] ? package.oz : package.kgs + else + code = options[:imperial] ? 'LBS' : 'KGS' + weight = options[:imperial] ? package.lbs : package.kgs + end xml.UnitOfMeasurement do - xml.Code(options[:imperial] ? 'LBS' : 'KGS') + xml.Code(code) end - value = ((options[:imperial] ? package.lbs : package.kgs).to_f * 1000).round / 1000.0 # 3 decimals + value = ((weight).to_f * 1000).round / 1000.0 # 3 decimals xml.Weight([value, 0.1].max) end Array(package.options[:reference_numbers]).each do |reference_number_info| @@ -762,23 +770,24 @@ activities = first_package.css('> Activity') unless activities.empty? shipment_events = activities.map do |activity| description = activity.at('Status/StatusType/Description').text + type_code = activity.at('Status/StatusType/Code').text zoneless_time = parse_ups_datetime(:time => activity.at('Time'), :date => activity.at('Date')) location = location_from_address_node(activity.at('ActivityLocation/Address')) - ShipmentEvent.new(description, zoneless_time, location) + ShipmentEvent.new(description, zoneless_time, location, nil, type_code) end shipment_events = shipment_events.sort_by(&:time) # UPS will sometimes archive a shipment, stripping all shipment activity except for the delivery # event (see test/fixtures/xml/delivered_shipment_without_events_tracking_response.xml for an example). # This adds an origin event to the shipment activity in such cases. if origin && !(shipment_events.count == 1 && status == :delivered) first_event = shipment_events[0] - origin_event = ShipmentEvent.new(first_event.name, first_event.time, origin) + origin_event = ShipmentEvent.new(first_event.name, first_event.time, origin, first_event.message, first_event.type_code) if within_same_area?(origin, first_event.location) shipment_events[0] = origin_event else shipment_events.unshift(origin_event) @@ -793,10 +802,10 @@ actual_delivery_date = parse_ups_datetime(:date => delivered_activity.at('Date'), :time => delivered_activity.at('Time')) end unless destination destination = shipment_events[-1].location end - shipment_events[-1] = ShipmentEvent.new(shipment_events.last.name, shipment_events.last.time, destination) + shipment_events[-1] = ShipmentEvent.new(shipment_events.last.name, shipment_events.last.time, destination, shipment_events.last.message, shipment_events.last.type_code) end end end TrackingResponse.new(success, message, Hash.from_xml(response).values.first,