Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bero158/glslabel

GLS API yaml + auto-generated openapi client + CLI for downloading the labels
https://github.com/bero158/glslabel

api-rest cli delivery gls labels openapi openapi-specification python

Last synced: 26 days ago
JSON representation

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

Awesome Lists containing this project

README

        

YAML and OpenAPI auto-generated client for GLS API
==================================================

[GLS](https://gls-group.com) 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:](https://api.mygls.cz/)
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](https://opencollective.com/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)

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 -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.