Active Shipping
April 21st, 2008
Active Shipping is now available under an open source license. It's on GitHub, here. Active Shipping is an extension for Active Merchant which I wrote to let Shopify users provide carrier-calculated shipping rates to their customers. You can easily include Active Shipping in your Rails project as a plugin (or in any other ruby project, for that matter) and start doing things like this:
include ActiveMerchant::Shipping
usps = USPS.new(:login => '123JAMES4567')
origin = Location.new(:country => 'US', :zip => '90210')
destination = Location.new(:country => 'CA', :postal_code => 'K2P 0K3')
grams = 100
centimetres = [20,10,10]
packages = [Package.new(grams, centimetres)]
response = usps.find_rates(origin, destination, packages)
rates = response.rates.sort_by(&:price)
cheapest = rates.map {|r| [ r.service_name,
r.price.to_f / 100, # rates returned in cents
r.currency]}.first
# => ["USPS First-Class Mail International", 1.62, "USD"]
It's under active development and more details for contributing to the project can be found in the README.
June 30th, 2008 at 10:00 AM
Sounds like a cool plug. I wish I could have ported in code like this back when I was a full time web dev.