mygls-rest-client
mygls-rest-client is a python client for the MyGLS REST API to create printable shipping labels.
Before you can start interacting with the MyGLS REST API, you need an agreement with GLS. If you don’t have the required MyGLS login credentials please contact GLS.
Motivation
The API development team of GLS has decided to release sample code for C#, PHP, JAVA.
This project adds Python to mix.
Under the hood
mygls-rest-client uses the requests library to fetch data via the MyGLS API. A couple design decisions to be aware of that this client library has no influence on:
- all API endpoints use the
POSTHTTP verb - all model properties use upper camel case naming
Basic usage
-
Create a
GLSinstance:from gls import GLS client_number = 100123456 username = "user@gls.hu" password = "secret" gls = GLS(client_number, username, password)1.1. Configure settings
from gls import Settings, CountryCode gls = GLS(client_number, username, password, Settings(country=CountryCode.HR, test=True))Consult settings.py for supported countries.
-
Create a parcel label:
from datetime import datetime from gls import Address, Parcel ADDRESS = { "City": "Budapest", "ContactEmail": "info@bme.hu", "ContactName": "Dr. Sztoczek József", "ContactPhone": "+36 1 463-1111", "CountryIsoCode": "HU", "HouseNumber": "3", "Name": "Budapesti Műszaki és Gazdaságtudományi Egyetem", "Street": "Műegyetem rkp.", "ZipCode": "1111", "HouseNumberInfo": "", } parcel = gls.create_parcel( pickup_from = Address(**ADDRESS), deliver_to = Address(**ADDRESS), pickup_date = datetime.today(), reference = "REF-123", count = 1 ) parcel_ids = gls.print_labels( "~/label.pdf", [parcel], ) -
Look up parcels by print date:
from gls import ParcelResponse from datetime import datetime parcels: ParcelResponse = gls.get_parcels( print_from=datetime.today(), print_to=datetime.today(), ) -
Get printed labels:
from gls import PrintedLabelsResponse labels: PrintedLabelsResponse = gls.get_printed_labels(parcel_ids=[10023456]) -
Delete labels:
from gls import DeleteLabelsResponse parcel_ids = [10023456] result: DeleteLabelsResponse = gls.delete_labels(parcel_ids)
Sample Output
Here is an example of how the created label would look like in the saved PDF:
Contributions
Contributions are welcome, please submit a Pull Request.
Reference
GLS is a trademark and brand of General Logistics Systems Germany GmbH & Co.
Release files for mygls-rest-client 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mygls-rest-client-1.0.0.tar.gz | 12.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mygls_rest_client-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.0 kB
Release files / mygls-rest-client-1.0.0.tar.gz
| Download URL | mygls-rest-client-1.0.0.tar.gz |
|---|---|
| Size | 12.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3d52f96b9033e313545ef1e1932e67bf662acf08a1008df6d9453a83e75712f9
|
|
BLAKE2b-256 checksum How to use checksums |
3ef3264fe2bc5efde573fa24859403dda8ec23244ad4db79540284a45ee1a291
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|
Release files / mygls_rest_client-1.0.0-py3-none-any.whl
| Download URL | mygls_rest_client-1.0.0-py3-none-any.whl |
|---|---|
| Size | 13.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
26a0531836e745b8a2052b13a4f58e6bd0baa38a02dd4d8bb7e15225bfc7e053
|
|
BLAKE2b-256 checksum How to use checksums |
12a2702d072bf0c06316e6d4bd53db5213bcc29e3317939accd568b3b4ff2610
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|