MyGLS REST API client
Project description
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
POST
HTTP verb - all model properties use upper camel case naming
Basic usage
-
Create a
GLS
instance: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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mygls-rest-client-1.0.0.tar.gz
.
File metadata
- Download URL: mygls-rest-client-1.0.0.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d52f96b9033e313545ef1e1932e67bf662acf08a1008df6d9453a83e75712f9 |
|
MD5 | 2eb6b02f2e57369ac50f7ad766beb653 |
|
BLAKE2b-256 | 3ef3264fe2bc5efde573fa24859403dda8ec23244ad4db79540284a45ee1a291 |
Provenance
File details
Details for the file mygls_rest_client-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: mygls_rest_client-1.0.0-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26a0531836e745b8a2052b13a4f58e6bd0baa38a02dd4d8bb7e15225bfc7e053 |
|
MD5 | 5b9b27d874193a94dab90a548303e149 |
|
BLAKE2b-256 | 12a2702d072bf0c06316e6d4bd53db5213bcc29e3317939accd568b3b4ff2610 |