JSON files | ||
.gitignore | ||
__init__.py | ||
cancel_delivery.py | ||
CODE_OF_CONDUCT.md | ||
config-sample.py | ||
CONTRIBUTING.md | ||
LICENSE.md | ||
push.py | ||
README.md | ||
req_delivery.py | ||
SECURITY.md | ||
track.py |
Objective
These Python scripts allow to place, track and delete delivery requests using the uParcel API.
Requirements
- Python installed on the machine running this application.
- Credentials for accessing the uParcel API - you need to request to uParcel for the activation of the API for your account. You will then be able to craete your credentials using the uParcel portal.
- Credentials for writing to a MongDB database - this database will be used for logging the responses from the uParcel API.
How to run this application
- Copy the file
config-sample.py
toconfig.py
. - Edit
config.py
with your credentials and defaults. - Inside the folder
JSON files
copy thedefault_address.json.sample
todefault_address.json
. - Edit
default_address.json
with your defaults for the delivery address. - Using
default_address.json
as a template, you may create personalised.json
files for your frequent delivery addresses. - To place a delivery request, run
python3 req_delivery.py <address.json>
and follow the instructions of the script. If you leave the parameter<address.json>
blank, the script will use the data fromdefault_address.json
. - To track the status of a delivery request, run
python3 track.py <track_id>
, where<track_id>
is the uParcel trucking code of your delivery. - To cancel a delivery request, run
python3 cancel_delivery.py <order_id>
, where<order_id>
is the Order ID you provided when you made the request (note that this is NOT the<track_id>
).
Do you really need a MongoDB database?
-
You don't really need a database at all, this database is only for logging purposes.
-
It is safe to leave the database credentials blank or with bogus data. You will receive an error message each time the script attempts to write to the database, but you can safely ignore this error message.
-
The logic behind having a datase is the following though:
-
You can pass a WEBHOOK URL to the uParcel API where the API can later post any updates to the delivery request. These updates are posted in JSON format. You will need a database if you are interested in logging these updates. We accomplished that by posting those updates to a MongoDB database.
-
The uParcel API posts via the WEBHOOK URL only the events made in their portal, but not the events made via the API, such as the creation or cancellation of the delivery requests by our own scripts, so our scripts will need the ability to post those events to the database too. That is what the script
push.py
does.
-