The Room Booking API is a RESTful service that allows users to manage room bookings. Users can check available rooms, create bookings, and validate room availability based on specified time ranges. This API is designed for ease of use and security, ensuring that only valid bookings are processed.
- User Authentication: Secure endpoints with JWT-based authentication.
- Room Management: Create, read, update, and delete room information.
- Booking Management: Create bookings, check availability, and validate booking times.
- Availability Check: Users can check which rooms are available for a given time range.
- Java 17
- Spring Boot
- Spring Data JPA
- H2 Database
- Maven
This document provides an overview of the RoomBookingAPI endpoints, including authentication, room management, and booking functionalities.
All endpoints are relative to: http://localhost:8081/api
- URL:
/api/auth/signup - Method: POST
- Headers: None
- Request Body:
{
"username": "string",
"email": "string",
"password": "string",
"role": "ROLE_ADMIN"
}- Response: User registration confirmation
- URL:
/api/auth/signin - Method: POST
- Headers: None
- Request Body:
{
"username": "string",
"password": "string"
}- Response: JWT token for authentication
- URL:
/api/auth/signout - Method: POST
- Headers:
- Authorization: Bearer {JWT_TOKEN}
- Response: Logout confirmation
- URL:
/api/users/ - Method: GET
- Headers:
- Authorization: Bearer {JWT_TOKEN}
- Response: List of user objects
- URL:
/api/rooms/ - Method: GET
- Headers:
- Authorization: Bearer {JWT_TOKEN}
- Response: List of room objects
- URL:
/api/rooms/ - Method: POST
- Headers:
- Authorization: Bearer {JWT_TOKEN}
- Request Body:
{
"name": "string",
"capacity": "integer",
"availability": "boolean"
}- Response: Created room object
- URL:
/api/rooms/{id} - Method: GET
- Headers:
- Authorization: Bearer {JWT_TOKEN}
- Response: Room object
- URL:
/api/rooms/{id} - Method: PUT
- Headers:
- Authorization: Bearer {JWT_TOKEN}
- Request Body:
{
"name": "string",
"capacity": "integer",
"availability": "boolean"
}- Response: Updated room object
- URL:
/api/rooms/{id} - Method: DELETE
- Headers:
- Authorization: Bearer {JWT_TOKEN}
- Response: Deletion confirmation
- URL:
/api/rooms/available - Method: POST
- Headers:
- Authorization: Bearer {JWT_TOKEN}
- Request Body:
{
"startTime": "yyyy-MM-ddTHH:mm:ss",
"endTime": "yyyy-MM-ddTHH:mm:ss"
}- Response: List of available room objects
- URL:
/api/bookings/ - Method: POST
- Headers:
- Authorization: Bearer {JWT_TOKEN}
- Request Body:
{
"roomId": "integer",
"capacity": "integer",
"startTime": "yyyy-MM-ddTHH:mm:ss",
"endTime": "yyyy-MM-ddTHH:mm:ss"
}- Response: Created booking object
- URL:
/api/bookings/{id} - Method: GET
- Headers:
- Authorization: Bearer {JWT_TOKEN}
- Response: Booking object
- URL:
/api/bookings/{id} - Method: PUT
- Headers:
- Authorization: Bearer {JWT_TOKEN}
- Request Body:
{
"room": {
"id": "integer"
},
"capacity": "integer",
"startTime": "yyyy-MM-ddTHH:mm:ss",
"endTime": "yyyy-MM-ddTHH:mm:ss"
}- Response: Updated booking object
- URL:
/api/bookings/{id} - Method: DELETE
- Headers:
- Authorization: Bearer {JWT_TOKEN}
- Response: Cancellation confirmation
- URL:
/api/bookings/user/{userId}/bookings - Method: GET
- Headers:
- Authorization: Bearer {JWT_TOKEN}
- Response: List of booking objects for the specified user
- URL:
/api/bookings/ - Method: GET
- Headers:
- Authorization: Bearer {JWT_TOKEN}
- Response: List of all booking objects
All endpoints may return appropriate HTTP status codes for different scenarios:
- 200 OK: Successful operation
- 201 Created: Resource successfully created
- 400 Bad Request: Invalid input or parameters
- 401 Unauthorized: Authentication failure or invalid token
- 403 Forbidden: Insufficient permissions
- 404 Not Found: Requested resource not found
- 500 Internal Server Error: Unexpected server error
For detailed error messages, refer to the response body of the API calls.