The candidate will create three API endpoints which are mentioned below:
- Park a Car: The Endpoint will be given the car number as input and outputs the slot where it is parked. If the parking lot is full, the appropriate error message is returned.
- Unpark the Car: This endpoint takes the slot number from which the car is to be removed from and frees that slot up to be used by other cars.
- Get the Car/Slot Information: This endpoint can take either the slot number or car number and return both the car number and slot number for the input.
Make a python virtual environment
run pip install -r requirements.txt
run python manage.py migrate
run python manage.py runserver
URL : /park/
Method : POST
Auth required : NO
Permissions required : None
Data example All fields must be sent.
- car_number: Number of Car (String)
{
"car_number": "MP10F9999"
}
Code : 201 Created
Content examples
{
"slot": 1
}
Error Response
{
"error": "Parking is full"
}
URL : /unpark/
Method : POST
Auth required : NO
Permissions required : None
Data example All fields must be sent.
- slot: slot number of car parking (Integer)
{
"slot": "2"
}
Code : 201 Created
Content examples
{
"message": "Car unparked"
}
Error Response
{
"error": "Slot Not Present"
}
URL for getting info from slot : /getparkinginfo?slot=1
URL for getting info from car_number : /getparkinginfo?car_number=MP20F6529
Method : GET
Auth required : NO
Permissions required : None
Code : 200 OK
Content examples
{
"car_number": "MP20F6529"
}
Error Response
{
"error": "No Car parked"
}