Skip to content

Repository files navigation

YAML and OpenAPI auto-generated client for GLS API

GLS is a delivery company operating in middle Europe. In this repository there's a gls.yaml file and a simple code for use GLS API described here: I've developed this code because GLS company currently doesn't provide yaml. Gls.yaml file is generated from the provided documentation by AI and heavily modified by myself. Rest of the client is autogenerated from gls.yaml with OpenAPI generator

getprintedlabels.py is a CLI implementation of getPrintedLabels. It can create PDF from:

  • Package Nr. (that code printed on the label)
  • Package ID (internal number in GLS database. It's the number you get from PrepareLabels API call)

Features

  • Behavior can be configured through settings.local.toml or via env. variables starting with prefix GLSLABEL
  • Secrets are stored in .secrets.toml (you must create it)
  • In case the label exists and can't be printed (because of lack of this ability from GLS then a copy of the label is made and the copied label is stored and/or printed)
  • Added printing through GhostScript as an option in case Adobe Acrobat is not working
  • Added getstatus for getting package states Dependencies

  • urllib3
  • python_dateutil
  • pydantic
  • typing-extensions
  • dynaconf
  • hashlib
  • argparse

Installation

  • clone the repository
  • create venv (python -m venv .venv)
  • install the main package (.venv/bin/pip install -e glslabelapi)
  • install the openapi_client generated package (.venv/bin/pip install -e glslabelapi/openapi_client)
  • check, add or modify settings.local.toml and .secrets.toml

Usage

python getprintedlabels.py -id <your-package-id> -o label.pdf -p Expected behavior is you get PDF with label(s) or API error.

(Re)Generate API

npx @openapitools/openapi-generator-cli generate -i gls.yaml -g python -o ./glslabelapi

Current state

  • DeleteLabels and PrepareLabels weren't tested. Check it before you use it.
  • There may be glitches in yaml definition caused by lack of documentation.

About

GLS API yaml + auto-generated openapi client + CLI for downloading the labels

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages