public void HotelListRequestWithAllInclusiveFilter() { // Arrange HotelListRequest hotelListRequest = new HotelListRequest(); hotelListRequest.City = "London"; hotelListRequest.CountryCode = "UK"; hotelListRequest.PropertyCategories = new List <PropertyCategory>(); hotelListRequest.PropertyCategories.Add(PropertyCategory.AllInclusive); // Return all that are Inclusive // Act HotelListResponse hotelListResponse = expediaService.GetHotelActiveList(hotelListRequest); // Assert if (hotelListResponse.HotelList != null) { if (hotelListResponse.HotelList.HotelSummary != null) { foreach (var summary in hotelListResponse.HotelList.HotelSummary) { Console.WriteLine((PropertyCategory)summary.PropertyCategory); Assert.That(hotelListRequest.PropertyCategories.Contains((PropertyCategory)summary.PropertyCategory)); } } } }
public void HotelListRequestBasicAvailability() { // Arrange HotelListRequest hotelListRequest = new HotelListRequest(); hotelListRequest.City = "London"; hotelListRequest.CountryCode = "UK"; hotelListRequest.ArrivalDate = new DateTime(2013, 02, 07); hotelListRequest.DepartureDate = new DateTime(2013, 03, 07); hotelListRequest.RoomGroup = new List <Room>(); hotelListRequest.RoomGroup.Add(new Room { NumberOfAdults = 1, NumberOfChildren = 0 }); hotelListRequest.RoomGroup.Add(new Room { NumberOfAdults = 2, NumberOfChildren = 2, ChildAges = new List <int> { 14, 16 } }); // Act //HotelListResponse hotelListResponse = expediaService.GetHotelAvailabilityList(hotelListRequest); // Assert //Assert.That(hotelListResponse.HotelList.HotelSummary.Any()); }
public void HotelListRequestWithAmenitiesFilter() { // Arrange HotelListRequest hotelListRequest = new HotelListRequest(); hotelListRequest.City = "New York"; hotelListRequest.CountryCode = "US"; hotelListRequest.StateProvinceCode = "NY"; hotelListRequest.Amenities = new List <Amenity>() { Amenity.SwimmingPool }; // Act HotelListResponse hotelListResponse = expediaService.GetHotelActiveList(hotelListRequest); // Assert if (hotelListResponse.HotelList != null) { if (hotelListResponse.HotelList.HotelSummary != null) { foreach (var summary in hotelListResponse.HotelList.HotelSummary) { Console.WriteLine("Amenity Mask: " + summary.AmenityMask); Console.WriteLine("Contained amenties: "); } } } }
public void HotelListRequestMethodOneUk() { // Arrange HotelListRequest hotelListRequest = new HotelListRequest(); hotelListRequest.City = "London"; hotelListRequest.CountryCode = "UK"; // Act HotelListResponse hotelListResponse = expediaService.GetHotelActiveList(hotelListRequest); // Assert Assert.That(hotelListResponse.HotelList.HotelSummary.Any()); }
/// <summary> /// Fiddler URL Dump /// /// </summary> /// <param name="hotelListRequest"></param> /// <returns></returns> public override HotelListResponse GetHotelActiveList(HotelListRequest hotelListRequest) { string path = PathFor("HotelListResponse.json"); string content = Regex.Replace(File.ReadAllText(path), ""); JsonDeserializer jsonDeserializer = new JsonDeserializer() { RootElement = "HotelListResponse" }; HotelListResponse hotelListResponse = jsonDeserializer.Deserialize <HotelListResponse>(new RestResponse() { Content = content }); return(hotelListResponse); }
public void HotelListRequestMethodOneUs() { // Arrange HotelListRequest hotelListRequest = new HotelListRequest(); hotelListRequest.City = "New York"; hotelListRequest.CountryCode = "US"; hotelListRequest.StateProvinceCode = "NY"; // Act HotelListResponse hotelListResponse = expediaService.GetHotelActiveList(hotelListRequest); // Assert Assert.That(hotelListResponse.HotelList.HotelSummary.Any()); }
public OperationResult <HotelListRs> GetHotelList(HotelListRequest request) { var client = new RestClient("https://hotels-dev.mekongleisuretravel.com/ihs/v2/list"); var restRequest = InitRestRequest(request); var response = client.Execute(restRequest); if (response.IsSuccessful) { if (response.ContentType.Contains("application/json")) { var hotelListResponse = _javaScriptScriptSerializer.Deserialize <HotelListResponse>(response.Content); if (hotelListResponse.Status.ToLower().Contains("success")) { return(new OperationResult <HotelListRs>(hotelListResponse.HotelListRs)); } } } return(new OperationResult <HotelListRs>(OperationResult.OperationStatus.GeneralError, response.ErrorMessage.ToString())); }
public override HotelListResponse GetHotelActiveList(HotelListRequest hotelListRequest) { Require.Argument("hotelListRequest", hotelListRequest); // Guard Clause RestRequest restRequest = new RestRequest { Resource = "list", Method = Method.GET, RootElement = "HotelListResponse" }; if (hotelListRequest.DestinationString.HasValue()) { // Free text destination search restRequest.AddParameter("destinationString", hotelListRequest.DestinationString); } else { // City, State, Country Search if (hotelListRequest.City.HasValue()) { restRequest.AddParameter("city", hotelListRequest.City); } if (hotelListRequest.CountryCode.HasValue()) { restRequest.AddParameter("countryCode", hotelListRequest.CountryCode); } if (hotelListRequest.StateProvinceCode.HasValue()) { restRequest.AddParameter("stateProvinceCode", hotelListRequest.StateProvinceCode); } } HandleFilteringMethods(restRequest, hotelListRequest); return(Execute <HotelListResponse>(restRequest)); }
private List<Entity.Hotel> GetHotelsData(string city, int numberOfAdults, DateTime arrivalDate, DateTime departureDate) { var result = new List<Entity.Hotel>(); var hotelServicesClient = new HotelServicesClient(); var request = new HotelListRequest(); request.arrivalDate = arrivalDate.ToString("MM/dd/yyyy"); request.departureDate = departureDate.ToString("MM/dd/yyyy"); request.city = city; request.cid = 55505; request.apiKey = "qb8es7zetcad5s5atuadxt3f"; var room = new Room(); room.numberOfAdults = numberOfAdults; request.RoomGroup = new[] { room }; hotelServicesClient.Open(); var hotelListResponse = hotelServicesClient.getList(request); var rooms = new List<HotelRoomResponse>(); foreach (HotelSummary hotelSummary in hotelListResponse.HotelList.HotelSummary) { var roomRequest = new HotelRoomAvailabilityRequest(); roomRequest.cid = 55505; roomRequest.apiKey = "qb8es7zetcad5s5atuadxt3f"; roomRequest.hotelId = hotelSummary.hotelId; roomRequest.arrivalDate = arrivalDate.ToString("MM/dd/yyyy"); roomRequest.departureDate = departureDate.ToString("MM/dd/yyyy"); roomRequest.RoomGroup = new[] { room }; var hotelRoomResponse = hotelServicesClient.getAvailability(roomRequest); foreach (HotelRoomResponse roomResponse in hotelRoomResponse.HotelRoomResponse) { result.Add(new Entity.Hotel(hotelSummary.name, roomResponse.RateInfo.ChargeableRateInfo.commissionableUsdTotal, roomResponse.RateInfo.ChargeableRateInfo.currencyCode, @"http://media.expedia.com/" + hotelSummary.thumbNailUrl, city, roomResponse.rateDescription)); } } return result; }
/// <summary> /// This is used in two other API calls. /// /// A Hotel Availability request /// <see cref="GetHotelAvailabilityList"/> /// A Hotel Dateless / Active hotels request /// <see cref="GetHotelActiveList"/> /// </summary> /// <param name="request">The RestRequest</param> /// <param name="hotelListRequest">The HotelListRequest</param> private void HandleFilteringMethods(RestRequest request, HotelListRequest hotelListRequest) { if (hotelListRequest.PropertyCategories != null) { request.AddParameter("propertyCategory", string.Join(",", hotelListRequest.PropertyCategories.Select(pc => Convert.ToInt32(pc)))); } if (hotelListRequest.Amenities != null) { request.AddParameter("amenities", string.Join(",", hotelListRequest.Amenities.Select(a => Convert.ToInt32(a)))); } if (hotelListRequest.MinStarRating.HasValue) { request.AddParameter("minStarRating", hotelListRequest.MinStarRating.Value); } if (hotelListRequest.MaxStarRating.HasValue) { request.AddParameter("maxStarRating", hotelListRequest.MaxStarRating.Value); } }
public ProxyResult <HotelListRs> GetHotelList(HotelListRequest req) { // var requestBody = new HotelListRequest // { // CityCode = "", // ArrivalDate = "12/29/2018", // DepartureDate = "12/30/2018", // RoomGuests = new List<RoomGuestRequestModel>(), // HotelIds = new int[]{ // 632882, // 148036, // 100502 } // }; // var roomGuest = new RoomGuestRequestModel(); // roomGuest.NumberOfAdults = 1; // requestBody.RoomGuests.Add(roomGuest); var operationResult = _vleisureApiRequest.GetHotelList(req); return(operationResult.ToProxyResult()); }
public abstract HotelListResponse GetHotelActiveList(HotelListRequest hotelListRequest);
public abstract HotelListResponse GetHotelAvailabilityList(HotelListRequest hotelListRequest);
public SearchResultRS GetSearchResult(HDSRequest request) { //create hotel list request object(HotelListRequest) HotelListRequest rawRq = new HotelListRequest(); rawRq = (HotelListRequest)commonHelper.GenerateBaseRequest(rawRq, request); if (request.Session.Expedia != null) { rawRq.cacheKey = request.Session.Expedia.CacheKey; rawRq.cacheLocation = request.Session.Expedia.CacheLocation; } else { //set max hotel return if (request.Session.PageSize != null) { rawRq.numberOfResults = (int)request.Session.PageSize; rawRq.numberOfResultsSpecified = true; } //star rating if (request.SearchCriteria != null) { if (request.SearchCriteria.MinStarRating != null) { rawRq.minStarRating = (float)request.SearchCriteria.MinStarRating; rawRq.minStarRatingSpecified = true; } if (request.SearchCriteria.MaxStarRating != null) { rawRq.maxStarRating = (float)request.SearchCriteria.MaxStarRating; rawRq.maxStarRatingSpecified = true; } } //stay date rawRq.arrivalDate = request.StayDate.GetCheckInUSFormat(); rawRq.departureDate = request.StayDate.GetCheckOutUSFormat(); //room and num adults-children rawRq.numberOfBedRooms = request.Itineraries.Count; rawRq.maxRatePlanCount = DEFAULT_MAX_NUMBER_OF_ROOM; rawRq.RoomGroup = commonHelper.GenerateRoomGroup(request.Itineraries); //location keyword or location(s) or list of hotelid switch (request.RequestType) { case HDSRequestType.SearchByHotelIds: int index = 0; rawRq.hotelIdList = new long[request.Hotels.Count]; foreach (HDSInterfaces.Hotel hotel in request.Hotels) { rawRq.hotelIdList[index] = (long)hotel.Id; index = index + 1; } break; case HDSRequestType.SearchByLocationIds: rawRq.destinationId = request.SearchCriteria.Location.Code; break; case HDSRequestType.SearchByLocationKeyword: rawRq.destinationString = request.SearchCriteria.LocationKeyword; break; } //addition filter - by hotel name keyword ( **** NOTE: this is excluded to search by list of hotel ID as expedia will ignore this on this search type ***** ) if (request.SearchCriteria.HotelNameKeyword != null){ rawRq.propertyName = request.SearchCriteria.HotelNameKeyword; } //addition filter - by amenities (NOTE: tested and it's working with search by location keyword, location id and list of hotel id) if (request.SearchCriteria.Amenities != null) { if (request.SearchCriteria.Amenities.Count > 0) { int index = 0; rawRq.amenities = new int[request.SearchCriteria.Amenities.Count]; foreach (HDSInterfaces.Amenity amenity in request.SearchCriteria.Amenities) { rawRq.amenities[index] = int.Parse(amenity.Code); index = index + 1; } } } //additon filter - by property type (e.g. hotel, motel, apartment) if (request.SearchCriteria.PropertyTypes != null) { if (request.SearchCriteria.PropertyTypes.Count > 0) { int index = 0; rawRq.propertyCategory = new PropertyCategory[request.SearchCriteria.PropertyTypes.Count]; foreach (HDSInterfaces.PropertyType propertyType in request.SearchCriteria.PropertyTypes) { PropertyCategory pc = PropertyCategory.Item0; switch (propertyType.Code.Trim()) { case "1": pc = PropertyCategory.Item1; break; case "2": pc = PropertyCategory.Item2; break; case "3": pc = PropertyCategory.Item3; break; case "4": pc = PropertyCategory.Item4; break; case "5": pc = PropertyCategory.Item5; break; case "6": pc = PropertyCategory.Item6; break; } rawRq.propertyCategory[index] = pc; index = index + 1; } } } } //submit soap request to expedia HotelListResponse rawRs; try { serviceObjShop = new Expedia.HotelShoppingServiceReference.HotelServicesClient(); rawRs = serviceObjShop.getList(rawRq); } catch (Exception e1) { SearchResultRS error = new SearchResultRS(); error.Errors = new List<WarningAndError>(); error.Errors.Add(new WarningAndError { Id = 9003, Message = "Error return from provider", DetailDescription = e1.ToString() }); return error; } try { return objMapping.MappingSearchResult(rawRs, request); } catch (Exception e2) { SearchResultRS error = new SearchResultRS(); error.Errors = new List<WarningAndError>(); error.Errors.Add(new WarningAndError { Id = 9110, Message = "Search Result mapping exception", DetailDescription = e2.ToString() }); return error; } }
/// <summary> ///REST Room and guest counts are formatted differently than XML and SOAP. // Review the REST room format section on the hotel list request page. // http://developer.ean.com/docs/read/hotels/version_3/request_hotel_rooms // &room[room number, starting with 1]= // [number of adults], // [comma-delimited list of children's ages] /// </summary> /// <param name="hotelListRequest"></param> /// <returns></returns> public override HotelListResponse GetHotelAvailabilityList(HotelListRequest hotelListRequest) { Require.Argument("hotelListRequest", hotelListRequest); // Guard Clause RestRequest request = new RestRequest { Resource = "list", Method = Method.GET, RootElement = "HotelListResponse", RequestFormat = DataFormat.Json, DateFormat = "mmddyyyy" }; // This is a paging request if (hotelListRequest.CacheKey.HasValue() && hotelListRequest.CacheLocation.HasValue()) { request.AddParameter("cacheKey", hotelListRequest.CacheKey); request.AddParameter("cacheLocation", hotelListRequest.CacheLocation); return(Execute <HotelListResponse>(request)); } // This check-in date if (hotelListRequest.ArrivalDate.HasValue) { request.AddParameter("arrivalDate", hotelListRequest.ArrivalDate.Value.ToShortDateString()); } // This check-out date if (hotelListRequest.DepartureDate.HasValue) { request.AddParameter("departureDate", hotelListRequest.DepartureDate.Value.ToShortDateString()); } if (hotelListRequest.DestinationId.HasValue()) // If I gave you a destination id, use that { request.AddParameter("destinationId", hotelListRequest.DestinationId); } else if (hotelListRequest.DestinationString.HasValue()) // otherwise, use the destination string I gave { request.AddParameter("destinationString", hotelListRequest.DestinationString); } else { // if destination id nor destination string have values, try and use city, state and county if (hotelListRequest.City.HasValue()) { request.AddParameter("city", hotelListRequest.City); } if (hotelListRequest.CountryCode.HasValue()) { request.AddParameter("countryCode", hotelListRequest.CountryCode); } if (hotelListRequest.StateProvinceCode.HasValue()) { request.AddParameter("stateProvinceCode", hotelListRequest.StateProvinceCode); } } if (hotelListRequest.NumberOfResults.HasValue) { request.AddParameter("numberOfResults", hotelListRequest.NumberOfResults.Value); } if (hotelListRequest.SupplierType.HasValue) { request.AddParameter("supplierType", hotelListRequest.SupplierType.Value.ToString()); } HandleFilteringMethods(request, hotelListRequest); if (hotelListRequest.RoomGroup != null) { for (int i = 0; i < hotelListRequest.NumberOfBedRooms; i++) { Room room = hotelListRequest.RoomGroup[i]; int adults = room.NumberOfAdults; int children = room.NumberOfChildren; List <int> ages = room.ChildAges; int roomNumber = hotelListRequest.RoomGroup.IndexOf(room) + 1; var parameter = new Parameter(); parameter.Value = adults + (ages.OrEmptyIfNull().Any() ? ("," + string.Join(",", ages.Take(children).ToArray())) : string.Empty); parameter.Type = ParameterType.GetOrPost; parameter.Name = string.Format("room{0}", roomNumber); request.AddParameter(parameter); } } // for performance boost request.AddParameter("supplierCacheTolerance", "MAX_ENHANCED"); return(Execute <HotelListResponse>(request)); }
public async Task <ActionResult> GtHotel(Search.Hotel hotel, string currentCode = "MYR") { var hotelReqInit = new HotelListRequest { ArrivalDate = hotel.DateFrom.Date, // setter by user pass in date DepartureDate = hotel.DateTo.Date, // setter by user pass in date CrossSale = (_ExecutedController == "checkout" && _ExecutedAction == "addon"), // setter by controller action, if addon then true, else false CurrencyCode = currentCode, // setter by global currency select by customer IsB2B = (User.Identity.IsAuthenticated ? CustomPrincipal.IsAgent : false), // setter by check user is login as Agent rateType = RateType.MerchantStandard, // setter by application default UserLoginID = (User.Identity.IsAuthenticated && CustomPrincipal.IsAgent ? CustomPrincipal.LoginID : null), // setter by agent user login id Search_by = Alternative_Searching.Search_By_HotelIDs, SearchSuppliers = new SearchSupplier { Expedia = true } }; MayFlower dbCtx = new MayFlower(); //var featuredHotel = dbCtx.HotelFeatureLists.Where(x => x.IsActive && x.SupplierCode == "EAN") // .OrderByDescending(s => s.SortOrder).Take(3) // .Select(s => s.HotelID)?.ToArray() ?? new string[] { }; int dummyCount = 5; string _destinationTrim = hotel.Destination.Split(',').FirstOrDefault() ?? ""; var hotSellHotel = dbCtx.BookingHotels .Where(x => x.HotelID != null && x.BookingStatusCode == "CON" && x.SupplierCode == "EAN" && x.HotelCity.ToLower().StartsWith(_destinationTrim.ToLower())) .GroupBy(x => x.HotelID) .OrderBy(x => x.Count()) .Take(dummyCount) .Select(x => x.Key)?.ToArray() ?? new string[] { }; if (hotSellHotel.Length < dummyCount) { int _remainDummyRowCount = dummyCount - hotSellHotel.Length; var _list2 = dbCtx.HotelLists.Where(x => x.IsActive && x.City.ToLower().StartsWith(_destinationTrim.ToLower())) .Take(_remainDummyRowCount) .Select(x => x.EANHotelID.ToString())?.ToList() ?? new List <string>(); hotSellHotel = hotSellHotel.ToList().Concat(_list2).ToArray(); } hotelReqInit.Search_by_HotelIDs = new Search_By_HotelIDs(); hotelReqInit.Search_by_HotelIDs.HotelIDs = hotSellHotel; //featuredHotel; hotelReqInit.CustomerUserAgent = Request.UserAgent; hotelReqInit.CustomerSessionId = Guid.NewGuid().ToString(); hotelReqInit.CustomerIpAddress = GetUserIP(); hotelReqInit.UserLoginID = User.Identity.IsAuthenticated && CustomPrincipal.IsAgent ? CustomPrincipal.LoginID : null; string _sToken = Mayflower.Controllers.HotelController.SerializeHotelSearchToken(hotel.DateFrom, hotel.DateTo, hotel.NoRooms, hotel.Adults, hotel.Kids, hotelReqInit.CrossSale, hotelReqInit.IsB2B, hotelReqInit.rateType, hotelReqInit.CurrencyCode); var _room = JsonConvert.DeserializeObject <Search.Hotel.Room>(_sToken); _room.InitESBRoomRequest(true); hotelReqInit.NumberOfRoom = _room.ESBRoomRequest.NumberOfRoom; ESBHotelManagerClient webservice = new ESBHotelManagerClient(); var req = await webservice.GetHotelListAsync(hotelReqInit); ViewBag.TripID = hotelReqInit.CustomerSessionId; return(PartialView("~/Views/Hotel/v2/_HotelListSessionless.cshtml", req)); }