Parking lot service which exposes APIs to park/unpark a vehicle.
Parking lot is divided into three type of slots:
- Motorcycle
- Compact (can be used for both motorcycle and car)
- Large (can be used for motorcycle, car and bus)
- Parking Motorcycle and Car requires only 1 slot whereas Bus need a 5 consective slots in same row.
- For parking Motorcycle, if slot is not available in motorcycle slot, it can be parked in compact/large space depanding upon the availability.
- For parking car, if slot is not available in compact slot, it can be parked in large space depanding upon the availability.
- Bus can only be parked in large space.
GET /slotsReturns a list of slots categorised by slot type and status.GET /slots/:idReturns slot information like slot type, status, parked vehicle type, allotted slots, parking timestamp for given slot-id.POST /slots/parkAccepts avehicle_typeparam and returns aslot_idif vehicle is parked successfully.POST /slots/unparkAccepts aslot_idparam and returns achargesvalue as parking cost to be charged from customer.
You will need Java 8, Leiningen and FoundationDB to run this project.
This project depands upon clj_fdb which is a Clojure library used for interacting with FoundationDB Server. Follow the instructions on library Github page to install this library locally.
Initialize the Parking lot Space
lein run -m parking-lot-service.slots To start a web server for the application, run:
lein run This will start the server on Port 9099. Run below curl command to verify
curl http://localhost:9099/ping Run tests
lein test :all ... Ran 3 tests containing 14 assertions. 0 failures, 0 errors. Build the Jar using below command
lein uberjar Initialize the Parking lot Space
java -cp target/parking-lot-service-0.1.0-standalone.jar parking_lot_service.slots Run the following command to start the API server
java -jar target/parking-lot-service-0.1.0-standalone.jar Use the curl command mentioned above to verify.
Export the Postman Collection to Postman. This collections includes the sample request for all the APIs.