コード例 #1
0
 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";
コード例 #2
0
        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);
        }
コード例 #3
0
        public async Task <(HotelResponse?response, bool success)> GetHotels(FilterHotelsRequest request)
        {
            var hotels = await SearchHotels(request);

            return(MapResponse(hotels), HasData(hotels));
        }