Shopify/active_shipping — pull request #59 by jnormore (2012-09-10 14:14:10+00:00)
Title: Canada Post Platform Web Service

This pull request contains integration for the new Canada Post web services for onboarding, calculated rates, tracking, and label printing on behalf of a merchant. Details about their new services are at

http://www.canadapost.ca/cpotools/apps/developers/home?execution=e1s1

For each actions (oboarding, rates, tracking, and label/shipment creation, service methods and options retrieval) there is a method to initiate the action, a method to build the xml request, and a method to parse the xml response.

I've added a new PackageItem class to facilitate a list of items (with skus, hs codes, etc) within a package in the label/shipment creation methods.

Onboarding is accomplished by retrieving a request token, and redirecting user to CP login/signup page with this token, and then listening for a response from CP containing this token and a success flag.

Rating is similar to rate retrieval in other services, it requires a set of shipping options, list of items, etc.. and a list of available shipping services and rates are returned.

Tracking expects a tracking number and a response containing a list of tracking events (location, status, message) are returned.

Label/shipment retrieval is a 2 step process, first the shipment is created with a set of shipping options, line items (containing skus, hs codes, weights, etc), and package details (dimensions, weight), and the resulting shipping_id is used to retrieve the actual printed label (pdf file).

Shipping service methods and available options retrieval is also added. This is useful for a client to display available services and options for those services (where options can depend on each other either as prerequisites or conflicts) since the rating and shipment services are very strict on requiring these option dependencies in requests.

Besides unit tests, remote tests are added for both acting on behalf of merchants and not acting on behalf of merchants. Acting on behalf of merchants is required when creating labels, but not required for the other services.

@jduff and @odorcicd Can you review please, Thanks!