Class: ActiveMerchant::Shipping::NewZealandPost
- Defined in:
- lib/active_shipping/shipping/carriers/new_zealand_post.rb
Constant Summary collapse
- URL =
"http://workshop.nzpost.co.nz/api/v1/rate.xml"
- @@name =
"New Zealand Post"
Instance Attribute Summary
Attributes inherited from Carrier
Instance Method Summary collapse
-
#find_rates(origin, destination, packages, options = {}) ⇒ Object
Override with whatever you need to get the rates.
- #maximum_weight ⇒ Object
-
#requirements ⇒ Object
Override to return required keys in options hash for initialize method.
Methods inherited from Carrier
#initialize, #valid_credentials?
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Methods included from RequiresParameters
Constructor Details
This class inherits a constructor from ActiveMerchant::Shipping::Carrier
Instance Method Details
#find_rates(origin, destination, packages, options = {}) ⇒ Object
Override with whatever you need to get the rates
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/active_shipping/shipping/carriers/new_zealand_post.rb', line 19 def find_rates(origin, destination, packages, = {}) packages = Array(packages) rate_responses = [] packages.each do |package| if package.tube? request_hash = build_tube_request_params(origin, destination, package, ) else request_hash = build_rectangular_request_params(origin, destination, package, ) end url = URL + '?' + request_hash.to_param response = ssl_get(url) rate_responses << parse_rate_response(origin, destination, package, response, ) end combine_rate_responses(rate_responses, packages) end |
#maximum_weight ⇒ Object
35 36 37 |
# File 'lib/active_shipping/shipping/carriers/new_zealand_post.rb', line 35 def maximum_weight Mass.new(20, :kilograms) end |
#requirements ⇒ Object
Override to return required keys in options hash for initialize method.
14 15 16 |
# File 'lib/active_shipping/shipping/carriers/new_zealand_post.rb', line 14 def requirements [:key] end |