435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
|
# File 'lib/active_shipping/carriers/ups.rb', line 435
def build_delivery_dates_request(origin, destination, packages, pickup_date, options={})
xml_builder = Nokogiri::XML::Builder.new do |xml|
xml.TimeInTransitRequest do
xml.Request do
xml.RequestAction('TimeInTransit')
end
build_address_artifact_format_location(xml, 'TransitFrom', origin)
build_address_artifact_format_location(xml, 'TransitTo', destination)
xml.ShipmentWeight do
xml.UnitOfMeasurement do
xml.Code(options[:imperial] ? 'LBS' : 'KGS')
end
value = packages.inject(0) do |sum, package|
sum + (options[:imperial] ? package.lbs.to_f : package.kgs.to_f )
end
xml.Weight([value.round(3), 0.1].max)
end
xml.InvoiceLineTotal do
xml.CurrencyCode('USD')
total_value = packages.inject(0) {|sum, package| sum + package.value}
xml.MonetaryValue(total_value)
end
xml.PickupDate(pickup_date.strftime('%Y%m%d'))
end
end
xml_builder.to_xml
end
|