Class: ActiveMerchant::Shipping::NewZealandPost::RateRequest
- Defined in:
- lib/active_shipping/shipping/carriers/new_zealand_post.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#raw_responses ⇒ Object
writeonly
Sets the attribute raw_responses.
-
#urls ⇒ Object
readonly
Returns the value of attribute urls.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(origin, destination, packages, options) ⇒ RateRequest
constructor
A new instance of RateRequest.
- #new_zealand_origin? ⇒ Boolean
- #rate_response ⇒ Object
Constructor Details
#initialize(origin, destination, packages, options) ⇒ RateRequest
Returns a new instance of RateRequest.
57 58 59 60 61 62 63 64 65 |
# File 'lib/active_shipping/shipping/carriers/new_zealand_post.rb', line 57 def initialize(origin, destination, packages, ) @origin = Location.from(origin) @destination = Location.from(destination) @packages = Array(packages).map { |package| NewZealandPostPackage.new(package, api) } @params = { :format => "json", :api_key => [:key] } @test = [:test] @rates = @responses = @raw_responses = [] @urls = @packages.map { |package| url(package) } end |
Instance Attribute Details
#raw_responses=(value) ⇒ Object (writeonly)
Sets the attribute raw_responses
50 51 52 |
# File 'lib/active_shipping/shipping/carriers/new_zealand_post.rb', line 50 def raw_responses=(value) @raw_responses = value end |
#urls ⇒ Object (readonly)
Returns the value of attribute urls.
49 50 51 |
# File 'lib/active_shipping/shipping/carriers/new_zealand_post.rb', line 49 def urls @urls end |
Class Method Details
.from(*args) ⇒ Object
52 53 54 55 |
# File 'lib/active_shipping/shipping/carriers/new_zealand_post.rb', line 52 def self.from(*args) return International.new(*args) unless domestic?(args[0..1]) Domestic.new(*args) end |
Instance Method Details
#new_zealand_origin? ⇒ Boolean
74 75 76 |
# File 'lib/active_shipping/shipping/carriers/new_zealand_post.rb', line 74 def new_zealand_origin? self.class.new_zealand?(@origin) end |
#rate_response ⇒ Object
67 68 69 70 71 72 |
# File 'lib/active_shipping/shipping/carriers/new_zealand_post.rb', line 67 def rate_response @rates = rates NewZealandPostRateResponse.new(true, "success", response_params, ) rescue => error NewZealandPostRateResponse.new(false, error., response_params, ) end |