Add support for frequent delivery addresses via .json files
This commit is contained in:
parent
15614329c4
commit
79240557a1
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,5 +1,7 @@
|
||||||
# Sensitive files
|
# Sensitive files
|
||||||
config.py
|
config.py
|
||||||
|
*.json
|
||||||
|
*.JSON
|
||||||
|
|
||||||
# ---> Python
|
# ---> Python
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
|
|
8
JSON files/default_address.json.sample
Normal file
8
JSON files/default_address.json.sample
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"default_delivery_name" : "Lisa Doe",
|
||||||
|
"default_delivery_number" : "87654321",
|
||||||
|
"default_delivery_email" : "",
|
||||||
|
"default_delivery_address" : "2 Orchard Turn, Singapore 238801",
|
||||||
|
"default_delivery_pincode" : "238801",
|
||||||
|
"default_delivery_remark" : ""
|
||||||
|
}
|
|
@ -12,7 +12,10 @@ These Python scripts allow to place, track and delete delivery requests using th
|
||||||
|
|
||||||
* Copy the file `config-sample.py` to `config.py`.
|
* Copy the file `config-sample.py` to `config.py`.
|
||||||
* Edit `config.py` with your credentials and defaults.
|
* Edit `config.py` with your credentials and defaults.
|
||||||
* To place a delivery request, run `python3 req_delivery.py` and follow the instructions of the script.
|
* Inside the folder `JSON files` copy the `default_address.json.sample` to `default_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 from `default_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 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>`)*.
|
* 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>`)*.
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,4 @@ default_pickup_address = "1 Scotts Road, Singapore 228208"
|
||||||
default_pickup_pincode = "228208"
|
default_pickup_pincode = "228208"
|
||||||
default_pickup_remark = ""
|
default_pickup_remark = ""
|
||||||
default_vehicle = "all"
|
default_vehicle = "all"
|
||||||
default_delivery_name = "Lisa Doe"
|
|
||||||
default_delivery_number = "87654321"
|
|
||||||
default_delivery_email = ""
|
|
||||||
default_delivery_address = "2 Orchard Turn, Singapore 238801"
|
|
||||||
default_delivery_pincode = "238801"
|
|
||||||
default_delivery_remark = ""
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,16 @@ from push import *
|
||||||
import sys
|
import sys
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
def req_delivery():
|
def req_delivery(address_file='default_address.json'):
|
||||||
|
f = open("JSON files/"+address_file)
|
||||||
|
address = json.load(f)
|
||||||
|
f.close()
|
||||||
|
default_delivery_name = address['default_delivery_name']
|
||||||
|
default_delivery_number = address['default_delivery_number']
|
||||||
|
default_delivery_email = address['default_delivery_email']
|
||||||
|
default_delivery_address = address['default_delivery_address']
|
||||||
|
default_delivery_pincode = address['default_delivery_pincode']
|
||||||
|
default_delivery_remark = address['default_delivery_remark']
|
||||||
order_id = int(input('Enter the Order ID: ') or '1')
|
order_id = int(input('Enter the Order ID: ') or '1')
|
||||||
url = base_url + "api/merchant/auth/"
|
url = base_url + "api/merchant/auth/"
|
||||||
payload = json.dumps({
|
payload = json.dumps({
|
||||||
|
@ -123,5 +132,5 @@ def req_delivery():
|
||||||
})))
|
})))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
req_delivery()
|
req_delivery(sys.argv[1])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue