Class: ActiveShipping::AustraliaPost::CalculateRequest

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

Instance Attribute Summary collapse

Attributes inherited from AustraliaPostRequest

#rates, #raw_response, #response

Instance Method Summary collapse

Methods inherited from AustraliaPostRequest

#domestic_destination?, #url

Constructor Details

#initialize(origin, destination, package, service_code, options) ⇒ CalculateRequest

Returns a new instance of CalculateRequest.



195
196
197
198
199
200
# File 'lib/active_shipping/carriers/australia_post.rb', line 195

def initialize(origin, destination, package, service_code, options)
  super(origin, destination, package, options)

  @service_code = service_code
  @endpoints    = PARCEL_ENDPOINTS[:calculate]
end

Instance Attribute Details

#service_codeObject (readonly)

Returns the value of attribute service_code.



193
194
195
# File 'lib/active_shipping/carriers/australia_post.rb', line 193

def service_code
  @service_code
end

Instance Method Details

#parse(data) ⇒ Object



202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/active_shipping/carriers/australia_post.rb', line 202

def parse(data)
  super
  postage_result = response['postage_result']

  @rates = [{
    service_name:       postage_result['service'],
    service_code:       service_code,
    total_price:        postage_result['total_cost'].to_f,
    currency:           'AUD',
    delivery_time_text: postage_result['delivery_time']
  }]
end