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)



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

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)



21
22
23
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 21

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

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



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

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



8
9
10
# File 'lib/active_shipping/carriers/new_zealand_post.rb', line 8

def requirements
  [:key]
end