|
1 | 1 | #!/usr/bin/env python |
2 | 2 | """ |
3 | | -PostalCodeInquiryRequest classes are used to validate and receive additional |
| 3 | +ValidatePostalRequest classes are used to validate and receive additional |
4 | 4 | information about postal codes. |
5 | 5 | """ |
6 | 6 | import logging |
7 | | -import sys |
8 | | - |
9 | 7 | from example_config import CONFIG_OBJ |
10 | | -from fedex.services.package_movement import PostalCodeInquiryRequest |
11 | | -from fedex.tools.conversion import sobject_to_dict |
| 8 | +from fedex.services.country_service import FedexValidatePostalRequest |
12 | 9 |
|
13 | | -# Un-comment to see the response from Fedex printed in stdout. |
14 | | -logging.basicConfig(stream=sys.stdout, level=logging.INFO) |
| 10 | +# Set this to the INFO level to see the response from Fedex printed in stdout. |
| 11 | +logging.basicConfig(level=logging.INFO) |
15 | 12 |
|
16 | 13 | # We're using the FedexConfig object from example_config.py in this dir. |
17 | | -inquiry = PostalCodeInquiryRequest(CONFIG_OBJ) |
18 | | -inquiry.PostalCode = '29631' |
19 | | -inquiry.CountryCode = 'US' |
20 | | - |
21 | | -# If you'd like to see some documentation on the ship service WSDL, un-comment |
| 14 | +customer_transaction_id = "*** ValidatePostal Request v4 using Python ***" # Optional transaction_id |
| 15 | +inquiry = FedexValidatePostalRequest(CONFIG_OBJ, customer_transaction_id=customer_transaction_id) |
| 16 | +inquiry.Address.PostalCode = '29631' |
| 17 | +inquiry.Address.CountryCode = 'US' |
| 18 | +inquiry.Address.StreetLines = ['104 Knox Road'] |
| 19 | +inquiry.Address.City = 'Clemson' |
| 20 | +inquiry.Address.StateOrProvinceCode = 'SC' |
| 21 | + |
| 22 | +# If you'd like to see some documentation on the country service WSDL, un-comment |
22 | 23 | # this line. (Spammy). |
23 | 24 | # print(inquiry.client) |
24 | 25 |
|
25 | 26 | # Un-comment this to see your complete, ready-to-send request as it stands |
26 | 27 | # before it is actually sent. This is useful for seeing what values you can |
27 | 28 | # change. |
28 | 29 | # print(inquiry.CarrierCode) |
29 | | -# print(inquiry.ClientDetail) |
30 | | -# print(inquiry.TransactionDetail) |
| 30 | +# print(inquiry.Address) |
| 31 | +# print(inquiry.ShipDateTime) |
| 32 | +# print(inquiry.CheckForMismatch) |
| 33 | +# print(inquiry.RoutingCode) |
31 | 34 |
|
32 | 35 | # Fires off the request, sets the 'response' attribute on the object. |
33 | 36 | inquiry.send_request() |
34 | 37 |
|
35 | 38 | # See the response printed out. |
36 | | -# print(inquiry.response) |
37 | | - |
38 | | -# This will convert the response to a python dict object. To |
39 | | -# make it easier to work with. |
40 | | -# from fedex.tools.conversion import basic_sobject_to_dict |
41 | | -# print(basic_sobject_to_dict(inquiry.response)) |
42 | | - |
43 | | -# This will dump the response data dict to json. |
44 | | -# from fedex.tools.conversion import sobject_to_json |
45 | | -# print(sobject_to_json(inquiry.response)) |
| 39 | +print(inquiry.response) |
46 | 40 |
|
47 | 41 | # Here is the overall end result of the query. |
48 | 42 | print("HighestSeverity: {}".format(inquiry.response.HighestSeverity)) |
49 | | -print("ExpressFreightContractorDeliveryArea: {}".format(sobject_to_dict(inquiry.response.ExpressDescription))) |
50 | | -print("ExpressDescription: {}".format(sobject_to_dict(inquiry.response.ExpressFreightDescription))) |
| 43 | +print("") |
| 44 | + |
| 45 | +print("State/Province: {}".format(inquiry.response.PostalDetail.StateOrProvinceCode)) |
| 46 | +print("City First Initial: {}".format(inquiry.response.PostalDetail.CityFirstInitials)) |
| 47 | +print("Clean Postal Code: {}".format(inquiry.response.PostalDetail.CleanedPostalCode)) |
| 48 | + |
| 49 | +for loc_description in inquiry.response.PostalDetail.LocationDescriptions: |
| 50 | + print("Location ID: {}".format(loc_description.LocationId)) |
| 51 | + print("Location No.: {}".format(loc_description.LocationNumber)) |
| 52 | + print("Country Code: {}".format(loc_description.CountryCode)) |
| 53 | + print("Postal Code: {}".format(loc_description.PostalCode)) |
| 54 | + print("Service Area: {}".format(loc_description.ServiceArea)) |
| 55 | + print("Airport ID: {}".format(loc_description.AirportId)) |
| 56 | + print("FedEx Europe First Origin: {}".format(loc_description.FedExEuropeFirstOrigin)) |
0 commit comments