ROOM & PROPERTY API
Return Rate Plan API
Technical documentation for the method that retrieves room rate plans as JSON.
Summary
| Purpose | Retrieve all rate plans associated with a specific room and return them as a JSON list. |
| Entry Method | POST /returnRatePlan |
| Input | roomId as a numeric request parameter. |
| Output | A list of RatePlanDetail objects containing the rate plan ID and name. |
Description
This endpoint is used to retrieve all rate plans related to a specific room. It receives a roomId, loads the Room from the database, checks whether the room has any associated rate plans, and maps each one into a simplified RatePlanDetail object.
If the room does not exist or has no rate plans, the endpoint returns an empty list.
Endpoint
POST
/returnRatePlan
Request
Request parameter: roomId
Authorization: Bearer <token>
| Field | Type | Description |
|---|---|---|
| roomId | Long | Room identifier |
Request Example
POST /returnRatePlan?roomId=12 Process
- The roomId is received as a request parameter.
- The Room is retrieved from the database using roomRepository.findById(roomId).
- The method checks whether the room exists.
- The method checks whether the room has a non-null and non-empty ratePlans list.
- Each RatePlans entity is iterated.
- For each item, a RatePlanDetail object is created.
- The fields id and rate_name are mapped.
- If rate_name is null, an empty string is used instead.
- All mapped objects are added to a list.
- The list is returned as JSON.
JSON Structure Returned
The final response contains a list of rate plans for the selected room.
| Field | Type | Description |
|---|---|---|
| id | Long | Rate plan ID. |
| rate_name | String | Rate plan name; if missing, an empty string is returned. |
Example JSON Returned
[
{
"id": 1,
"rate_name": "Standard Rate"
},
{
"id": 2,
"rate_name": "Non-Refundable Rate"
},
{
"id": 3,
"rate_name": "Breakfast Included"
}
]
Headers
Content-Type: application/jsonAccept: application/json
Example Response
[
{
"id": 10,
"rate_name": "Flexible Rate"
},
{
"id": 11,
"rate_name": "Weekend Offer"
}
]
Notes
- If the specified room identifier does not exist, the endpoint returns an empty result.
- If the room exists but has no associated rate plans, the response will also be empty.
- When a rate plan name is missing, it is automatically replaced with an empty value.
- Since this endpoint is used only for data retrieval, using a GET method could be considered as a more appropriate alternative to POST.