lib/active_shipping/carriers/usps.rb in active_shipping-1.2.0 vs lib/active_shipping/carriers/usps.rb in active_shipping-1.2.1

- old
+ new

@@ -232,11 +232,11 @@ end def extract_event_details(node) description = node.at('Event').text.upcase - if prefix = ONLY_PREFIX_EVENTS.find { |p| description.starts_with?(p) } + if prefix = ONLY_PREFIX_EVENTS.find { |p| description.start_with?(p) } description = prefix end timestamp = "#{node.at('EventDate').text}, #{node.at('EventTime').text}" event_code = node.at('EventCode').text @@ -289,11 +289,11 @@ # never use test mode; rate requests just won't work on test servers parse_rate_response(origin, destination, packages, commit(:us_rates, request, false), options) end def world_rates(origin, destination, packages, options = {}) - request = build_world_rate_request(packages, destination, options) + request = build_world_rate_request(origin, packages, destination, options) # never use test mode; rate requests just won't work on test servers parse_rate_response(origin, destination, packages, commit(:world_rates, request, false), options) end # Once the address verification API is implemented, remove this and have valid_credentials? build the request using that instead. @@ -369,14 +369,15 @@ # * the size restrictions are returned AS AN ENGLISH SENTENCE (!?) # # # package.options[:mail_type] -- one of [:package, :postcard, :matter_for_the_blind, :envelope]. # Defaults to :package. - def build_world_rate_request(packages, destination, options) + def build_world_rate_request(origin, packages, destination, options) country = COUNTRY_NAME_CONVERSIONS[destination.country.code(:alpha2).value] || destination.country.name xml_builder = Nokogiri::XML::Builder.new do |xml| xml.IntlRateV2Request('USERID' => @options[:login]) do + xml.Revision(2) Array(packages).each_with_index do |package, id| xml.Package('ID' => id) do xml.Pounds(0) xml.Ounces([package.ounces, 1].max.ceil) # takes an integer for some reason, must be rounded UP xml.MailType(MAIL_TYPES[package.options[:mail_type]] || 'Package') @@ -400,9 +401,12 @@ xml.Height("%0.2f" % [package.inches(:height), 0.01].max) xml.Girth("%0.2f" % [package.inches(:girth), 0.01].max) if commercial_type = commercial_type(options) xml.public_send(COMMERCIAL_FLAG_NAME.fetch(commercial_type), 'Y') end + xml.OriginZip(origin.zip) + xml.AcceptanceDateTime((options[:acceptance_time] || Time.now.utc).iso8601) + xml.DestinationPostalCode(destination.zip) end end end end save_request(xml_builder.to_xml)