|
| 1 | +""" |
| 2 | +Location Service Module |
| 3 | +================================= |
| 4 | +This package contains the shipping methods defined by Fedex's |
| 5 | +LocationService WSDL file. Each is encapsulated in a class for |
| 6 | +easy access. For more details on each, refer to the respective class's |
| 7 | +documentation. |
| 8 | +""" |
| 9 | + |
| 10 | +from ..base_service import FedexBaseService |
| 11 | + |
| 12 | + |
| 13 | +class FedexSearchLocationRequest(FedexBaseService): |
| 14 | + """ |
| 15 | + This class allows you validate service availability |
| 16 | + """ |
| 17 | + |
| 18 | + def __init__(self, config_obj, *args, **kwargs): |
| 19 | + """ |
| 20 | + @type config_obj: L{FedexConfig} |
| 21 | + @param config_obj: A valid FedexConfig object. |
| 22 | + """ |
| 23 | + |
| 24 | + self._config_obj = config_obj |
| 25 | + # Holds version info for the VersionId SOAP object. |
| 26 | + self._version_info = { |
| 27 | + 'service_id': 'locs', |
| 28 | + 'major': '3', |
| 29 | + 'intermediate': '0', |
| 30 | + 'minor': '0' |
| 31 | + } |
| 32 | + |
| 33 | + """@ivar: set default objects.""" |
| 34 | + self.Address = None |
| 35 | + self.PhoneNumber = None |
| 36 | + self.MultipleMatchesAction = None |
| 37 | + self.Constraints = [] |
| 38 | + self.LocationsSearchCriterion = None |
| 39 | + |
| 40 | + """@ivar: Holds the WSDL object.""" |
| 41 | + |
| 42 | + super(FedexSearchLocationRequest, self).__init__( |
| 43 | + self._config_obj, 'LocationsService_v3.wsdl', *args, **kwargs) |
| 44 | + |
| 45 | + def _prepare_wsdl_objects(self): |
| 46 | + """ |
| 47 | + Create the data structure and get it ready for the WSDL request. |
| 48 | + """ |
| 49 | + self.MultipleMatchesAction = 'RETURN_ALL' |
| 50 | + self.Constraints = self.create_wsdl_object_of_type('SearchLocationConstraints') |
| 51 | + self.Address = self.create_wsdl_object_of_type('Address') |
| 52 | + |
| 53 | + def _assemble_and_send_request(self): |
| 54 | + """ |
| 55 | + Fires off the Fedex request. |
| 56 | + |
| 57 | + @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), |
| 58 | + WHICH RESIDES ON FedexBaseService AND IS INHERITED. |
| 59 | + """ |
| 60 | + |
| 61 | + # We get an exception like this when specifying an IntegratorId: |
| 62 | + # suds.TypeNotFound: Type not found: 'IntegratorId' |
| 63 | + # Setting it to None does not seem to appease it. |
| 64 | + del self.ClientDetail.IntegratorId |
| 65 | + self.logger.debug(self.WebAuthenticationDetail) |
| 66 | + self.logger.debug(self.ClientDetail) |
| 67 | + self.logger.debug(self.TransactionDetail) |
| 68 | + self.logger.debug(self.VersionId) |
| 69 | + # Fire off the query. |
| 70 | + return self.client.service.searchLocations( |
| 71 | + WebAuthenticationDetail=self.WebAuthenticationDetail, |
| 72 | + ClientDetail=self.ClientDetail, |
| 73 | + TransactionDetail=self.TransactionDetail, |
| 74 | + Version=self.VersionId, |
| 75 | + LocationsSearchCriterion=self.LocationsSearchCriterion, |
| 76 | + PhoneNumber=self.PhoneNumber, |
| 77 | + MultipleMatchesAction=self.MultipleMatchesAction, |
| 78 | + Constraints=self.Constraints, |
| 79 | + Address=self.Address) |
0 commit comments