def location_service(self, credentials, from_address_doc, from_country_doc): from fedex.services.location_service import FedexSearchLocationRequest customer_transaction_id = "*** LocationService Request v3 using Python ***" # Optional transaction_id location_request = FedexSearchLocationRequest(credentials, \ customer_transaction_id=customer_transaction_id) location_request.Constraints.RadiusDistance.Value = self.radius location_request.Constraints.RadiusDistance.Units = self.radius_uom location_request.Address.PostalCode = from_address_doc.pincode[0:10] location_request.Address.CountryCode = from_country_doc.code location_request.send_request() response_dict = sobject_to_dict(location_request.response) frappe.msgprint(str(response_dict))
def test_location_coordinates_search(self): # Test search by geo coordinates # https://www.fedex.com/us/developer/webhelp/ws/2020/US/FedEx_WebServices_2020_Developer_Guide.htm#t=wsdvg%2FLocation_Request_Coding_Details.htm location_request = FedexSearchLocationRequest(CONFIG_OBJ) location_request.LocationsSearchCriterion = 'GEOGRAPHIC_COORDINATES' location_request.Address.CountryCode = 'US' location_request.GeographicCoordinates = '34.074866096127096-118.40365442768258/' location_request.send_request() assert location_request.response.HighestSeverity == 'SUCCESS'
def test_location_phone_search(self): # Test location service phone query location_request = FedexSearchLocationRequest(CONFIG_OBJ) location_request.LocationsSearchCriterion = 'PHONE_NUMBER' location_request.PhoneNumber = '4169297819' location_request.MultipleMatchesAction = 'RETURN_ALL' location_request.Constraints.LocationTypesToInclude = ['FEDEX_AUTHORIZED_SHIP_CENTER'] location_request.Address.PostalCode = 'M5V 1Z0' location_request.Address.CountryCode = 'CA' location_request.send_request() assert location_request.response
""" import logging import sys from example_config import CONFIG_OBJ from fedex.services.location_service import FedexSearchLocationRequest from fedex.tools.conversion import sobject_to_dict # Un-comment to see the response from Fedex printed in stdout. logging.basicConfig(stream=sys.stdout, level=logging.INFO) # This is the object that will be handling our request. # We're using the FedexConfig object from example_config.py in this dir. customer_transaction_id = "*** LocationService Request v3 using Python ***" # Optional transaction_id location_request = FedexSearchLocationRequest( CONFIG_OBJ, customer_transaction_id=customer_transaction_id) # Un-comment to specify the type of search and search criteria. # Can be ADDRESS (default), GEOGRAPHIC_COORDINATES, or PHONE_NUMBER # location_request.LocationsSearchCriterion = 'PHONE_NUMBER' # Un-comment when using PHONE_NUMBER search criterion. # location_request.PhoneNumber = '4169297819' # Un-comment when using GEOGRAPHIC_COORDINATES search criterion. # location_request.GeographicCoordinates = '43.6357-79.5373' # Un-comment to specify how to handle multiple matches. # Can be set to RETURN_ALL (default), RETURN_ERROR, or RETURN_FIRST # location_request.MultipleMatchesAction = 'RETURN_FIRST'
def test_location_address_search(self): # Test search by address, using minimum parameters location_request = FedexSearchLocationRequest(CONFIG_OBJ) location_request.Address.PostalCode = '38119' location_request.Address.CountryCode = 'US'
""" import logging import sys from example_config import CONFIG_OBJ from fedex.services.location_service import FedexSearchLocationRequest from fedex.tools.conversion import sobject_to_dict # Un-comment to see the response from Fedex printed in stdout. logging.basicConfig(stream=sys.stdout, level=logging.INFO) # This is the object that will be handling our request. # We're using the FedexConfig object from example_config.py in this dir. customer_transaction_id = "*** LocationService Request v3 using Python ***" # Optional transaction_id location_request = FedexSearchLocationRequest(CONFIG_OBJ, customer_transaction_id=customer_transaction_id) # Un-comment to specify the type of search and search criteria. # Can be ADDRESS (default), GEOGRAPHIC_COORDINATES, or PHONE_NUMBER # location_request.LocationsSearchCriterion = 'PHONE_NUMBER' # Un-comment when using PHONE_NUMBER search criterion. # location_request.PhoneNumber = '4169297819' # Un-comment when using GEOGRAPHIC_COORDINATES search criterion. # location_request.GeographicCoordinates = '43.6357-79.5373' # Un-comment to specify how to handle multiple matches. # Can be set to RETURN_ALL (default), RETURN_ERROR, or RETURN_FIRST # location_request.MultipleMatchesAction = 'RETURN_FIRST'