class SimpleShipping::Fedex::Request
Builds a complete request for the FedEx service.
Public Class Methods
new(credentials, shipment)
click to toggle source
Calls superclass method
SimpleShipping::Abstract::Request::new
# File lib/simple_shipping/fedex/request.rb, line 8 def initialize(credentials, shipment) super(credentials) @shipment = shipment end
Public Instance Methods
body(opts = {})
click to toggle source
Build a complete request from a {Shipment shipment} object.
# File lib/simple_shipping/fedex/request.rb, line 14 def body(opts = {}) {'WebAuthenticationDetail' => web_authentication_detail, 'ClientDetail' => client_detail, 'Version' => version, 'RequestedShipment' => ShipmentBuilder.build(@shipment, opts), :order! => ['WebAuthenticationDetail', 'ClientDetail', 'Version', 'RequestedShipment'] } end
Private Instance Methods
client_detail()
click to toggle source
Build the body for the UserCredential element.
@return [Hash]
# File lib/simple_shipping/fedex/request.rb, line 35 def client_detail {'AccountNumber' => @credentials.account_number, 'MeterNumber' => @credentials.meter_number, :order! => ['AccountNumber', 'MeterNumber']} end
version()
click to toggle source
Build the body for the Version element.
@return [Hash]
# File lib/simple_shipping/fedex/request.rb, line 45 def version {'ServiceId' => 'ship', 'Major' => '10', 'Intermediate' => '0', 'Minor' => '0', :order! => ['ServiceId', 'Major', 'Intermediate', 'Minor']} end
web_authentication_detail()
click to toggle source
Build the body for the WebAuthenticationDetail element.
@return [Hash]
# File lib/simple_shipping/fedex/request.rb, line 25 def web_authentication_detail { 'UserCredential' => {'Key' => @credentials.key, 'Password' => @credentials.password, :order! => ['Key', 'Password']}} end