Project

canadapost

0.0
No commit activity in last 3 years
No release in over 3 years
A basic gem to interface with the Canada POST REST API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.3
>= 0

Runtime

 Project Readme

Canadapost

A gem to facilitate Ruby on Rails interaction with Canada Post's REST API.

This is currently the most basic implementation that I needed for a particular project, and only has provisions for obtaining a list of shipping rates. I invite you to extend or improve as you see fit.

Installation

Add this line to your application's Gemfile:

gem 'canadapost'

And then execute:

$ bundle

Or install it yourself as:

$ gem install canadapost

Usage

canada_post = Canadapost.new({
    username: "xxx", 
 	password: "xxx",
	customer_number: 'xxx',
 	development: true (optional) 
 	})

canada_post.origin_postal_code = "xxx"
canada_post.dimensions = {}
canada_post.customer = {}
canada_post.get_rates

get_rates returns a hash of services, including:

  • :service_name
  • :service_code
  • :price_details, with [:due] as the total amount
  • :service_link, with [:href] as the URL
  • :service_standard, with [:expected_transit_time] as the estimated number of days for delivery (from today)

dimension hash {weight: x.x, height: x.x, length: x.x, width: x.x } Weight is kilograms; height, length, width are centimetres

customer hash: for us: { :'united-states' => { :'zip-code' => 'xxxxx' } } for canada: { domestic: { :'postal-code' => 'xxxxxx' } } for international: { international: { :'country-code' => 'xx' } }

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request