Introducing Shippinglogic

Today I released the first version of Shippinglogic, which is a ruby library I wrote to make integrating with FedEx, UPS, USPS, etc, very easy.

This is not a project I wanted to do, but I couldn’t find a library that did everything I needed it to. One library had support for creating shipments, but didn’t have support for getting a list of rates. Another had support for getting rates, but didn’t have support for creating shipments. I need both for the application I’m working on. I even decided to modify one of the libraries to suit my needs but the code was really hard to follow and I didn’t feel comfortable using it. Especially since shipping was such an important part of my application.

That’s when I came to the sad realization that I probably need to write my own library. I was really surprised by the lack of choices when it came to shipping API integration. Then I started reading the FedEx documentation and realized why. Documentation on creating a shipment with the FedEx web services was 570 pages long. The amount of bullshit in the documentation astounded me. 99% of developers are probably concerned with maybe 30 pages in that entire document. I felt like I was reading a legal document, not web service documentation.

Sorry for the ranting, but this week has been especially frustrating, imagine reading FedEx documentation all day. Anyways, onto Shippinglogic.

What is Shippinglogic?

My goal with Shippinglogic was to make integrating with the various shipping APIs (FedEx, UPS, USPS, etc) easy and complete. The keyword being complete. Shippinglogic is not an abstraction layer, meaning each classes’ focus is on the web service at hand. It is not trying to conform to an interface. With all of the differences between the various APIs its simply not possible to do this without severely limiting the feature sets for each API. There is no defined shipping standard that all of these companies agreed on, so how do you safely make an abstraction layer for this?

Anyways, I think it turned out pretty well. The syntax is pretty slick, thanks to the proxy class trick I talked about in a previous post.

Here’s a quick example of tracking a package:

fedex = Shippinglogic::FedEx.new(key, password, account, meter)
tracking = fedex.track(:tracking_number => "XXXXXXXXXXXXXXXXX")

# this shows that the tracking object is actually a proxy for the underlying array
tracking.tracking_number
# => "XXXXXXXXXXXXXXXXX"

tracking.tracking_number = "YYYYYYYYYYYYYYY"
# => "YYYYYYYYYYYYYYY"

tracking.class
# => Array

tracking.first
# => #

tracking.first.name
# => "Delivered"

I was pretty thorough with the documentation. Check out the project on github for more examples. Let me know what you think.

  • Share/Save/Bookmark


20 Responses to “Introducing Shippinglogic”

  1. stam says:

    This is a great piece of work, thanks for solving these common problems in clean and consistent ways.

    Is there a BillingLogic in the making to complete the trilogy? (Recurrent payments are another big common problem.)

  2. Great work! can imagine it must have been tough to follow up on all of the different shipping API’s. Nice one mate.

  3. Alan Harper says:

    I just finished integrating Fedex in the app I’m working on last week!

    Good to see more support out there for shipping now

  4. [...] Introducing Shippinglogic – Ruby library for easy integration with FedEx, UPS, USPS and so on. [...]

  5. Guess I am a little confused, you mention UPS and USPS, but there is no corresponding code for these yet. Is this in the works by you, or left open to solve for the community? I am only asking as I am putting together ActiveShipping for a Spree cart this week, and my needs are for UPS and USPS (for international), and I would evaluate this one if it was so. Otherwise I will consider looking at it when my shipping needs increase.

  6. benjohnson says:

    Hi Timothy,
    It’s in the works. I didn’t want to advertise this library as a FedEx only library, because that will soon change, but I wanted to get it out there. UPS and USPS integration should not be hard, I have everything in place to make requests and parse responses, the only problem is reading the documentation. That’s where a lot of my time was spent with the FedEx integration.

  7. Joe Van Dyk says:

    I believe the ActiveMerchant people were working on ActiveShipping.

    http://blog.leetsoft.com/2008/4/21/active-shipping

  8. benjohnson says:

    Yeah, that’s the library I initially tried using. It was convoluted and there was a lot of unnecessary code in there. Bundled libraries, etc. Shipping is an important aspect of the application I’m building and I didn’t feel comfortable extending it and adding my own services.

  9. I understand, its why many of us look eagerly toward these libraries. I’ll take a look at this over the coming weeks.

  10. [...] Shared Introducing Shippinglogic – Binary Logic [...]

  11. [...] Introducing Shippinglogic – Binary Logic From the dude who did Authlogic and SearchLogic, comes ShippingLogic, which is to deal with…shipping. [...]

  12. Larry Sprock says:

    Just curious if you have plans to add the ability to gather other info through tracking such as expected delivery date, location and other such info normally associated with a shipment?

    Also do you know if Fedex has an api just for retrieving tracking info that doesn’t require jumping through hoops? I looked and couldn’t find any documentation but could have missed something. Seems trivial since anyone can look it up on there website…

    Nice work!
    ~Larry

  13. benjohnson says:

    Yeah, I thought expected delivery date was already in there, I have it for rates and creating a shipment. If its not in there for tracking I’ll add it.

    Also, I’m pretty confident to use their services at all you have to get an api key and what not. I don’t think they have a public free for all web service that anyone can use. But I may be wrong. I agree though, that would make the most sense since that information is publicly accessible anyways.

  14. Larry Sprock says:

    Very cool.

    Just looked at the available options for the TrackReply Elements from fedex as well as your code… Would be cool if you could just add options to the tracking request so that you could retrieve other values if needed… as well as have a standard set…
    eg. fedex.tracking(:tracking_number => ‘xxxxxxxxxxx’, :options =>…

    Hope that’s clear…

  15. benjohnson says:

    I’m not sure I follow you. But the format of the tracking reply from FedEx is unbelievably complicated, so there is no user friendly way for me to just let you tap into that and pull out whatever you need. My goal is to give you everything you need in that object, basically pull out as much information as I can from the response. Otherwise you would be digging into a hash that is 20 levels deep.

    I’ll look at the request again and add in more information, such as expected delivery date.

  16. Larry Sprock says:

    Gotcha, thanks for the quick answer!

    ~Larry

  17. benjohnson says:

    Larry, this should be all set, if you checkout 1.1.0 you will notice track now has more information.

  18. Larry Sprock says:

    Sorry, Just had time to take a look at the changes. Works a treat! Thanks for the addition!

  19. sd says:

    I was curious if you wanted a little help on ShippingLogic. I’m interested in working on some classes for FreightQuote.com I know they won’t be the most popular shipping choice, but for something i’m working on it’s very useful. I’m a relatively inexperienced rails developed, but I’m looking for a concrete project to focus on and some guidance