1
1
"""
2
2
Rate Service Module
3
- ===================
3
+
4
4
This package contains classes to request pre-ship rating information and to
5
5
determine estimated or courtesy billing quotes. Time in Transit can be
6
6
returned with the rates if it is specified in the request.
@@ -33,12 +33,12 @@ def __init__(self, config_obj, *args, **kwargs):
33
33
'intermediate' : '0' , 'minor' : '0' }
34
34
35
35
self .RequestedShipment = None
36
- """@ivar: Holds the RequestedShipment WSDL object."""
36
+ """@ivar: Holds the RequestedShipment WSDL object including the shipper, recipient and shipt time ."""
37
37
# 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 )
41
40
self .ClientDetail .Region = config_obj .express_region_code
41
+ """@ivar: Holds the express region code from the config object."""
42
42
43
43
def _prepare_wsdl_objects (self ):
44
44
"""
@@ -53,36 +53,34 @@ def _prepare_wsdl_objects(self):
53
53
self .RequestedShipment = self .client .factory .create ('RequestedShipment' )
54
54
self .RequestedShipment .ShipTimestamp = datetime .datetime .now ()
55
55
56
- TotalWeight = self .client .factory .create ('Weight' )
56
+ # Defaults for TotalWeight wsdl object.
57
+ total_weight = self .client .factory .create ('Weight' )
57
58
# Start at nothing.
58
- TotalWeight .Value = 0.0
59
+ total_weight .Value = 0.0
59
60
# Default to pounds.
60
- TotalWeight .Units = 'LB'
61
+ total_weight .Units = 'LB'
61
62
# This is the total weight of the entire shipment. Shipments may
62
63
# contain more than one package.
63
- self .RequestedShipment .TotalWeight = TotalWeight
64
+ self .RequestedShipment .TotalWeight = total_weight
64
65
65
66
# 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' )
69
70
70
71
# Link the ShipperParty to our master data structure.
71
- self .RequestedShipment .Shipper = ShipperParty
72
+ self .RequestedShipment .Shipper = shipper
72
73
73
74
# 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' )
78
78
# Link the RecipientParty object to our master data structure.
79
- self .RequestedShipment .Recipient = RecipientParty
79
+ self .RequestedShipment .Recipient = recipient_party
80
80
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'
86
84
87
85
# Start with no packages, user must add them.
88
86
self .RequestedShipment .PackageCount = 0
0 commit comments