Class: ActiveShipping::AustraliaPost::ServiceRequest

Inherits:
AustraliaPostRequest show all
Defined in:
lib/active_shipping/carriers/australia_post.rb

Instance Attribute Summary

Attributes inherited from AustraliaPostRequest

#rates, #raw_response, #response

Instance Method Summary collapse

Methods inherited from AustraliaPostRequest

#domestic_destination?, #domestic_params, #international_params, #url

Constructor Details

#initialize(origin, destination, package, options) ⇒ ServiceRequest

Returns a new instance of ServiceRequest.



172
173
174
175
# File 'lib/active_shipping/carriers/australia_post.rb', line 172

def initialize(origin, destination, package, options)
  super
  @endpoints = PARCEL_ENDPOINTS[:service]
end

Instance Method Details

#parse(data) ⇒ Object



177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/active_shipping/carriers/australia_post.rb', line 177

def parse(data)
  super

  @rates = response['services']['service'].map do |service|
    {
      service_name: service['name'],
      service_code: service['code'],
      total_price:  service['price'].to_f,
      currency:     'AUD'
    }
  end
end