Update app.py
Browse files
app.py
CHANGED
|
@@ -243,12 +243,18 @@ def fetch_fedex_tracking_info(tracking_number):
|
|
| 243 |
if 'estimatedDeliveryTimeWindow' in track_results:
|
| 244 |
estimated_delivery = format_date(track_results['estimatedDeliveryTimeWindow'].get('window', {}).get('ends'))
|
| 245 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
return {
|
| 247 |
'status': latest_status.get('statusByLocale', 'N/A'),
|
| 248 |
'courier': 'FedEx',
|
| 249 |
'estimatedDelivery': estimated_delivery,
|
| 250 |
-
'latestLocation':
|
| 251 |
-
'latestCheckpoint': latest_status.get('description', 'N/A'),
|
| 252 |
'lastUpdateDateTime': format_date(latest_status.get('scanDateTime', 'N/A')),
|
| 253 |
'latestEventId': latest_status.get('code', 'N/A'),
|
| 254 |
'rawTimestamp': latest_status.get('scanDateTime', 'N/A')
|
|
|
|
| 243 |
if 'estimatedDeliveryTimeWindow' in track_results:
|
| 244 |
estimated_delivery = format_date(track_results['estimatedDeliveryTimeWindow'].get('window', {}).get('ends'))
|
| 245 |
|
| 246 |
+
# Handle cases where scanLocation might not be available
|
| 247 |
+
if 'scanLocation' in latest_status and 'city' in latest_status['scanLocation']:
|
| 248 |
+
location = f"{latest_status['scanLocation']['city']}, {latest_status['scanLocation'].get('stateOrProvinceCode', 'N/A')}"
|
| 249 |
+
else:
|
| 250 |
+
location = 'N/A'
|
| 251 |
+
|
| 252 |
return {
|
| 253 |
'status': latest_status.get('statusByLocale', 'N/A'),
|
| 254 |
'courier': 'FedEx',
|
| 255 |
'estimatedDelivery': estimated_delivery,
|
| 256 |
+
'latestLocation': location,
|
| 257 |
+
'latestCheckpoint': latest_status.get('description', 'N/A'),
|
| 258 |
'lastUpdateDateTime': format_date(latest_status.get('scanDateTime', 'N/A')),
|
| 259 |
'latestEventId': latest_status.get('code', 'N/A'),
|
| 260 |
'rawTimestamp': latest_status.get('scanDateTime', 'N/A')
|