http://github.com/deepsalt/active_shipping/tree/master
The good stuff is in the ups carrier and its remote test.
Having spiked a solution for UPS, I'm now working on supporting USPS
labels and then factoring out the commonalities. Fedex support would
of course be nice but is not something for which I have an immediate
need.
Supporting UPS and USPS with a common API presents a challenge right
off the bat, of course. UPS has a two-stage shipping label purchase
process, where you must accept a quoted shipment rate before getting
the label. USPS does it all it one pass. I was thinking that a common
interface might look like:
carrier.buy_shipping_labels(shipper, origin, destination, packages, options)
origin and destination would be locations, packages would be packages
shipper would be a new Shipper object which would have at least a name
and an account number
options might consist of:
expected_price: the expected cost of the shipment, presumably based on
a rate quoted by the rate request api (default: the confirmation is
automatically accepted)
price_epsilon: the amount by which the shipment quote may exceed the
expected price without automatically refusing the confirmation
(default: 0)
payer: a shipper or a creditcard (default: the given shipper)
The return value would probably be a new Shipment object which would
have a Label for each Package.
Any comments? In particular, if anyone with Fedex shipping label
experience can note if the proposed API would cover their case, that'd
be super.
- donald
I'm actually working on a revised active_shipping API, at least
internally. I've introduced a Shipment object which has all of the
relevant attributes you might expect (destination, packages, labels,
tracking number, etc.) and am using that as a message object; it's
helped clarify the code substantially. I'm tinkering around with the
notion of allowing the public API to operate on shipment objects,
e.g.:
rates = carrier.get_rates(shipment)
...
shipment.service = rates.first.service_code
carrier.buy_shipping_labels(shipment)
shipment.labels.each do |label|
...
end
...
carrier.find_tracking_info(shipment)
That might be gilding the lily, I'm not sure, but I think it's more
convenient than passing around a disparate collection of addresses and
packages. Any thoughts on that?
- donald