ups_time_in_transit is an easy to use interface to the UPS Time in Transit API.

installation ==

gem install ups_time_in_transit

usage ==

# define your access options. These are options that won’t change # between requests. Take care to specify the proper UPS url: # ‘wwwcie.ups.com/ups.app/xml/TimeInTransit’ for testing and # development, and ‘onlinetools.ups.com/ups.app/xml/TimeInTransit’ # for production. access_options =

:url => 'https://wwwcie.ups.com/ups.app/xml/TimeInTransit',
:access_license_number => 'foo',
:user_id => 'bar',
:password => 'baz',
:order_cutoff_time => 17 ,
:sender_city => 'Hoboken',
:sender_state => 'NJ',
:sender_country_code => 'US',
:sender_zip => '07030'

# It’s best to store these these options in a yaml file and load them # into a map when you need them: yaml = YAML.load_file(“#{RAILS_ROOT}/config/ups_time_in_transit.yml”) access_options = yaml.inject({}){|h,(k, v)| h = v; h}

# create an api instance with your access options time_in_transit_api = UPS::TimeInTransit.new(access_options)

# for each request, generate a map of request options describing # the shipment and where it’s going request_options = {

:total_packages => 1,
:unit_of_measurement => 'LBS',
:weight => 10,
:city => 'Newark',
:state => 'DE',
:zip => '19711',
:country_code => 'US'}

# request the map of delivery types (overnight, ground, etc.) to the expected # delivery date for that type. Be sure to rescue any errors. begin

delivery_dates = time_in_transit_api.request(request_options)

rescue => error

puts error.inspect

end

changelog ==

v.0.1.5

Added the ability to optionally specify the date you are shipping the package on, instead of assuming it's today. If you specify a shipping date that is ivalid, the first available pick-up time will be used (calculated in a function based on the last daily pick-up time and day of the week).
When adding the pick-up date you must specify it in the following string format --> YYYYMMDD, i.e. 20151225 --> Christmas day 2015.

Example of usage:
  request_options = {

:pickup_date => “20151225”, …

}

v.0.1.4

Minor bug fix to project files.

v.0.1.3

First working version by Ben Crudo.
Extracting more data from the UPS API: Response now contains a hash with the delivery date as well as the number business days the package would be in transit.

v.0.1.2

First pass by Ben Crudo to modify the Gem and release it on RubyGems. Yanked it though for having a bug.

v.0.1.1

some erroneous documentation

v.0.1.0

initial release