private string BuildQuery(FilterHotelsRequest filters) => $"cityCode={filters.City}" + $"&checkInDate={FormatDate(filters.CheckIn)}&checkOutDate={FormatDate(filters.Checkout)}" + $"&roomQuantity=1&adults={Persons}" + $"&radius={SearchRadius}&radiusUnit=KM" + "&paymentPolicy=NONE" + $"&includeClosed={IncludeClosedHotels}" + "&bestRateOnly=true&view=FULL&sort=NONE";
private async Task <AmadeusHotelsResponse?> SearchHotels(FilterHotelsRequest request) { var client = _httpClientFactory.CreateClient("hotel-search"); client.DefaultRequestHeaders.Add("Authorization", await _authService.AuthHeader()); var filteredHotelsResponse = await client.GetAsync("hotel-offers?" + BuildQuery(request)); var hotels = JsonConvert.DeserializeObject <AmadeusHotelsResponse>(await filteredHotelsResponse.Content .ReadAsStringAsync()); return(hotels); }
public async Task <(HotelResponse?response, bool success)> GetHotels(FilterHotelsRequest request) { var hotels = await SearchHotels(request); return(MapResponse(hotels), HasData(hotels)); }