11"""
22Rate Service Module
3- ===================
3+
44This package contains classes to request pre-ship rating information and to
55determine estimated or courtesy billing quotes. Time in Transit can be
66returned with the rates if it is specified in the request.
@@ -33,12 +33,12 @@ def __init__(self, config_obj, *args, **kwargs):
3333 'intermediate' : '0' , 'minor' : '0' }
3434
3535 self .RequestedShipment = None
36- """@ivar: Holds the RequestedShipment WSDL object."""
36+ """@ivar: Holds the RequestedShipment WSDL object including the shipper, recipient and shipt time ."""
3737 # Call the parent FedexBaseService class for basic setup work.
38- super (FedexRateServiceRequest , self ).__init__ (self ._config_obj ,
39- 'RateService_v18.wsdl' ,
40- * args , ** kwargs )
38+ super (FedexRateServiceRequest , self ).__init__ (
39+ self ._config_obj , 'RateService_v18.wsdl' , * args , ** kwargs )
4140 self .ClientDetail .Region = config_obj .express_region_code
41+ """@ivar: Holds the express region code from the config object."""
4242
4343 def _prepare_wsdl_objects (self ):
4444 """
@@ -53,36 +53,34 @@ def _prepare_wsdl_objects(self):
5353 self .RequestedShipment = self .client .factory .create ('RequestedShipment' )
5454 self .RequestedShipment .ShipTimestamp = datetime .datetime .now ()
5555
56- TotalWeight = self .client .factory .create ('Weight' )
56+ # Defaults for TotalWeight wsdl object.
57+ total_weight = self .client .factory .create ('Weight' )
5758 # Start at nothing.
58- TotalWeight .Value = 0.0
59+ total_weight .Value = 0.0
5960 # Default to pounds.
60- TotalWeight .Units = 'LB'
61+ total_weight .Units = 'LB'
6162 # This is the total weight of the entire shipment. Shipments may
6263 # contain more than one package.
63- self .RequestedShipment .TotalWeight = TotalWeight
64+ self .RequestedShipment .TotalWeight = total_weight
6465
6566 # This is the top level data structure for Shipper information.
66- ShipperParty = self .client .factory .create ('Party' )
67- ShipperParty .Address = self .client .factory .create ('Address' )
68- ShipperParty .Contact = self .client .factory .create ('Contact' )
67+ shipper = self .client .factory .create ('Party' )
68+ shipper .Address = self .client .factory .create ('Address' )
69+ shipper .Contact = self .client .factory .create ('Contact' )
6970
7071 # Link the ShipperParty to our master data structure.
71- self .RequestedShipment .Shipper = ShipperParty
72+ self .RequestedShipment .Shipper = shipper
7273
7374 # This is the top level data structure for Recipient information.
74- RecipientParty = self .client .factory .create ('Party' )
75- RecipientParty .Contact = self .client .factory .create ('Contact' )
76- RecipientParty .Address = self .client .factory .create ('Address' )
77-
75+ recipient_party = self .client .factory .create ('Party' )
76+ recipient_party .Contact = self .client .factory .create ('Contact' )
77+ recipient_party .Address = self .client .factory .create ('Address' )
7878 # Link the RecipientParty object to our master data structure.
79- self .RequestedShipment .Recipient = RecipientParty
79+ self .RequestedShipment .Recipient = recipient_party
8080
81- Payor = self .client .factory .create ('Payor' )
82- # Grab the account number from the FedexConfig object by default.
83- Payor .AccountNumber = self ._config_obj .account_number
84- # Assume US.
85- Payor .CountryCode = 'US'
81+ # Make sender responsible for payment by default.
82+ self .RequestedShipment .ShippingChargesPayment = self .create_wsdl_object_of_type ('Payment' )
83+ self .RequestedShipment .ShippingChargesPayment .PaymentType = 'SENDER'
8684
8785 # Start with no packages, user must add them.
8886 self .RequestedShipment .PackageCount = 0
0 commit comments