REST API for Hotel System.
Steps to setup:
- Clone the repository.
git clone https://github.com/Anupam-dagar/RESTAPI.git
- Change directory to repository.
cd RESTAPI
- Run the shell script
run
to setup and run the server locally../run
. It will setup a virtual environment, install requirements and run the server. - To stop serving the website press
ctrl+c
. - If you want to again run the server, use the run script again, it won't setup virtual environment again and install requirements.
To modify the code:
- Run the setup script.
./run
- Stop the server and activate the virtual environment.
source venv/bin/activate
- Run the server using
python3 manage.py runserver
.
API Details:
- To update the details of a room on a given date:
url:/api/room/date-of-booking/
where date of booking should be in the YYYY-MM-DD format.
Request Type:PUT
payload = {
"singleroomaval": integer_string,
"doubleroomaval": integer_string
}
default for both fields is 5. integer_string should be between 0 and 5.
- To update the details of room price on a given date:
url:/api/price/date-of-booking/
where date of booking should be in the YYYY-MM-DD format.
Request Type:PUT
payload = {
"pricesingle": integer_string,
"pricedouble": integer_string
}
both fields are decimal field with upto 2 decimal places. More than 2 decimal places will result in an error. Both should be non negative.
default for both fields is 0.00
-
To get the details of a room on a given date:
url:/api/room/date-of-booking/
where date of booking should be in the YYYY-MM-DD format.
Request Type:GET
-
To get the details of price of a room on a given date:
url:/api/price/date-of-booking/
where date of booking should be in the YYYY-MM-DD format.
Request Type:GET
-
To do bulk operations (updating values in a range of date):
url:/api/bulk/
Request Type:PUT
payload = {
"from_date": YYYY-MM-DD,
"to_date": YYYY-MM-DD,
"days": [1-7],
"room_type": single or double,
"price": integer_string,
"availability": integer_string
}
days
is an array with numbers from 1-7 with each number representing the respective day of the week.
For example monday and tuesday will be sent as [1,2]
.
room_type
is a string with value either single
or double
.
price
is a decimal field with upto 2 decimal places. More than 2 decimal places will result in an error. Price should be non negative.
availability
must be between 0 to 5 only.