Class: Fedex::WebServices::Request::ProcessShipment

Inherits:
Base
  • Object
show all
Defined in:
lib/fedex/web_services/request/process_shipment.rb

Constant Summary

Constants included from Definitions

Definitions::MODULE_PATH

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Definitions

#generate_definitions, #load_definitions

Constructor Details

#initialize(service, service_type, shipper, recipient, label_specification, package_count, requested_package_line_items) ⇒ ProcessShipment

Returns a new instance of ProcessShipment.



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fedex/web_services/request/process_shipment.rb', line 26

def initialize(service, service_type, shipper, recipient,
    label_specification, package_count, requested_package_line_items)

  super(service)

  @service_type = service_type
  @shipper = shipper
  @recipient = recipient
  @label_specification = label_specification
  @package_count = package_count
  @requested_package_line_items = requested_package_line_items
end

Class Method Details

.mps_requests(service, service_type, shipper, recipient, label_specification, package_weights) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fedex/web_services/request/process_shipment.rb', line 5

def self.mps_requests(service, service_type, shipper, recipient,
    label_specification, package_weights)

  package_weights.map.with_index do |weight, index|
    requested_package_line_item = RequestedPackageLineItem.new.tap do |o|
      o.sequenceNumber = index + 1
      o.weight = weight
    end

    ProcessShipment.new(
      service,
      service_type,
      shipper,
      recipient,
      label_specification,
      package_weights.size,
      [ requested_package_line_item ]
    )
  end
end

Instance Method Details

#contentsObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/fedex/web_services/request/process_shipment.rb', line 43

def contents
  ProcessShipmentRequest.new.tap do |o|
    o.webAuthenticationDetail = web_authentication_detail
    o.version                 = version
    o.clientDetail            = client_detail

    o.requestedShipment = RequestedShipment.new.tap do |o|
      o.shipTimestamp = Time.now.iso8601
      o.dropoffType   = DropoffType::REGULAR_PICKUP
      o.serviceType   = @service_type
      o.packagingType = PackagingType::YOUR_PACKAGING

      o.shipper   = @shipper
      o.recipient = @recipient

      o.shippingChargesPayment = Payment.new.tap do |o|
        o.paymentType = PaymentType::SENDER
        o.payor = Payor.new.tap do |o|
          o.accountNumber = @service.credentials.
        end
      end

      o.labelSpecification = @label_specification

      o.rateRequestTypes = [ RateRequestType::LIST ]

      o.requestedPackageLineItems = @requested_package_line_items
      o.packageCount = @package_count
    end
  end
end

#remote_methodObject



39
40
41
# File 'lib/fedex/web_services/request/process_shipment.rb', line 39

def remote_method
  :processShipment
end