55ShipService WSDL file. Each is encapsulated in a class for easy access.
66For more details on each, refer to the respective class's documentation.
77"""
8+ from datetime import datetime
89from .. base_service import FedexBaseService
910
1011class FedexShipRequest (FedexBaseService ):
@@ -35,19 +36,97 @@ def __init__(self, config_obj, tracking_value,
3536 self ._config_obj = config_obj
3637
3738 # Holds version info for the VersionId SOAP object.
38- self ._version_info = {'service_id' : 'trck ' , 'major' : '7' ,
39+ self ._version_info = {'service_id' : 'ship ' , 'major' : '7' ,
3940 'intermediate' : '0' , 'minor' : '0' }
4041 # Call the parent FedexBaseService class for basic setup work.
4142 super (FedexShipRequest , self ).__init__ (self ._config_obj ,
4243 'ShipService_v7.wsdl' ,
4344 * args , ** kwargs )
4445
45- def __set_transactional_detail (self ):
46+ def __set_requested_shipment (self ):
4647 """
48+ This is the data that will be used to create your shipment. Create
49+ the data structure and get it ready for the WSDL request.
4750 """
48- TransactionDetail = self .client .factory .create ('TransactionDetail' )
49- self .logger .info (TransactionDetail )
50- self .TransactionDetail = TransactionDetail
51+ RequestedShipment = self .client .factory .create ('RequestedShipment' )
52+ RequestedShipment .ShipTimestamp = datetime .now ()
53+ RequestedShipment .DropoffType = 'REGULAR_PICKUP' # REGULAR_PICKUP, REQUEST_COURIER, DROP_BOX, BUSINESS_SERVICE_CENTER and STATION
54+ RequestedShipment .ServiceType = 'PRIORITY_OVERNIGHT' # valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND
55+ RequestedShipment .PackagingType = 'FEDEX_PAK' # valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING
56+
57+ Weight = self .client .factory .create ('Weight' )
58+ Weight .Value = 50.0
59+ Weight .Units = 'LB' # LB or KG
60+ # Assemble
61+ RequestedShipment .TotalWeight = Weight
62+
63+ """
64+ Begin shipper info.
65+ """
66+ ShipperParty = self .client .factory .create ('Party' )
67+ ShipperContact = self .client .factory .create ('Contact' )
68+ ShipperContact .PersonName = 'Sender Name'
69+ ShipperContact .CompanyName = 'Some Company'
70+ ShipperContact .PhoneNumber = '9012638716'
71+ # Assemble
72+ ShipperParty .Contact = ShipperContact
73+
74+ ShipperAddress = self .client .factory .create ('Address' )
75+ ShipperAddress .StreetLines = ['Address Line 1' ]
76+ ShipperAddress .City = 'Herndon'
77+ ShipperAddress .StateOrProvinceCode = 'VA'
78+ ShipperAddress .PostalCode = '20171'
79+ ShipperAddress .CountryCode = 'US'
80+ ShipperAddress .Residential = True
81+ # Assemble
82+ ShipperParty .Address = ShipperAddress
83+ # Assemble
84+ RequestedShipment .Shipper = ShipperParty
85+ """
86+ End shipper info.
87+ """
88+
89+ """
90+ Begin recipient info.
91+ """
92+ RecipientParty = self .client .factory .create ('Party' )
93+ RecipientContact = self .client .factory .create ('Contact' )
94+ RecipientContact .PersonName = 'Recipient Name'
95+ RecipientContact .CompanyName = 'Recipient Company'
96+ RecipientContact .PhoneNumber = '9012637906'
97+ # Assemble
98+ RecipientParty .Contact = RecipientContact
99+
100+ RecipientAddress = self .client .factory .create ('Address' )
101+ RecipientAddress .StreetLines = ['Address Line 1' ]
102+ RecipientAddress .City = 'Herndon'
103+ RecipientAddress .StateOrProvinceCode = 'VA'
104+ RecipientAddress .PostalCode = '20171'
105+ RecipientAddress .CountryCode = 'US'
106+ RecipientAddress .Residential = True
107+ # Assemble
108+ RecipientParty .Address = RecipientAddress
109+ # Assemble
110+ RequestedShipment .Recipient = RecipientParty
111+ """
112+ End recipient info.
113+ """
114+
115+ ShippingChargesPayment = self .client .factory .create ('Payment' )
116+ ShippingChargesPayment .PaymentType = 'SENDER' # RECIPIENT, SENDER and THIRD_PARTY
117+ Payor = self .client .factory .create ('Payor' )
118+ Payor .AccountNumber = self ._config_obj .account_number
119+ Payor .CountryCode = 'US'
120+ ShippingChargesPayment .Payor = Payor
121+ # Assemble
122+ RequestedShipment .ShippingChargesPayment = ShippingChargesPayment
123+
124+ RequestedShipment .RateRequestTypes = ['ACCOUNT' ] # ACCOUNT and LIST
125+ RequestedShipment .PackageCount = 1
126+ RequestedShipment .PackageDetail = 'INDIVIDUAL_PACKAGES'
127+
128+ self .logger .debug (RequestedShipment )
129+ self .RequestedShipment = RequestedShipment
51130
52131 def _assemble_and_send_request (self ):
53132 """
@@ -56,14 +135,19 @@ def _assemble_and_send_request(self):
56135 @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES
57136 ON FedexBaseService AND IS INHERITED.
58137 """
59- self .__set_transactional_detail ()
138+ self .__set_requested_shipment ()
60139 client = self .client
61140 # Fire off the query.
141+ response = client .service .processShipment (WebAuthenticationDetail = self .WebAuthenticationDetail ,
142+ ClientDetail = self .ClientDetail ,
143+ TransactionDetail = self .TransactionDetail ,
144+ Version = self .VersionId ,
145+ RequestedShipment = self .RequestedShipment )
62146 """
63147 processShipment(WebAuthenticationDetail WebAuthenticationDetail,
64148 ClientDetail ClientDetail,
65149 TransactionDetail TransactionDetail,
66150 VersionId Version,
67151 RequestedShipment RequestedShipment)
68152 """
69- # return response
153+ return response
0 commit comments