2
Package Movement Information Service
3
====================================
4
This package contains classes to check service availability, route, and postal
5
codes. Defined by the PackageMovementInformationService WSDL file.
8
from .. base_service import FedexBaseService, FedexError
10
class FedexPostalCodeNotFound(FedexError):
12
Exception: Sent when the postalcode is missing.
16
class FedexInvalidPostalCodeFormat(FedexError):
18
Exception: Sent when the postal code is invalid
22
class PostalCodeInquiryRequest(FedexBaseService):
24
The postal code inquiry enables customers to validate postal codes
25
and service commitments.
27
def __init__(self, config_obj, postal_code=None, country_code=None, *args, **kwargs):
29
Sets up an inquiry request. The optional keyword args
30
detailed on L{FedexBaseService} apply here as well.
32
@type config_obj: L{FedexConfig}
33
@param config_obj: A valid FedexConfig object
34
@param postal_code: a valid postal code
35
@param country_code: ISO country code to which the postal code belongs to.
37
self._config_obj = config_obj
39
# Holds version info for the VersionId SOAP object.
40
self._version_info = {'service_id': 'pmis', 'major': '4',
41
'intermediate': '0', 'minor': '0'}
42
self.PostalCode = postal_code
43
self.CountryCode = country_code
46
# Call the parent FedexBaseService class for basic setup work.
47
super(PostalCodeInquiryRequest, self).__init__(self._config_obj,
48
'PackageMovementInformationService_v4.wsdl',
52
def _check_response_for_request_errors(self):
54
Checks the response to see if there were any errors specific to
57
if self.response.HighestSeverity == "ERROR":
58
for notification in self.response.Notifications:
59
if notification.Severity == "ERROR":
60
if "Postal Code Not Found" in notification.Message:
61
raise FedexPostalCodeNotFound(notification.Code,
64
elif "Invalid Postal Code Format" in self.response.Notifications:
65
raise FedexInvalidPostalCodeFormat(notification.Code,
68
raise FedexError(notification.Code,
71
def _prepare_wsdl_objects(self):
75
def _assemble_and_send_request(self):
77
Fires off the Fedex request.
79
@warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES
80
ON FedexBaseService AND IS INHERITED.
85
# We get an exception like this when specifying an IntegratorId:
86
# suds.TypeNotFound: Type not found: 'IntegratorId'
87
# Setting it to None does not seem to appease it.
89
del self.ClientDetail.IntegratorId
92
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)
b'\\ No newline at end of file'