Class: FedexWebServices::ProcessShipmentRequest
- Defined in:
- lib/fedex_web_services/process_shipment_request.rb
Instance Attribute Summary
Attributes inherited from Request
Class Method Summary collapse
Instance Method Summary collapse
- #customer_invoice!(invoice_number) ⇒ Object
- #customer_reference!(reference) ⇒ Object
- #for_master_tracking_number!(tracking_number) ⇒ Object
-
#initialize ⇒ ProcessShipmentRequest
constructor
A new instance of ProcessShipmentRequest.
- #issue_request(port, credentials) ⇒ Object
- #list_rate! ⇒ Object
- #regular_pickup! ⇒ Object
- #remote_method ⇒ Object
- #sender_paid!(account_number) ⇒ Object
- #service_id ⇒ Object
- #soap_module ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize ⇒ ProcessShipmentRequest
Returns a new instance of ProcessShipmentRequest.
5 6 7 |
# File 'lib/fedex_web_services/process_shipment_request.rb', line 5 def initialize @contents = soap_module::ProcessShipmentRequest.new end |
Class Method Details
.shipment_requests(service_type, from, to, label_specification, package_weights) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/fedex_web_services/process_shipment_request.rb', line 71 def self.shipment_requests(service_type, from, to, label_specification, package_weights) package_weights.map.with_index do |weight, ndx| new.tap do |request| mod = request.soap_module request.contents.requestedShipment = mod::RequestedShipment.new.tap do |rs| rs.shipTimestamp = Time.now.iso8601 rs.serviceType = service_type rs.packagingType = mod::PackagingType::YOUR_PACKAGING rs.shipper = from rs.recipient = to rs.labelSpecification = label_specification rs.packageCount = package_weights.size rs.requestedPackageLineItems = mod::RequestedPackageLineItem.new.tap do |rpli| rpli.sequenceNumber = ndx + 1 rpli.weight = weight end end end end end |
Instance Method Details
#customer_invoice!(invoice_number) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/fedex_web_services/process_shipment_request.rb', line 63 def customer_invoice!(invoice_number) mod = self.soap_module ref = mod::CustomerReference.new(mod::CustomerReferenceType::INVOICE_NUMBER, invoice_number) contents.requestedShipment.requestedPackageLineItems.customerReferences ||= [] contents.requestedShipment.requestedPackageLineItems.customerReferences << ref end |
#customer_reference!(reference) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/fedex_web_services/process_shipment_request.rb', line 55 def customer_reference!(reference) mod = self.soap_module ref = mod::CustomerReference.new(mod::CustomerReferenceType::CUSTOMER_REFERENCE, reference) contents.requestedShipment.requestedPackageLineItems.customerReferences ||= [] contents.requestedShipment.requestedPackageLineItems.customerReferences << ref end |
#for_master_tracking_number!(tracking_number) ⇒ Object
49 50 51 52 53 |
# File 'lib/fedex_web_services/process_shipment_request.rb', line 49 def for_master_tracking_number!(tracking_number) contents.requestedShipment.masterTrackingId = soap_module::TrackingId.new.tap do |ti| ti.trackingNumber = tracking_number end end |
#issue_request(port, credentials) ⇒ Object
25 26 27 |
# File 'lib/fedex_web_services/process_shipment_request.rb', line 25 def issue_request(port, credentials) ProcessShipmentResponse.new(port.send(remote_method, request_contents(credentials))) end |
#list_rate! ⇒ Object
45 46 47 |
# File 'lib/fedex_web_services/process_shipment_request.rb', line 45 def list_rate! contents.requestedShipment.rateRequestTypes = [ soap_module::RateRequestType::LIST ] end |
#regular_pickup! ⇒ Object
41 42 43 |
# File 'lib/fedex_web_services/process_shipment_request.rb', line 41 def regular_pickup! contents.requestedShipment.dropoffType = soap_module::DropoffType::REGULAR_PICKUP end |
#remote_method ⇒ Object
13 14 15 |
# File 'lib/fedex_web_services/process_shipment_request.rb', line 13 def remote_method :processShipment end |
#sender_paid!(account_number) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fedex_web_services/process_shipment_request.rb', line 29 def sender_paid!(account_number) mod = self.soap_module contents.requestedShipment.shippingChargesPayment = mod::Payment.new.tap do |scp| scp.paymentType = mod::PaymentType::SENDER scp.payor = mod::Payor.new scp.payor.responsibleParty = contents.requestedShipment.shipper.dup scp.payor.responsibleParty.accountNumber = account_number end end |
#service_id ⇒ Object
17 18 19 |
# File 'lib/fedex_web_services/process_shipment_request.rb', line 17 def service_id :ship end |
#soap_module ⇒ Object
9 10 11 |
# File 'lib/fedex_web_services/process_shipment_request.rb', line 9 def soap_module FedexWebServices::Soap::Ship end |
#version ⇒ Object
21 22 23 |
# File 'lib/fedex_web_services/process_shipment_request.rb', line 21 def version 12 end |