Skip to content
RESTAPI for Hotel Management System
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
RESTAPI
api
.gitignore
README.md
manage.py
requirements.txt
run

README.md

REST API for Hotel System.

Steps to setup:

  1. Clone the repository. git clone https://github.com/Anupam-dagar/RESTAPI.git
  2. Change directory to repository. cd RESTAPI
  3. 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.
  4. To stop serving the website press ctrl+c.
  5. 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:

  1. Run the setup script. ./run
  2. Stop the server and activate the virtual environment. source venv/bin/activate
  3. Run the server using python3 manage.py runserver.

API Details:

  1. 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.

  1. 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

  1. 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

  2. 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

  3. 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.

You can’t perform that action at this time.