Pattern: map rooms and rates
Developers (API)REST API v1
Prices and reservations in the API are addressed by Effective Tours ids, not by names. This pattern reads a hotel, its rooms and its rates once, and gives you a mapping table that links them to the room types in your own PMS. Every integration that writes prices or reservations needs it. See Integration patterns for the shared principles; this pattern uses only read calls.
Re-run it when the hotel changes its rooms or rates, and keep the table in your database rather than reading it on every request.
Steps
1. Read the hotel
Confirm that the hotel id you got from first connection is the one you mean, and see which channels are connected. See GET /hotels/{id}. Here {id} is the hotel id.
curl "https://api.effectivetours.com/v1/hotels/{id}" \
-H "Authorization: Bearer $ET_API_KEY"Example response (abbreviated):
{
"id": 1001,
"name": "Example Guest House",
"category": "Guest house",
"address": "1 Example Street",
"rate_type": "ROOM",
"company": {
"id": 501,
"name": "Example Distributor Ltd",
"company_type": "DISTRIBUTOR"
},
"city": {
"id": 301,
"country": {
"id": 201,
"code": "XX",
"name": "Exampleland"
},
"name": "Exampleville"
},
"connections": {}
}2. Read the rooms
Rooms tell you what can be booked and which occupancies each room supports (sgl, dbl, tpl, apartment). Each room also lists the rates that apply to it. See GET /hotels/{id}/rooms.
curl "https://api.effectivetours.com/v1/hotels/{id}/rooms" \
-H "Authorization: Bearer $ET_API_KEY"Example response (abbreviated: one room shown):
[
{
"id": 2001,
"name": "Double Room 1",
"sgl": false,
"dbl": true,
"tpl": false,
"apartment": false,
"is_virtual": false,
"rates": [
{
"id": 3001,
"name": "Standard rate",
"food": "RO"
}
]
}
]3. Read the rates
Rates are the room types you price. The sgl, dbl, tpl and full flags say which occupancies the rate supports, and connections shows the channel ids it is mapped to. See GET /hotels/{id}/rates.
curl "https://api.effectivetours.com/v1/hotels/{id}/rates" \
-H "Authorization: Bearer $ET_API_KEY"Example response (abbreviated: one rate shown):
[
{
"id": 3001,
"name": "Standard rate",
"food": "RO",
"sgl": false,
"dbl": true,
"tpl": false,
"full": false,
"connections": {
"booking": [
{
"booking_id": 9001,
"booking_rate": 9101,
"occupancy": 2
}
]
}
}
]An empty list ([]) is a normal answer: a hotel can exist without rates. Treat it as "nothing to map yet", not as an error.
4. Build the mapping table
Store one row for each combination you will use. The template below is for your PMS; the ET columns come from the calls above.
| Your room type | ET room_id | ET rate_id | Occupancy |
|---|---|---|---|
| Double (your PMS code DBL-STD) | 2001 | 3001 | dbl |
| Single (your PMS code SGL-STD) | 2002 | 3002 | sgl |
Rules that keep the table correct:
- A room id is used when you book a specific room. A rate id is used for prices, and for booking by room type.
- Map the occupancy that the rate supports: check the
sgl,dbl,tplandfullflags on the rate. - Keep the table per hotel: ids are read from one hotel, so store the hotel id in every row.
Related method page: Hotels, rooms and rates. Next: Pattern: read and update prices.
What can go wrong
| Status | Body | What to do |
|---|---|---|
| 404 | {"detail":"Hotel not found"} | The id is wrong, or your key has no access to this hotel. Re-read /hotels/. |
| 410 | {"detail":"Requested HotelID: <id> not found."} | The hotel belongs to your company but was permanently removed. Remove it from your mapping. |
| 401 | {"detail":"Invalid API key"} | Check the key. |
| 503 | {"detail":"Authentication backend unavailable"} | Retry the read after a pause. |
200 with [] from /rates or /rooms | [] | Normal. Nothing to map yet; ask again later. |
| 422 | standard validation error | The id in the path is not a number. Fix the path. |