class ActiveShipping::NewZealandPost::NewZealandPostPackage
Public Class Methods
new(package, api)
click to toggle source
# File lib/active_shipping/carriers/new_zealand_post.rb, line 189 def initialize(package, api) @package = package @api = api @params = { :weight => weight, :length => length } end
Public Instance Methods
params()
click to toggle source
# File lib/active_shipping/carriers/new_zealand_post.rb, line 195 def params @params.merge(api_params).merge(shape_params) end
Protected Instance Methods
api_params()
click to toggle source
# File lib/active_shipping/carriers/new_zealand_post.rb, line 222 def api_params send("#{@api}_params") end
cuboid_params()
click to toggle source
# File lib/active_shipping/carriers/new_zealand_post.rb, line 238 def cuboid_params { :height => height, :thickness => width } end
currency()
click to toggle source
# File lib/active_shipping/carriers/new_zealand_post.rb, line 255 def currency @package.currency || "NZD" end
cylinder_params()
click to toggle source
# File lib/active_shipping/carriers/new_zealand_post.rb, line 242 def cylinder_params { :diameter => width } end
domestic_params()
click to toggle source
# File lib/active_shipping/carriers/new_zealand_post.rb, line 230 def domestic_params {} end
height()
click to toggle source
# File lib/active_shipping/carriers/new_zealand_post.rb, line 209 def height mm(:height) end
international_params()
click to toggle source
# File lib/active_shipping/carriers/new_zealand_post.rb, line 226 def international_params { :value => value } end
length()
click to toggle source
# File lib/active_shipping/carriers/new_zealand_post.rb, line 205 def length mm(:length) end
mm(measurement)
click to toggle source
# File lib/active_shipping/carriers/new_zealand_post.rb, line 246 def mm(measurement) @package.cm(measurement) * 10 end
shape()
click to toggle source
# File lib/active_shipping/carriers/new_zealand_post.rb, line 217 def shape return :cylinder if @package.cylinder? :cuboid end
shape_params()
click to toggle source
# File lib/active_shipping/carriers/new_zealand_post.rb, line 234 def shape_params send("#{shape}_params") end
value()
click to toggle source
# File lib/active_shipping/carriers/new_zealand_post.rb, line 250 def value return 0 unless @package.value && currency == "NZD" @package.value / 100 end
weight()
click to toggle source
# File lib/active_shipping/carriers/new_zealand_post.rb, line 201 def weight @package.kg end
width()
click to toggle source
# File lib/active_shipping/carriers/new_zealand_post.rb, line 213 def width mm(:width) end