diff --git a/.gitignore b/.gitignore
index bef7e43..a46f22f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
# Sensitive files
config.py
+*.json
+*.JSON
# ---> Python
# Byte-compiled / optimized / DLL files
diff --git a/JSON files/default_address.json.sample b/JSON files/default_address.json.sample
new file mode 100644
index 0000000..318cc84
--- /dev/null
+++ b/JSON files/default_address.json.sample
@@ -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" : ""
+}
diff --git a/README.md b/README.md
index cf6001c..3764d9f 100644
--- a/README.md
+++ b/README.md
@@ -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`.
* 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
` and follow the instructions of the script. If you leave the parameter `` blank, the script will use the data from `default_address.json`.
* To track the status of a delivery request, run `python3 track.py `, where `` is the uParcel trucking code of your delivery.
* To cancel a delivery request, run `python3 cancel_delivery.py `, where `` is the Order ID you provided when you made the request *(note that this is NOT the ``)*.
diff --git a/config-sample.py b/config-sample.py
index 297d590..93770e8 100644
--- a/config-sample.py
+++ b/config-sample.py
@@ -22,10 +22,4 @@ default_pickup_address = "1 Scotts Road, Singapore 228208"
default_pickup_pincode = "228208"
default_pickup_remark = ""
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 = ""
diff --git a/req_delivery.py b/req_delivery.py
index f755431..e985f98 100644
--- a/req_delivery.py
+++ b/req_delivery.py
@@ -5,7 +5,16 @@ from push import *
import sys
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')
url = base_url + "api/merchant/auth/"
payload = json.dumps({
@@ -123,5 +132,5 @@ def req_delivery():
})))
if __name__ == '__main__':
- req_delivery()
+ req_delivery(sys.argv[1])