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
This commit is contained in:
parent
e4478d4a42
commit
ecde311927
2 changed files with 36 additions and 1 deletions
|
@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "trackbert"
|
name = "trackbert"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
authors = [
|
authors = [
|
||||||
{ name="Kumi Mitterer", email="trackbert@kumi.email" },
|
{ name="Kumi Mitterer", email="trackbert@kumi.email" },
|
||||||
]
|
]
|
||||||
|
@ -20,6 +20,7 @@ classifiers = [
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"pykeydelivery",
|
"pykeydelivery",
|
||||||
"postat",
|
"postat",
|
||||||
|
"glsapi",
|
||||||
"sqlalchemy",
|
"sqlalchemy",
|
||||||
"python-dateutil",
|
"python-dateutil",
|
||||||
]
|
]
|
||||||
|
|
34
src/trackbert/trackers/gls.py
Normal file
34
src/trackbert/trackers/gls.py
Normal file
|
@ -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
|
Loading…
Reference in a new issue