From ecde3119271cbd15c4eef8bb691aa5af50db323e Mon Sep 17 00:00:00 2001 From: Kumi Date: Fri, 25 Aug 2023 07:54:34 +0200 Subject: [PATCH] Bump version to 0.1.1 in pyproject.toml & add GLS tracker - Increase version to 0.1.1 in pyproject.toml to show updated version - Add "glsapi" as a new dependency in pyproject.toml for package - Add GLS tracker module - Create GLS class and methods to get status and supported carriers --- pyproject.toml | 3 ++- src/trackbert/trackers/gls.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/trackbert/trackers/gls.py diff --git a/pyproject.toml b/pyproject.toml index 159fc80..5614fdf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "trackbert" -version = "0.1.0" +version = "0.1.1" authors = [ { name="Kumi Mitterer", email="trackbert@kumi.email" }, ] @@ -20,6 +20,7 @@ classifiers = [ dependencies = [ "pykeydelivery", "postat", + "glsapi", "sqlalchemy", "python-dateutil", ] diff --git a/src/trackbert/trackers/gls.py b/src/trackbert/trackers/gls.py new file mode 100644 index 0000000..24817d5 --- /dev/null +++ b/src/trackbert/trackers/gls.py @@ -0,0 +1,34 @@ +from .base import BaseTracker +from ..classes.database import Event + +import json + +from dateutil.parser import parse +from glsapi.classes.api import GLSAPI + + +class GLS(BaseTracker): + def __init__(self, *args, **kwargs): + pass + + def get_status(self, tracking_number, carrier): + api = GLSAPI() + status = api.tracking(tracking_number) + events = status["tuStatus"][0]["history"] + + for event in events: + event_time = f"{event['date']} {event['time']}" + yield Event( + shipment_id=0, + event_time=event_time, + event_description=event["evtDscr"], + raw_event=json.dumps(event), + ) + + def supported_carriers(self): + return [ + ("gls", 100), + ] + + +tracker = GLS