def test_postal_inquiry(self): inquiry = FedexValidatePostalRequest(CONFIG_OBJ) inquiry.Address.PostalCode = '29631' inquiry.Address.CountryCode = 'US' inquiry.send_request() assert inquiry.response assert inquiry.response.HighestSeverity == 'SUCCESS'
def validate_postal_address(self, recipient_address): recipient_details = frappe.db.get_value("Address", recipient_address, "*", as_dict=True) inquiry = FedexValidatePostalRequest(self.config_obj) inquiry.Address.PostalCode = recipient_details.get("pincode") inquiry.Address.CountryCode = recipient_details.get("country_code") inquiry.Address.StreetLines = [recipient_details.get("address_line2"),\ recipient_details.get("address_line1")] inquiry.Address.City = recipient_details.get("city") inquiry.Address.StateOrProvinceCode = recipient_details.get( "state_code") inquiry.send_request() if inquiry.response.HighestSeverity not in [ "SUCCESS", "NOTE", "WARNING" ]: self.show_notification(inquiry) frappe.throw(_('Recipient Address verification failed.'))
# If you'd like to see some documentation on the country service WSDL, un-comment # this line. (Spammy). # print(inquiry.client) # Un-comment this to see your complete, ready-to-send request as it stands # before it is actually sent. This is useful for seeing what values you can # change. # print(inquiry.CarrierCode) # print(inquiry.Address) # print(inquiry.ShipDateTime) # print(inquiry.CheckForMismatch) # print(inquiry.RoutingCode) # Fires off the request, sets the 'response' attribute on the object. inquiry.send_request() # See the response printed out. print(inquiry.response) # Here is the overall end result of the query. print("HighestSeverity: {}".format(inquiry.response.HighestSeverity)) print("") print("State/Province: {}".format(inquiry.response.PostalDetail.StateOrProvinceCode)) print("City First Initial: {}".format(inquiry.response.PostalDetail.CityFirstInitials)) print("Clean Postal Code: {}".format(inquiry.response.PostalDetail.CleanedPostalCode)) for loc_description in inquiry.response.PostalDetail.LocationDescriptions: print("Location ID: {}".format(loc_description.LocationId)) print("Location No.: {}".format(loc_description.LocationNumber))
# If you'd like to see some documentation on the country service WSDL, un-comment # this line. (Spammy). # print(inquiry.client) # Un-comment this to see your complete, ready-to-send request as it stands # before it is actually sent. This is useful for seeing what values you can # change. # print(inquiry.CarrierCode) # print(inquiry.Address) # print(inquiry.ShipDateTime) # print(inquiry.CheckForMismatch) # print(inquiry.RoutingCode) # Fires off the request, sets the 'response' attribute on the object. inquiry.send_request() # See the response printed out. print(inquiry.response) # Here is the overall end result of the query. print("HighestSeverity: {}".format(inquiry.response.HighestSeverity)) print("") print("State/Province: {}".format( inquiry.response.PostalDetail.StateOrProvinceCode)) print("City First Initial: {}".format( inquiry.response.PostalDetail.CityFirstInitials)) print("Clean Postal Code: {}".format( inquiry.response.PostalDetail.CleanedPostalCode))