Class: ActiveMerchant::Shipping::CanadaPost

Inherits:
Carrier show all
Defined in:
lib/active_shipping/shipping/carriers/canada_post.rb

Defined Under Namespace

Classes: Box, CanadaPostRateResponse, PackedItem, PostalOutlet

Constant Summary collapse

DEFAULT_TURN_AROUND_TIME =
24
URL =
"http://sellonline.canadapost.ca:30000"
DOCTYPE =
'<!DOCTYPE eparcel SYSTEM "http://sellonline.canadapost.ca/DevelopersResources/protocolV3/eParcel.dtd">'
RESPONSE_CODES =
{
 '1'     =>	"All calculation was done",
 '2'     =>	"Default shipping rates are returned due to a problem during the processing of the request.",
 '-2'    => "Missing argument when calling module",
 '-5'	   => "No Item to ship",
 '-6'	   => "Illegal Item weight",
 '-7'	   => "Illegal item dimension",
 '-12'   => "Can't open IM config file",
 '-13'   => "Can't create log files",
 '-15'   => "Invalid config file format",
 '-102'  => "Invalid socket connection",
 '-106'  => "Can't connect to server",
 '-1000' => "Unknow request type sent by client",
 '-1002' => "MAS Timed out",
 '-1004' => "Socket communication break",
 '-1005' => "Did not receive required data on socket.",
 '-2000' => "Unable to estabish socket connection with RSSS",
 '-2001' => "Merchant Id not found on server",
 '-2002' => "One or more parameter was not sent by the IM to the MAS",
 '-2003' => "Did not receive required data on socket.",
 '-2004' => "The request contains to many items to process it.",
 '-2005' => "The request received on socket is larger than the maximum allowed.",
 '-3000' => "Origin Postal Code is illegal",
 '-3001' => "Destination Postal Code/State Name/ Country  is illegal",
 '-3002' => "Parcel too large to be shipped with CPC",
 '-3003' => "Parcel too small to be shipped with CPC",
 '-3004' => "Parcel too heavy to be shipped with CPC",
 '-3005' => "Internal error code returned by the rating DLL",
 '-3006' => "The pick up time format is invalid or not defined.",
 '-4000' => "Volumetric internal error",
 '-4001' => "Volumetric time out calculation error.",
 '-4002' => "No bins provided to the volumetric engine.",
 '-4003' => "No items provided to the volumetric engine.",
 '-4004' => "Item is too large to be packed",
 '-4005' => "Number of item more than maximum allowed",
 '-5000' => "XML Parsing error",
 '-5001' => "XML Tag not found",
 '-5002' => "Node Value Number format error",
 '-5003' => "Node value is empty",
 '-5004' => "Unable to create/parse XML Document",
 '-6000' => "Unable to open the database",
 '-6001' => "Unable to read from the database",
 '-6002' => "Unable to write to the database",
 '-50000' => "Internal problem - Please contact Sell Online Help Desk"
}
NON_ISO_COUNTRY_NAMES =
{
  'Russian Federation' => 'Russia'
}
@@name =
"Canada Post"
@@name_french =
"Postes Canada"

Instance Attribute Summary

Attributes inherited from Carrier

#last_request, #test_mode

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Carrier

#initialize, #valid_credentials?

Constructor Details

This class inherits a constructor from ActiveMerchant::Shipping::Carrier

Class Method Details

.default_locationObject



100
101
102
103
104
105
106
107
108
# File 'lib/active_shipping/shipping/carriers/canada_post.rb', line 100

def self.default_location
  {
    :country => 'CA',
    :province => 'ON',
    :city => 'Ottawa',
    :address1 => '61A York St',
    :postal_code => 'K1N5T2'
  }
end

Instance Method Details

#find_rates(origin, destination, line_items = [], options = {}) ⇒ Object



91
92
93
94
# File 'lib/active_shipping/shipping/carriers/canada_post.rb', line 91

def find_rates(origin, destination, line_items = [], options = {})
  rate_request = build_rate_request(origin, destination, line_items, options)
  commit(rate_request, origin, destination, options)
end

#maximum_weightObject



96
97
98
# File 'lib/active_shipping/shipping/carriers/canada_post.rb', line 96

def maximum_weight
  Mass.new(30, :kilograms)
end

#requirementsObject



87
88
89
# File 'lib/active_shipping/shipping/carriers/canada_post.rb', line 87

def requirements
  [:login]
end