Class: SimpleShipping::Ups::ShipmentRequest

Inherits:
Request show all
Defined in:
lib/simple_shipping/ups/shipment_request.rb

Overview

Shipment request model.

Constant Summary

Constants inherited from Request

Request::REQUEST_OPTION

Instance Attribute Summary

Attributes inherited from Abstract::Request

#credentials, #type

Instance Method Summary collapse

Methods inherited from Request

#label_specification

Methods inherited from Abstract::Request

#response, #response_class

Constructor Details

#initialize(credentials, shipment, options = {}) ⇒ ShipmentRequest

Returns a new instance of ShipmentRequest.



4
5
6
7
8
9
# File 'lib/simple_shipping/ups/shipment_request.rb', line 4

def initialize(credentials, shipment, options = {})
  @credentials = credentials
  @shipment    = shipment
  @options     = options
  @type        = :process_shipment
end

Instance Method Details

#bodyObject

Builds a request from shipment object.



12
13
14
15
16
17
18
19
20
# File 'lib/simple_shipping/ups/shipment_request.rb', line 12

def body
  { 'common:Request' => {
      'common:RequestOption' => REQUEST_OPTION
    },
    'Shipment'           => ShipmentBuilder.build(@shipment, @options),
    'LabelSpecification' => label_specification,
    :order!              => ['common:Request', 'Shipment', 'LabelSpecification']
  }
end