Sha256: 4370e8ce8300773d0cf39cb5101367ecf19a615a33d36d61d9af7aeae9b90f4d
Contents?: true
Size: 1.38 KB
Versions: 3
Compression:
Stored size: 1.38 KB
Contents
module ParcelApi # Returns the shipping options and rates available depending on customer, # pick up and destination addresses and parcel dimensions and weight. # Both domestic and international. class ShippingOptions DOMESTIC_URL = '/ShippingOptions/2.0/domestic' INTERNATIONAL_URL = '/ShippingOptions/2.0/international' # Creates a new ParcelApi::ShippingOptions instance. def initialize(connection=nil) @connection ||= connection || ParcelApi::Client.connection end # Search for Domestic (NZ) Shipping Options # @param parcel_params [Hash] parcel parameters # @return [Array] return array of shipping options def get_domestic(parcel_params) response = @connection.get DOMESTIC_URL, parcel_params options = response.body.tap do |so| so.delete('success') so.delete('message_id') end RecursiveOpenStruct.new(options, recurse_over_arrays: true) end # Search for International Shipping Options # @param parcel_params [Hash] parcel parameters # @return [Array] return array of shipping options def get_international(parcel_params) response = @connection.get INTERNATIONAL_URL, parcel_params options = response.body.tap do |so| so.delete('success') so.delete('message_id') end RecursiveOpenStruct.new(options, recurse_over_arrays: true) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
parcel_api-0.4.1 | lib/parcel_api/shipping_options.rb |
parcel_api-0.3.0 | lib/parcel_api/shipping_options.rb |
parcel_api-0.2.0 | lib/parcel_api/shipping_options.rb |