Class: ActiveMerchant::Shipping::NewZealandPost

Inherits:
Carrier show all
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

#last_request, #test_mode

Instance Method Summary collapse

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

#requires!

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, options = {})
  packages = Array(packages)
  rate_responses = []
  packages.each do |package|
    if package.tube?
      request_hash = build_tube_request_params(origin, destination, package, options)
    else
      request_hash = build_rectangular_request_params(origin, destination, package, options)
    end
    url = URL + '?' + request_hash.to_param
    response = ssl_get(url)
    rate_responses << parse_rate_response(origin, destination, package, response, options)
  end
  combine_rate_responses(rate_responses, packages)
end

#maximum_weightObject



35
36
37
# File 'lib/active_shipping/shipping/carriers/new_zealand_post.rb', line 35

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

#requirementsObject

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