trackbert/trackers/postat.py
Kumi a8a7522ff0
Refactor shipment_id assignment in Tracker and trackers/keydelivery.py
The shipment_id assignment has been refactored in the Tracker class and in the keydelivery.py file to set the value as 0 instead of using the tracking_number. This change ensures consistency in assigning the shipment_id across different trackers.
2023-08-24 15:33:09 +02:00

36 lines
No EOL
988 B
Python

from .base import BaseTracker
from classes.database import Event
import json
from dateutil.parser import parse
from postat.classes.api import PostAPI
class PostAT(BaseTracker):
def __init__(self, *args, **kwargs):
pass
def get_status(self, tracking_number, carrier):
api = PostAPI()
status = api.get_shipment_status(tracking_number)
shipment = status["data"]["einzelsendung"]
events = shipment["sendungsEvents"]
for event in events:
timestamp = event["timestamp"]
py_timestamp = parse(timestamp)
event_time = py_timestamp.strftime("%Y-%m-%d %H:%M:%S")
yield Event(
shipment_id = 0,
event_time = event_time,
event_description = event["text"],
raw_event = json.dumps(event)
)
@staticmethod
def supported_carriers():
return [
("austrian_post", 100),
]
tracker = PostAT