Class: ActiveShipping::CanadaPost
- Inherits:
-
Carrier
- Object
- Carrier
- ActiveShipping::CanadaPost
show all
- Defined in:
- lib/active_shipping/carriers/canada_post.rb
Defined Under Namespace
Classes: Box, CanadaPostRateResponse, PackedItem, PostalOutlet
Constant Summary
collapse
- URL =
"http://sellonline.canadapost.ca:30000"
- DTD_NAME =
'eparcel'
- DTD_URI =
"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
#available_services, #cancel_shipment, #create_shipment, #find_tracking_info, #initialize, #save_request, #timestamp_from_business_day, #valid_credentials?
Class Method Details
.default_location ⇒ Object
97
98
99
100
101
102
103
104
105
|
# File 'lib/active_shipping/carriers/canada_post.rb', line 97
def self.default_location
{
:country => 'CA',
:province => 'ON',
:city => 'Ottawa',
:address1 => '61A York St',
:postal_code => 'K1N5T2'
}
end
|
Instance Method Details
#commit(request, origin, destination, options = {}) ⇒ Object
109
110
111
|
# File 'lib/active_shipping/carriers/canada_post.rb', line 109
def commit(request, origin, destination, options = {})
parse_rate_response(ssl_post(URL, request), origin, destination, options)
end
|
#find_rates(origin, destination, line_items = [], options = {}) ⇒ Object
83
84
85
86
|
# File 'lib/active_shipping/carriers/canada_post.rb', line 83
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_address_field_length ⇒ Object
92
93
94
95
|
# File 'lib/active_shipping/carriers/canada_post.rb', line 92
def maximum_address_field_length
44
end
|
#maximum_weight ⇒ Object
88
89
90
|
# File 'lib/active_shipping/carriers/canada_post.rb', line 88
def maximum_weight
Measured::Weight.new(30, :kg)
end
|
#requirements ⇒ Object
79
80
81
|
# File 'lib/active_shipping/carriers/canada_post.rb', line 79
def requirements
[:login]
end
|