# 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](https://gls-group.eu/GROUP/en/home).
## 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](https://github.com/psf/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](https://wiki.c2.com/?UpperCamelCase) naming
## Basic usage
1. 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](gls/settings.py) for supported countries.
1. 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],
)
1. 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(),
)
1. Get printed labels:
from gls import PrintedLabelsResponse
labels: PrintedLabelsResponse = gls.get_printed_labels(parcel_ids=[10023456])
1. 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:
![Label](https://github.com/adamkornafeld/mygls-python/blob/main/parcel.png?raw=true)
## Contributions
Contributions are welcome, please submit a Pull Request.
## Reference
GLS is a trademark and brand of General Logistics Systems Germany GmbH & Co.
Raw data
{
"_id": null,
"home_page": "https://github.com/adamkornafeld/mygls-python",
"name": "mygls-rest-client",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "gls,mygls,api,rest,package,parcel,label,print",
"author": "Adam Kornafeld",
"author_email": "adam@kornafeld.com",
"download_url": "https://files.pythonhosted.org/packages/3e/f3/264fe2bc5efde573fa24859403dda8ec23244ad4db79540284a45ee1a291/mygls-rest-client-1.0.0.tar.gz",
"platform": null,
"description": "# mygls-rest-client\n \n `mygls-rest-client` is a python client for the MyGLS REST API to create printable shipping labels.\n\nBefore you can start interacting with the MyGLS REST API, you need an agreement with GLS. If you\ndon\u2019t have the required MyGLS login credentials please contact [GLS](https://gls-group.eu/GROUP/en/home).\n\n\n## Motivation\n\n> The API development team of GLS has decided to release sample code for C#, PHP, JAVA. \n\nThis project adds Python to mix. \n\n### Under the hood\n\n`mygls-rest-client` uses the [requests](https://github.com/psf/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:\n- all API endpoints use the `POST` HTTP verb\n- all model properties use [upper camel case](https://wiki.c2.com/?UpperCamelCase) naming\n\n## Basic usage\n\n1. Create a `GLS` instance:\n\n from gls import GLS\n\n client_number = 100123456\n username = \"user@gls.hu\"\n password = \"secret\"\n \n gls = GLS(client_number, username, password)\n\n 1.1. Configure settings\n\n from gls import Settings, CountryCode\n\n gls = GLS(client_number, username, password, Settings(country=CountryCode.HR, test=True))\n\n Consult [settings.py](gls/settings.py) for supported countries.\n\n1. Create a parcel label:\n\n from datetime import datetime\n from gls import Address, Parcel\n\n ADDRESS = {\n \"City\": \"Budapest\",\n \"ContactEmail\": \"info@bme.hu\",\n \"ContactName\": \"Dr. Sztoczek J\u00f3zsef\",\n \"ContactPhone\": \"+36 1 463-1111\",\n \"CountryIsoCode\": \"HU\",\n \"HouseNumber\": \"3\",\n \"Name\": \"Budapesti M\u0171szaki \u00e9s Gazdas\u00e1gtudom\u00e1nyi Egyetem\",\n \"Street\": \"M\u0171egyetem rkp.\",\n \"ZipCode\": \"1111\",\n \"HouseNumberInfo\": \"\",\n }\n\n parcel = gls.create_parcel(\n pickup_from = Address(**ADDRESS),\n deliver_to = Address(**ADDRESS),\n pickup_date = datetime.today(),\n reference = \"REF-123\",\n count = 1\n )\n\n parcel_ids = gls.print_labels(\n \"~/label.pdf\", [parcel],\n )\n\n1. Look up parcels by print date:\n\n from gls import ParcelResponse\n from datetime import datetime\n\n parcels: ParcelResponse = gls.get_parcels(\n print_from=datetime.today(),\n print_to=datetime.today(),\n )\n\n1. Get printed labels:\n\n from gls import PrintedLabelsResponse\n\n labels: PrintedLabelsResponse = gls.get_printed_labels(parcel_ids=[10023456])\n\n1. Delete labels:\n\n from gls import DeleteLabelsResponse\n\n parcel_ids = [10023456]\n result: DeleteLabelsResponse = gls.delete_labels(parcel_ids)\n\n\n## Sample Output\n\nHere is an example of how the created label would look like in the saved PDF:\n\n![Label](https://github.com/adamkornafeld/mygls-python/blob/main/parcel.png?raw=true)\n\n\n## Contributions\n\nContributions are welcome, please submit a Pull Request.\n\n## Reference\n\nGLS is a trademark and brand of General Logistics Systems Germany GmbH & Co.\n",
"bugtrack_url": null,
"license": "Apache Software License 2.0 (Apache-2.0)",
"summary": "MyGLS REST API client",
"version": "1.0.0",
"split_keywords": [
"gls",
"mygls",
"api",
"rest",
"package",
"parcel",
"label",
"print"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "5b9b27d874193a94dab90a548303e149",
"sha256": "26a0531836e745b8a2052b13a4f58e6bd0baa38a02dd4d8bb7e15225bfc7e053"
},
"downloads": -1,
"filename": "mygls_rest_client-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5b9b27d874193a94dab90a548303e149",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 13387,
"upload_time": "2022-12-13T21:54:42",
"upload_time_iso_8601": "2022-12-13T21:54:42.988673Z",
"url": "https://files.pythonhosted.org/packages/12/a2/702d072bf0c06316e6d4bd53db5213bcc29e3317939accd568b3b4ff2610/mygls_rest_client-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "2eb6b02f2e57369ac50f7ad766beb653",
"sha256": "3d52f96b9033e313545ef1e1932e67bf662acf08a1008df6d9453a83e75712f9"
},
"downloads": -1,
"filename": "mygls-rest-client-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "2eb6b02f2e57369ac50f7ad766beb653",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 12661,
"upload_time": "2022-12-13T21:54:45",
"upload_time_iso_8601": "2022-12-13T21:54:45.725153Z",
"url": "https://files.pythonhosted.org/packages/3e/f3/264fe2bc5efde573fa24859403dda8ec23244ad4db79540284a45ee1a291/mygls-rest-client-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-13 21:54:45",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "adamkornafeld",
"github_project": "mygls-python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "mygls-rest-client"
}