ROOM & PROPERTY API
Get Rooms API
Technical documentation for the method that returns all rooms for a property as JSON.
Summary
| Purpose | Retrieve all rooms for a specific property and return them as a JSON array of room DTO objects. |
| Entry Method | POST /getRooms |
| Input | propertyId as a request parameter. |
| Output | A JSON array of RoomsAllbookersDTO objects. |
Description
This endpoint is used to retrieve all rooms related to a property and return them as a list of RoomsAllbookersDTO objects. The method reads the propertyId, loads the Property from the database, iterates through its rooms, and maps each room to a lightweight DTO containing the room identifier and room name.
Endpoint
POST
/getRooms
Request
Request Parameter: propertyId
Authorization: Bearer <token>
| Field | Type | Description |
|---|---|---|
| propertyId | Long | Property identifier |
Request Example
POST /getRooms?propertyId=15
Process
- The propertyId is read from the request parameter.
- The Property is retrieved from the database using propertyId.
- All Room entities linked to the property are iterated.
- For each Room, a RoomsAllbookersDTO object is created.
- Each DTO includes the room id and room name.
- The final list is returned as JSON.
JSON Structure Returned
The final response contains a JSON array of room objects.
| Field | Type | Description |
|---|---|---|
| id | Long | Room ID |
| name | String | Room name |
Example JSON Returned
[
{
"id": 101,
"name": "Standard Double Room"
},
{
"id": 102,
"name": "Family Suite"
},
{
"id": 103,
"name": "Sea View Room"
}
]
Example Response
[
{
"id": 101,
"name": "Standard Double Room"
},
{
"id": 102,
"name": "Family Suite"
}
]
Notes
- If the provided property identifier does not exist, the situation should be handled through a controlled error response rather than being silently accepted.
- The current method returns only the room id and room name for each room.
- Because this endpoint only reads data, GET may be more appropriate than POST unless there is a specific integration requirement.
- If you want to extend the payload, additional room fields can be added to RoomsAllbookersDTO.