hotelsSearch method
- HotelSearchRequest? hotelSearchRequest,
- Future<
void> ? abortTrigger,
Search hotels
Searches hotels by location or hotel IDs and returns their bookable rates for the stay. Send searchCriteria.location or searchCriteria.hotelIds; a non-empty hotelIds wins and location is then ignored. checkIn, checkOut, rooms and guestNationality are required: rates are priced for the occupancy, child ages and guest market sent here. A stay longer than 30 nights returns 400 / 10001 with reason MAX_STAY_EXCEEDED at checkOut. The body rejects an unknown member at every level, filters, searchCriteria.location and rooms[] included, and the route takes no query parameters: either gives 400 / 10001. Returns { items, pagination, nextCursor, details }. Each item is a hotel: id, name, countryCode, category (always null), logoUrl (the main image), description, its offers, and details with the star rating, address, coordinates, images, amenity groups and contact. Each offer is one rate: an opaque publicId, a name such as "Deluxe King, Breakfast, Free cancellation", a price for the whole stay (all rooms and nights), and the rate terms in details, including expiresAt. Pass an offer's publicId to quote or order before it expires. The hotel's id is not an offer; send it in searchCriteria.hotelIds to search that hotel again. A hotel without an orderable offer is not listed. details.availableFilters holds the amenity filter values of a cityCode search. Location searches are paged: limit is 1–50 (default 20) and the next page is requested by sending the response's nextCursor back as cursor with the same body; a null nextCursor is the last page. A page can hold fewer hotels than limit, even none, while nextCursor is not null: keep paging until it is null. pagination.totalCount counts the area's candidate hotels, an upper bound of what the pages list. To keep pages small, each hotel on a page has one offer, its cheapest rate, with empty nightlyPrices and surcharges, and no description and one image. A hotelIds search returns every rate of those hotels with the full detail, as one complete page; an empty items there means none of those hotels has an orderable offer. Errors: an ID that is not a hotel ID returns 400 / 21000; an unknown or expired hotel ID 400 / 11004; 503 / 21003 when offers are temporarily unavailable (retry the search); 502, 504 or 503 with 21007–21009 when the hotel system fails, times out or is unavailable.
Parameters:
- HotelSearchRequest hotelSearchRequest:
Implementation
Future<HotelSearchResult?> hotelsSearch({ HotelSearchRequest? hotelSearchRequest, Future<void>? abortTrigger, }) async {
final response = await hotelsSearchWithHttpInfo(hotelSearchRequest: hotelSearchRequest, abortTrigger: abortTrigger,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'HotelSearchResult',) as HotelSearchResult;
}
return null;
}