This documentation outlines the various API routes for the CabShare module, describing the required inputs and expected responses for each route.
- Send emails on various events on success, like booking creation, request acceptance, etc. Following routes require email notifications:
- POST
/bookings
- POST
/bookings/{booking_id}/request
- POST
/bookings/{booking_id}/accept
- POST
/bookings/{booking_id}/reject
- DELETE
/bookings/{booking_id}/self
- DELETE
/bookings/{booking_id}
- Description: Root endpoint to verify the API is operational.
- Request: None
- Response:
200 OK
{ "Hello": "World" }```
- Description: Test endpoint to validate user identity by retrieving the authenticated user's phone number.
- Request Headers:
Authorization: Bearer <JWT_TOKEN>
- Response:
200 OK
{ "phone_number": "1234567890" }```
- Description: Creates a new booking for a cab share.
- Request Body:
{ "from_loc": "IITH Main Gate", "to_loc": "Gachibowli", "start_time": "2024-09-22T10:30:00", "end_time": "2024-09-22T11:30:00", "capacity": 4, "comments": "Heading to office" }```
- Description: Updates the time of an existing booking.
- Request Parameters:
booking_id
: ID of the booking to be updated.
- Request Body:
{ "start_time": "2024-09-22T11:00:00", "end_time": "2024-09-22T12:00:00" }```
- Description: Retrieves bookings where the authenticated user is a traveler.
- Response:
200 OK
{ "past_bookings": [/* past booking objects */], "future_bookings": [/* future booking objects */] }```
- Description: Retrieves pending requests sent by the authenticated user.
- Response:
200 OK
: List of pending requests.
- Description: Searches for available bookings based on locations and time.
- Request Parameters (optional):
from_loc
: Starting locationto_loc
: Destination locationstart_time
: Start time (ISO format)end_time
: End time (ISO format)
- Response:
200 OK
: List of matching bookings.400 Bad Request
: If only one location is provided.
- Description: Requests to join an existing booking.
- Request Parameters:
booking_id
: ID of the booking.
- Request Body:
{ "comments": "Looking for a ride to work." }```
- Response:
200 OK
: Request sent successfully.400 Bad Request
: Request already sent or booking is full.
- Description: Deletes a user's request to join a booking.
- Request Parameters:
booking_id
: ID of the booking.
- Response:
200 OK
: Request deleted successfully.400 Bad Request
: No pending request found.
- Description: Accepts a request for a traveler to join a booking.
- Request Parameters:
booking_id
: ID of the booking.
- Request Body:
{ "requester_email": "traveller@example.com" }
- Response:
200 OK
: Traveler added successfully.400 Bad Request
: No pending request or ride is full.403 Forbidden
: Unauthorized to accept the request.
- Description: Rejects a traveler's request to join a booking.
- Request Parameters:
booking_id
: ID of the booking.
- Request Body:
{ "requester_email": "traveller@example.com" }```
- Response:
200 OK
: Request rejected successfully.
- Description: Deletes an existing booking.
- Request Parameters:
booking_id
: ID of the booking.
- Response:
200 OK
: Booking deleted successfully.403 Forbidden
: Unauthorized to delete the booking.
- Description: Allows a user (not the owner) to exit from a booking.
- Request Parameters:
booking_id
: ID of the booking.
- Response:
200 OK
: Successfully exited from the booking.400 Bad Request
: Owner cannot exit, only delete the ride.