Class: ShippingCalc::DHL
- Inherits:
-
Object
- Object
- ShippingCalc::DHL
- Defined in:
- lib/shipping_calc/dhl.rb
Overview
Current version on their website is 1.0 and can be found in: https://eCommerce.airborne.com/ApiLandingTest.asp . To get full access to all their stuff you have to make sure they certify your application against their live platform tests. The test bed should be enough to get simple calculations. Currently, only shipments made inside the US are available.
Instance Method Summary collapse
-
#quote(params) ⇒ Object
Obtains an estimate quote from the DHL site.
Instance Method Details
#quote(params) ⇒ Object
Obtains an estimate quote from the DHL site. params is a hash with all the settings for the shipment. They are:
:api_user:: API access username, provided by DHL. :api_password:: API access password, provided by DHL. :shipping_key:: API shipping key, provided by DHL. :account_num:: Account number, provided by DHL. :date:: Date for the shipping in format YYYY-MM-DD (defaults to Time.now). :service_code:: Service code defined in Rate Estimate Specification(E, N, S, G). 1030 and SAT are not supported yet. Defaults to G (ground service). :shipment_code:: ShipmentType code defined in the Rate Estimate Specification. "P" for Package or "L" for Letter. Defaults to "P". :weight:: Order's weight. If the shipment code is a "L" (letter) then the weight will be 0. :to_zip:: Recipient's zip code. :to_country:: Recipient's country. Not used, currently DHL only supports US. :to_state:: Recipient's state.
53 54 55 56 57 58 59 60 61 |
# File 'lib/shipping_calc/dhl.rb', line 53 def quote(params) @xml = xml = Document.new xml << XMLDecl.new("1.0' encoding='UTF-8") raise ShippingCalcError.new("Invalid parameters") if params.nil? raise ShippingCalcError.new("Missing shipping parameters") unless params.keys.length == 10 auth(params[:api_user], params[:api_password]) rate_estimate(params) request end |