项目作者: pratik149

项目描述 :
API endpoints for a Car Rental Agency built using Django REST Framework
高级语言: Python
项目地址: git://github.com/pratik149/car-rental-agency.git
创建时间: 2020-02-17T19:23:17Z
项目社区:https://github.com/pratik149/car-rental-agency

开源协议:

下载


Car-Rental-Agency

API endpoints for a Car Rental Agency built using Django REST Framework.
An assignment given by ClinicSpots.

API hosted on:

https://car149.herokuapp.com/

Note: DB schema can be found in db-schema.pdf file.

API endpoints according to tasks:

I. Add new cars to the system, which could be used for renting

  1. POST:
  2. Desc: API to add new cars
  3. Live link: https://car149.herokuapp.com/car/add/
  4. Expects:
  5. {
  6. "vehicle_number": "8585",
  7. "model": "Etios",
  8. "seating_capacity": 5,
  9. "rent_per_day": 5000
  10. }

II. Book an available car.

  1. POST method:
  2. Live link: https://car149.herokuapp.com/rent/book/
  3. Expects:
  4. {
  5. "customer": 2,
  6. "car": 3,
  7. "issue_date": "2020-02-20",
  8. "return_date": "2020-02-22"
  9. }

III. Show the details of a particular car with its availability and its currently active booking details if not available.

  1. GET method:
  2. Format: https://car149.herokuapp.com/car/<int:car_pk>/active_booking/
  3. Live link: https://car149.herokuapp.com/car/1/active_booking/

IV. Show the cars with their availability status on a given date. This API should have the feature to filter the cars based on various fields.

  1. GET method:
  2. Desc: Returns list of all cars with status on given date. When the date is not given then it takes today's date. User can filter by fields like model, seating_capacity, availability.
  3. Format: https://car149.herokuapp.com/car/status/?date=YYYY-MM-DD&model=STR&capacity=NUM&availability=BOOL
  4. Live link 1: https://car149.herokuapp.com/car/status/?date=2020-03-04
  5. Live link 2: https://car149.herokuapp.com/car/status/?model=Scorpio&capacity=8
  6. Live link 3: https://car149.herokuapp.com/car/status/?availability=True

V. Extend the booking of the car, if the car is not already reserved for the dates user wants to extend the booking.

  1. PUT method:
  2. Desc: Extends the return date.
  3. Format: https://car149.herokuapp.com/rent/<int:rent_pk>/extend/
  4. Live link: https://car149.herokuapp.com/rent/3/extend/
  5. Expects:
  6. {
  7. "customer": 5,
  8. "car": 1,
  9. "issue_date": "2020-02-26",
  10. "return_date": "2020-02-30"
  11. }

VI. Cancel a specific Booking.

  1. DELETE method:
  2. Format: https://car149.herokuapp.com/rent/<int:rent_pk>/cancel/
  3. Live link: https://car149.herokuapp.com/rent/5/cancel/

Other useful API endpoints:

1. For Car

View all cars
  1. GET method:
  2. Live Link: https://car149.herokuapp.com/car/
View particular car details
  1. GET method:
  2. Format: https://car149.herokuapp.com/car/<int:car_pk>/
  3. Live link: https://car149.herokuapp.com/car/2/
Update Car details
  1. PUT method:
  2. Format : https://car149.herokuapp.com/car/<int:car_pk>/update/
  3. Live link: https://car149.herokuapp.com/car/2/update/
  4. Expects:
  5. {
  6. "vehicle_number": "7888",
  7. "model": "Swift",
  8. "seating_capacity": 5,
  9. "rent_per_day": 3000
  10. }
Delete car
  1. DELETE method:
  2. Format: https://car149.herokuapp.com/car/<int:car_pk>/delete/
  3. Live link: https://car149.herokuapp.com/car/4/delete/

2. For Customer

View all customer
  1. GET method:
  2. Live link: https://car149.herokuapp.com/customer/
View particular customer details
  1. GET method:
  2. Format: https://car149.herokuapp.com/customer/<int:cust_pk>/
  3. Live link: https://car149.herokuapp.com/customer/2/
Add customer
  1. POST method:
  2. Live link: https://car149.herokuapp.com/customer/add/
  3. Expects:
  4. {
  5. "name": "Steven Holt",
  6. "email": "steven@gmail.com",
  7. "phone": "9855754754"
  8. }
Update customer details
  1. PUT method:
  2. Format : https://car149.herokuapp.com/customer/<int:pk>/update/
  3. Live link: https://car149.herokuapp.com/customer/2/update/
  4. Expects:
  5. {
  6. "vehicle_number": "7888",
  7. "model": "Swift",
  8. "seating_capacity": 5,
  9. "rent_per_day": 3000
  10. }
Delete customer
  1. DELETE method:
  2. Format: https://car149.herokuapp.com/customer/<int:cust_pk>/delete/
  3. Live link: https://car149.herokuapp.com/customer/4/delete/

3. For Reservation

View all reservations
  1. GET method:
  2. Live link: https://car149.herokuapp.com/rent/
View particular reservation details
  1. GET method:
  2. Format: https://car149.herokuapp.com/rent/<int:rent_pk>/
  3. Live link: https://car149.herokuapp.com/rent/2/