Class: SimpleShipping::Fedex::PackageBuilder

Inherits:
Abstract::Builder show all
Defined in:
lib/simple_shipping/fedex/package_builder.rb

Overview

Knows how to convert Package model to SOAP element for FedEx.

Constant Summary collapse

WEIGHT_UNITS =

FedEx mapping for weight units.

{:kg => 'KG',
:lb => 'LB'}
DIMENSION_UNITS =

FedEx mapping for dimension units.

{:in => 'IN',
:cm => 'CM'}

Instance Method Summary collapse

Methods inherited from Abstract::Builder

build, set_default_opts, #validate

Instance Method Details

#buildObject

Build a SOAP package element as a hash for Savon.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/simple_shipping/fedex/package_builder.rb', line 12

def build
  { 'Weight'     => {'Units' => WEIGHT_UNITS[@model.weight_units],
                     'Value' => @model.weight,
                     :order! => ['Units', 'Value']},
    'Dimensions' => {'Length' => @model.length,
                     'Width'  => @model.width,
                     'Height' => @model.height,
                     'Units'  => DIMENSION_UNITS[@model.dimension_units],
                     :order!  => ['Length', 'Width', 'Height', 'Units']},
    :order! => ['Weight',  'Dimensions']}
end