forked from python-fedex-devs/python-fedex
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrack_shipment.py
More file actions
executable file
·30 lines (25 loc) · 1.05 KB
/
track_shipment.py
File metadata and controls
executable file
·30 lines (25 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
"""
This example shows how to track shipments.
"""
import logging
from example_config import CONFIG_OBJ
from fedex.services.track_service import FedexTrackRequest
# Set this to the INFO level to see the response from Fedex printed in stdout.
logging.basicConfig(level=logging.INFO)
# NOTE: TRACKING IS VERY ERRATIC ON THE TEST SERVERS. YOU MAY NEED TO USE
# PRODUCTION KEYS/PASSWORDS/ACCOUNT #.
# We're using the FedexConfig object from example_config.py in this dir.
track = FedexTrackRequest(CONFIG_OBJ)
track.TrackPackageIdentifier.Type = 'TRACKING_NUMBER_OR_DOORTAG'
track.TrackPackageIdentifier.Value = '798114182456'
# Fires off the request, sets the 'response' attribute on the object.
track.send_request()
# See the response printed out.
print track.response
# Look through the matches (there should only be one for a tracking number
# query), and show a few details about each shipment.
print "== Results =="
for match in track.response.TrackDetails:
print "Tracking #:", match.TrackingNumber
print "Status:", match.StatusDescription