You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
4.1 KiB

CURL COMMANDS:
GET /ping
command : curl -i -X GET localhost:8080
Returns a message "system is up".
GET /listAll
command : curl -X GET localhost:8080/listAll
Returns a serialized list of all packages as a JSON object
POST /addBook
example command (Windows): curl -i -H "Content-Type: application/json" -X POST -d {\"author\":\"test\",\"name\":\"testBook\",\"note\":\"\",\"price\":12.0,\"weight\":5.0,\"expectedDate\":\"2022-08-27T11:59\",\"delivered\":false,\"type\":\"book\"} localhost:8080/addBook
The body of the POST command represents the serialized PackageInfo object of Book type.
The type of fields are:
author: String
name: String
note: String
price: Double
weight: Double
expectedDate: YYYY-MM-DDTHH:MM (LocalDateTime)
delivered: Boolean
type: String
Based on the type of the package, the first field has to be author, expiryDate or handlingFee
Returns the updated packageList as a JSON object.
POST /addPerishable
example command: curl -i -H "Content-Type: application/json" -X POST -d {\"expiryDate\":\"2022-08-31T11:59\",\"name\":\"testPerishable\",\"note\":\"test\",\"price\":15.0,\"weight\":5.0,\"expectedDate\":\"2022-08-27T12:01\",\"delivered\":false,\"type\":\"perishable\"} localhost:8080/addPerishable
The body of the POST command represents the serialized PackageInfo object of Perishable type.
The type of fields are:
expiryDate: YYYY-MM-DDTHH:MM (LocalDateTime)
name: String
note: String
price: Double
weight: Double
expectedDate:YYYY-MM-DDTHH:MM (LocalDateTime)
delivered: Boolean
type: String
Returns the updated packageList as a JSON object.
POST /addElectronic
example command: curl -i -H "Content-Type: application/json" -X POST -d {\"handlingFee\":10.0,\"name\":\"testElectronic\",\"note\":\"none\",\"price\":100.0,\"weight\":10.0,\"expectedDate\":\"2022-08-20T08:30\",\"delivered\":false,\"type\":\"electronic\"} localhost:8080/addElectronic
The body of the POST command represents the serialized PackageInfo object of Electronic type.
The type of fields are:
handlingFee: Double
name: String
note: String
price: Double
weight: Double
expectedDate:YYYY-MM-DDTHH:MM (LocalDateTime)
delivered: Boolean
type: String
Returns the updated packageList as a JSON object.
POST /removePackage
example command: curl -i -H "Content-Type: application/json" -X POST -d {\"author\":\"test\",\"name\":\"testBook\",\"note\":\"\",\"price\":12.0,\"weight\":5.0,\"expectedDate\":\"2022-08-27T11:59\",\"delivered\":false,\"type\":\"book\"} localhost:8080/addBook
User has to ensure the POST command data fields match one of the packages in the packageList. My system allows for removing only the packages in the list, so it acts as an error checking mechanism in itself.
It takes a serialized version of the object to be removed and returns the updated package-list as a JSON object.
POST /markPackageAsDelivered
example command: curl -i -H "Content-Type: application/json" -X POST -d {\"handlingFee\":10.0,\"name\":\"testElectronic\",\"note\":\"none\",\"price\":100.0,\"weight\":10.0,\"expectedDate\":\"2022-08-20T08:30\",\"delivered\":false,\"type\":\"electronic\"} localhost:8080/markPackageAsDelivered
User has to ensure the POST command data fields match one of the packages in the packageList. My system allows for marking as "delivered" only the packages in the list, so it acts as an error checking mechanism in itself.
It takes a serialized version of the object to be marked as "delivered" and returns the updated package-list as a JSON object.
GET /listOverduePackage
command: curl -X GET localhost:8080/listOverduePackage
Returns all undelivered packages with expected delivery data before the current date and time, ordered by their expected delivery dates(oldest first)
It is returned as a list of JSON objects.
GET /listUpcomingPackage
command: curl -X GET localhost:8080/listUpcomingPackage
Returns all upcoming packages with expected delivery data before the current date and time, ordered by their expected delivery dates(oldest first)
It is returned as a list of JSON objects.
GET /exit
command: curl -X GET localhost:8080/exit
Triggers the server to save the current packageList into a JSON file (list.json)