class ReactiveShipping::AustraliaPost::AustraliaPostRequest
Attributes
rates[R]
raw_response[R]
response[R]
Public Class Methods
new(origin, destination, package, options)
click to toggle source
# File lib/reactive_shipping/carriers/australia_post.rb, line 124 def initialize(origin, destination, package, options) @origin = Location.from(origin) @destination = Location.from(destination) @package = package @rates = [] @options = options end
Public Instance Methods
parse(data)
click to toggle source
# File lib/reactive_shipping/carriers/australia_post.rb, line 139 def parse(data) @raw_response = data @response = JSON.parse(data) end
url()
click to toggle source
# File lib/reactive_shipping/carriers/australia_post.rb, line 132 def url endpoint = domestic_destination? ? @endpoints[:domestic] : @endpoints[:international] params = domestic_destination? ? domestic_params : international_params URI::HTTPS.build(host: HOST, path: endpoint, query: params.to_query).to_s end
Protected Instance Methods
domestic_destination?()
click to toggle source
# File lib/reactive_shipping/carriers/australia_post.rb, line 146 def domestic_destination? @destination.country_code == 'AU' end
domestic_params()
click to toggle source
# File lib/reactive_shipping/carriers/australia_post.rb, line 150 def domestic_params { length: @package.cm(:length), width: @package.cm(:width), height: @package.cm(:height), weight: @package.kilograms.to_f.round(2), from_postcode: @origin.postal_code, to_postcode: @destination.postal_code } end
international_params()
click to toggle source
# File lib/reactive_shipping/carriers/australia_post.rb, line 161 def international_params { weight: @package.kilograms.to_f.round(2), country_code: @destination.country_code } end