Class: ActiveShipping::NewZealandPost

Inherits:
Carrier
  • Object
show all
Defined in:
lib/active_shipping/carriers/new_zealand_post.rb

Defined Under Namespace

Classes: Domestic, International, NewZealandPostPackage, NewZealandPostRateResponse, RateRequest

Constant Summary collapse

URL =
"http://api.nzpost.co.nz/ratefinder"
@@name =
"New Zealand Post"

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, #maximum_address_field_length, #maximum_weight, #save_request, #timestamp_from_business_day, #valid_credentials?

Constructor Details

This class inherits a constructor from ActiveShipping::Carrier

Class Method Details

.default_locationObject (protected)



27
28
29
30
31
32
33
34
35
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 27

def self.default_location
  Location.new(
    :country => "NZ",
    :city => "Wellington",
    :address1 => "22 Waterloo Quay",
    :address2 => "Pipitea",
    :postal_code => "6011"
  )
end

Instance Method Details

#commit(urls) ⇒ Object (protected)



23
24
25
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 23

def commit(urls)
  save_request(urls).map { |url| ssl_get(url) }
end

#find_rates(origin, destination, packages, options = {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 14

def find_rates(origin, destination, packages, options = {})
  options = @options.merge(options)
  request = RateRequest.from(origin, destination, packages, options)
  request.raw_responses = commit(request.urls) if request.new_zealand_origin?
  request.rate_response
end

#requirementsObject



10
11
12
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 10

def requirements
  [:key]
end