55codes. Defined by the PackageMovementInformationService WSDL file.
66"""
77import logging
8- from .. base_service import FedexBaseService , FedexError
8+ from ..base_service import FedexBaseService , FedexError
9+
910
1011class FedexPostalCodeNotFound (FedexError ):
1112 """
1213 Exception: Sent when the postalcode is missing.
1314 """
1415 pass
1516
17+
1618class FedexInvalidPostalCodeFormat (FedexError ):
1719 """
1820 Exception: Sent when the postal code is invalid
1921 """
2022 pass
2123
24+
2225class PostalCodeInquiryRequest (FedexBaseService ):
2326 """
2427 The postal code inquiry enables customers to validate postal codes
2528 and service commitments.
2629 """
30+
2731 def __init__ (self , config_obj , postal_code = None , country_code = None , * args , ** kwargs ):
2832 """
2933 Sets up an inquiry request. The optional keyword args
@@ -35,19 +39,17 @@ def __init__(self, config_obj, postal_code=None, country_code=None, *args, **kwa
3539 @param country_code: ISO country code to which the postal code belongs to.
3640 """
3741 self ._config_obj = config_obj
38-
42+
3943 # Holds version info for the VersionId SOAP object.
4044 self ._version_info = {'service_id' : 'pmis' , 'major' : '4' ,
41- 'intermediate' : '0' , 'minor' : '0' }
45+ 'intermediate' : '0' , 'minor' : '0' }
4246 self .PostalCode = postal_code
4347 self .CountryCode = country_code
44-
45-
48+
4649 # Call the parent FedexBaseService class for basic setup work.
4750 super (PostalCodeInquiryRequest , self ).__init__ (self ._config_obj ,
48- 'PackageMovementInformationService_v4.wsdl' ,
49- * args , ** kwargs )
50-
51+ 'PackageMovementInformationService_v4.wsdl' ,
52+ * args , ** kwargs )
5153
5254 def _check_response_for_request_errors (self ):
5355 """
@@ -59,19 +61,22 @@ def _check_response_for_request_errors(self):
5961 if notification .Severity == "ERROR" :
6062 if "Postal Code Not Found" in notification .Message :
6163 raise FedexPostalCodeNotFound (notification .Code ,
62- notification .Message )
64+ notification .Message )
6365
6466 elif "Invalid Postal Code Format" in self .response .Notifications :
6567 raise FedexInvalidPostalCodeFormat (notification .Code ,
66- notification .Message )
68+ notification .Message )
6769 else :
6870 raise FedexError (notification .Code ,
6971 notification .Message )
70-
72+
7173 def _prepare_wsdl_objects (self ):
72- pass
73-
74-
74+ """
75+ Preps the WSDL data structures for the user.
76+ """
77+
78+ self .CarrierCode = 'FDXE'
79+
7580 def _assemble_and_send_request (self ):
7681 """
7782 Fires off the Fedex request.
@@ -80,21 +85,20 @@ def _assemble_and_send_request(self):
8085 ON FedexBaseService AND IS INHERITED.
8186 """
8287 client = self .client
83-
84-
88+
8589 # We get an exception like this when specifying an IntegratorId:
8690 # suds.TypeNotFound: Type not found: 'IntegratorId'
8791 # Setting it to None does not seem to appease it.
88-
92+
8993 del self .ClientDetail .IntegratorId
90-
94+
9195 # Fire off the query.
9296 response = client .service .postalCodeInquiry (WebAuthenticationDetail = self .WebAuthenticationDetail ,
93- ClientDetail = self .ClientDetail ,
94- TransactionDetail = self .TransactionDetail ,
95- Version = self .VersionId ,
96- PostalCode = self .PostalCode ,
97- CountryCode = self .CountryCode )
97+ ClientDetail = self .ClientDetail ,
98+ TransactionDetail = self .TransactionDetail ,
99+ Version = self .VersionId ,
100+ PostalCode = self .PostalCode ,
101+ CountryCode = self .CountryCode ,
102+ CarrierCode = self .CarrierCode )
98103
99104 return response
100-
0 commit comments