PackageTracker

PackageTracker is a ruby gem for fetching the status of a packages(UPS, FedEx, etc…) with a simple API. Currently only UPS and FedEx are supported. More docs and carrier support to come soon…

Installation

To install:

gem install package_tracker

Usage

@client = PackageTracker::Client.new(Yaml.load_file("credentials.yaml"))

fedex_response = @client.track("999999999999")
# => PackageTracker::Response

fedex_response.delivered? 
# => true

fedex_response.statuses 
# => [{:message => "DELIVERED", :location => "San Francsico, CA, USA", :time => 2011-04-22 00:00:00 -0700}, ...]

ups_response = @client.track("1Z9999999999999999")
# and so on...

Configuration

PackageTracker::Client::new takes a hash of credentials with the following parameters:

{
  :ups => {
    :key => "key"
    :user_id => "user id"
    :password => "password"
  },
  :fedex => {
    :password => "password",
    :key => "key",
    :account => "account",
    :meter => "meter number"
  }
}

It’s usually easiest to put those credentials in a YAML file and load them in. That makes it easy to keep your sensitive password info out of git as well.

If you just want to hit the carriers’ test servers, you can set your client to test mode:

@client = PackageTracker::Client.new(Yaml.load_file("credentials.yaml"))

@client.test_mode!
# => all requests will now to to the carriers' test servers