private AvailabilityRQ ConvertToHotelBedsSearchRequest(HotelAvailabilityProviderReq request) { Logger.Instance.LogFunctionEntry(this.GetType().Name, "ConvertToHotelBedsSearchRequest"); AvailabilityRQ hotelBedsAvailabilityRQ = new AvailabilityRQ(); if (request.HotelCodes != null && request.HotelCodes.Any()) { hotelBedsAvailabilityRQ.hotels = new HotelsFilter() { hotel = request.HotelCodes.Select(int.Parse).ToList() }; } hotelBedsAvailabilityRQ.stay = new Stay(request.CheckInDate, request.CheckOutDate, 2, true); hotelBedsAvailabilityRQ.occupancies = new List <Occupancy>(); hotelBedsAvailabilityRQ.occupancies.Add(new Occupancy { adults = request.TotalAdults, rooms = HotelBedsConstants.TotalRooms, children = 0, paxes = new List <Pax>() { new Pax { age = HotelBedsConstants.AdultAge, type = com.hotelbeds.distribution.hotel_api_model.auto.common.SimpleTypes.HotelbedsCustomerType.AD } } }); Logger.Instance.LogFunctionExit(this.GetType().Name, "ConvertToHotelBedsSearchRequest"); return(hotelBedsAvailabilityRQ); }
public HotelAvailabilityProviderRes Execute(HotelAvailabilityProviderReq request) { //Logger.Instance.LogFunctionEntry(this.GetType().Name, "Execute"); Availability avail = new Availability(); List <Hotel> hotels = new List <Hotel>(); if (request.CheckInDate <= DateTime.Today) { throw new ArgumentOutOfRangeException(nameof(request.CheckInDate)); } if (request.CheckInDate >= request.CheckOutDate) { throw new ArgumentOutOfRangeException(nameof(request.CheckOutDate)); } if (request.TotalAdults < HotelBedsConstants.TotalAdults) { throw new ArgumentOutOfRangeException(nameof(request.TotalAdults)); } //Check if #of nights are more than 30, if so throw exception var duration = (request.CheckOutDate - request.CheckInDate).TotalDays; if (duration > HotelBedsConstants.NightsDuration) { throw new ArgumentOutOfRangeException(nameof(duration)); } HotelAvailabilityProviderRes hotelSearchResults; using (var hotelBedsworker = new HotelBedsWorker()) { //convert the request dto to the HotelBeds search api payload AvailabilityRQ hotelBedsSearchRq = ConvertToHotelBedsSearchRequest(request); try { var hotelBedsHotels = hotelBedsworker.GetAvailability <AvailabilityRQ, AvailabilityRS>(hotelBedsSearchRq); //Check if we need to check .hotels == null if (hotelBedsHotels.hotels == null) { //throw new ProviderUnavailableException(ProviderTypes.HotelBeds.ToString(), $"No response to {nameof(AvailabilityRQ)}.", null); throw new ProviderUnavailableException(ProviderTypes.HotelBeds.ToString(), hotelBedsHotels.error.message.ToString(), null); } hotelSearchResults = ConvertToProviderResponse(hotelBedsHotels); } catch (HotelBedsProviderException e) { if (e.HasKnownError(HotelBedsProviderException.HotelKnownError.NoListings)) { hotelSearchResults = new HotelAvailabilityProviderRes(); } else { throw; } } } //Logger.Instance.LogFunctionExit(this.GetType().Name, "Execute"); return(hotelSearchResults); }
public List <Hotel> Search(BedBankSearchDto searchCriteria) { HotelApiClient client = new HotelApiClient(); StatusRS status = client.status(); List <Hotel> hotels = new List <Hotel>(); if (status != null && status.error == null) { //List<Tuple<string, string>> param; Availability avail = new Availability(); avail.checkIn = searchCriteria.StartDate; avail.checkOut = searchCriteria.EndDate; if (searchCriteria.Address != null && searchCriteria.Address != string.Empty) { avail.destination = searchCriteria.Address; } avail.zone = 90; avail.language = "CAS"; avail.shiftDays = 2; AvailRoom room = new AvailRoom(); room.adults = Convert.ToInt32(searchCriteria.TotalGuest); room.children = 0; room.details = new List <RoomDetail>(); room.adultOf(30); room.adultOf(30); avail.rooms.Add(room); room = new AvailRoom(); room.adults = 2; room.children = 0; room.details = new List <RoomDetail>(); room.adultOf(30); room.adultOf(30); avail.rooms.Add(room); //AT_WEB = 0, //AT_HOTEL = 1, //INDIFFERENT = 2 avail.payed = Availability.Pay.AT_WEB; AvailabilityRQ availabilityRQ = avail.toAvailabilityRQ(); if (availabilityRQ != null) { AvailabilityRS responseAvail = client.doAvailability(availabilityRQ); if (responseAvail != null && responseAvail.hotels != null && responseAvail.hotels.hotels != null && responseAvail.hotels.hotels.Count > 0) { int hotelsAvailable = responseAvail.hotels.hotels.Count; hotels = responseAvail.hotels.hotels; //var abc = JsonConvert.SerializeObject(responseAvail, Formatting.Indented, new JsonSerializerSettings() { DefaultValueHandling = DefaultValueHandling.Ignore }); } } } return(hotels); }
/// <summary> /// /// </summary> /// <param name="request"></param> /// <returns></returns> public AvailabilityRS doAvailability(AvailabilityRQ request) { try { HotelApiPaths.AVAILABILITY avail = new HotelApiPaths.AVAILABILITY(); AvailabilityRS response = callRemoteApi <AvailabilityRS, AvailabilityRQ>(request, avail, null, this.version); return(response); } catch (HotelSDKException e) { throw e; } }
public AvailabilityRS GetHotelDetails(AvailabilityRQ request) { //Logger.Instance.LogFunctionEntry(this.GetType().Name, "GetHotelDetails"); AvailabilityRS responseHotelDetail = new AvailabilityRS(); List <Hotel> hotels = new List <Hotel>(); HotelApiClient client = new HotelApiClient(); StatusRS status = client.status(); AvailabilityRS responseAvail = null; try { if (status != null && status.error == null) { Availability avail = new Availability(); avail.checkIn = Convert.ToDateTime(request.stay.checkIn); avail.checkOut = Convert.ToDateTime(request.stay.checkOut); avail.includeHotels = new List <int>(); foreach (var item in request.hotels.hotel) { avail.includeHotels.Add(item); } AvailRoom room = new AvailRoom(); foreach (var occupant in request.occupancies) { room.adults = Convert.ToInt32(occupant.adults); room.numberOfRooms = Convert.ToInt32(occupant.rooms); } room.details = new List <RoomDetail>(); for (int i = 0; i < room.adults; i++) { room.adultOf(30); } avail.rooms.Add(room); AvailabilityRQ availabilityRQ = avail.toAvailabilityRQ(); if (availabilityRQ == null) { throw new Exception("Availability RQ can't be null", new ArgumentNullException()); } responseAvail = client.doAvailability(availabilityRQ); return(responseAvail); } } catch (Exception) { throw; } //Logger.Instance.LogFunctionExit(this.GetType().Name, "GetHotelDetails"); return(responseHotelDetail); }
private AvailabilityRQ ConvertToHotelBedsSearchRequest(HotelAvailabilityProviderReq request) { AvailabilityRQ hotelBedsAvailabilityRQ = new AvailabilityRQ(); if (request.HotelCodes != null && request.HotelCodes.Any()) { hotelBedsAvailabilityRQ.hotels = new HotelsFilter() { hotel = request.HotelCodes.Select(int.Parse).ToList() }; } else { var gLocation = request.GeoLocation; hotelBedsAvailabilityRQ.geolocation = new com.hotelbeds.distribution.hotel_api_model.auto.model.GeoLocation { latitude = gLocation.HasValue ? Convert.ToDouble(gLocation.Value.Latitude) : 0, longitude = gLocation.HasValue ? Convert.ToDouble(gLocation.Value.Longitude) : 0, radius = HotelBedsConstants.RadiusLimit, unit = com.hotelbeds.distribution.hotel_api_model.util.UnitMeasure.UnitMeasureType.km }; } hotelBedsAvailabilityRQ.filter = new Filter { minCategory = HotelBedsConstants.MinRating, //request.MinRating, maxCategory = HotelBedsConstants.MaxRating //request.MaxRating }; hotelBedsAvailabilityRQ.stay = new Stay(request.CheckInDate, request.CheckOutDate, 0, true); hotelBedsAvailabilityRQ.occupancies = new List <Occupancy>(); hotelBedsAvailabilityRQ.occupancies.Add(new Occupancy { adults = request.TotalAdults, rooms = HotelBedsConstants.TotalRooms, children = 0, paxes = new List <Pax>() { new Pax { age = HotelBedsConstants.AdultAge, type = com.hotelbeds.distribution.hotel_api_model.auto.common.SimpleTypes.HotelbedsCustomerType.AD } } }); return(hotelBedsAvailabilityRQ); }
public HotelAvailabilityProviderRes Execute(HotelAvailabilityProviderReq request) { Logger.Instance.LogFunctionEntry(this.GetType().Name, "Execute"); Availability avail = new Availability(); List <Hotel> hotels = new List <Hotel>(); if (request.CheckInDate <= DateTime.Today) { throw new ArgumentOutOfRangeException(nameof(request.CheckInDate)); } if (request.CheckInDate >= request.CheckOutDate) { throw new ArgumentOutOfRangeException(nameof(request.CheckOutDate)); } if (request.TotalAdults < 1) { throw new ArgumentOutOfRangeException(nameof(request.TotalAdults)); } HotelAvailabilityProviderRes hotelSearchResults; using (var hotelBedsworker = new HotelBedsWorker()) { //convert the request dto to the Hot Beds search api payload AvailabilityRQ hotelBedsSearchRq = ConvertToHotelBedsSearchRequest(request); try { var hotelBedsHotels = hotelBedsworker.GetHotelDetails(hotelBedsSearchRq); hotelSearchResults = ConvertToProviderResponse(hotelBedsHotels); if (hotelSearchResults == null) { throw new ProviderUnavailableException(ProviderTypes.HotelBeds.ToString(), $"No response to {nameof(AvailabilityRQ)}.", null); } } catch (Exception) { throw; } } Logger.Instance.LogFunctionExit(this.GetType().Name, "Execute"); return(hotelSearchResults); }
public AvailabilityRS GetAvailability <TReq, TRes>(AvailabilityRQ request) { //Logger.Instance.LogFunctionEntry(this.GetType().Name, "GetAvailability"); List <Hotel> hotels = new List <Hotel>(); HotelApiClient client = new HotelApiClient(); StatusRS status = client.status(); AvailabilityRS responseAvail = null; try { //if (status?.error != null) if (status != null && status.error == null) { responseAvail = client.doAvailability(request); } } catch (Exception) { throw; } //Logger.Instance.LogFunctionExit(this.GetType().Name, "GetAvailability"); return(responseAvail); }
static void Main(string[] args) { try { HotelApiClient client = new HotelApiClient(); StatusRS status = client.status(); if (status != null && status.error == null) { Console.WriteLine("StatusRS: " + status.status); } else if (status != null && status.error != null) { Console.WriteLine("StatusRS: " + status.status + " " + status.error.code + ": " + status.error.message); return; } else if (status == null) { Console.WriteLine("StatusRS: Is not available."); return; } List <Tuple <string, string> > param; Availability avail = new Availability(); avail.checkIn = DateTime.Now.AddDays(10); avail.checkOut = DateTime.Now.AddDays(13); avail.destination = "PMI"; avail.zone = 90; avail.language = "CAS"; avail.shiftDays = 2; AvailRoom room = new AvailRoom(); room.adults = 1; room.children = 1; room.details = new List <RoomDetail>(); room.adultOf(30); room.childOf(4); room.numberOfRooms = 1; avail.rooms.Add(room); room = new AvailRoom(); room.adults = 2; room.children = 0; room.details = new List <RoomDetail>(); room.adultOf(30); room.adultOf(30); room.numberOfRooms = 2; avail.rooms.Add(room); avail.payed = Availability.Pay.AT_WEB; //avail.ofTypes = new HashSet<hotel_api_model.auto.common.SimpleTypes.AccommodationType>(); //avail.ofTypes.Add(hotel_api_model.auto.common.SimpleTypes.AccommodationType.HOTEL); //avail.ofTypes.Add(hotel_api_model.auto.common.SimpleTypes.AccommodationType.APARTMENT); //avail.minCategory = 4; //avail.limitHotelsTo = 10; //avail.numberOfTripAdvisorReviewsHigherThan = 2; //avail.tripAdvisorScoreHigherThan = 2 //avail.matchingKeywords = new HashSet<int>(); //avail.matchingKeywords.Add(34); //avail.matchingKeywords.Add(81); //avail.keywordsMatcher = Availability.Matcher.ALL; //avail.includeHotels = new List<int>(); //avail.includeHotels.Add(111637); //avail.includeHotels.Add(2818); //avail.includeHotels.Add(138465); //avail.includeHotels.Add(164471); //avail.excludeHotels = new List<int>(); //avail.excludeHotels.Add(187013); //avail.excludeHotels.Add(188330); //avail.useGiataCodes = false; //avail.limitHotelsTo = 250; //avail.limitRoomsPerHotelTo = 5; //avail.limitRatesPerRoomTo = 5; //avail.ratesHigherThan = 50; //avail.ratesLowerThan = 350; //avail.hbScoreHigherThan = 3; //avail.hbScoreLowerThan = 5; //avail.numberOfHBReviewsHigherThan = 50; //avail.tripAdvisorScoreHigherThan = 1; //avail.tripAdvisorScoreLowerThan = 4; //avail.numberOfHBReviewsHigherThan = 50; //avail.withinThis = new Availability.Circle() { latitude = 2.646633999999949, longitude = 39.57119, radiusInKilometers = 50 }; //avail.withinThis = new Availability.Square() { northEastLatitude = 45.37680856570233, northEastLongitude = -2.021484375, southWestLatitude = 38.548165423046584, southWestLongitude = 8.658203125 }; //avail.includeBoards = new List<string>(); //avail.includeBoards.Add("R0-E10"); //avail.includeBoards.Add("BB-E10"); //avail.excludeBoards = new List<string>(); //avail.excludeBoards.Add("RO"); //avail.includeRoomCodes = new List<string>(); //avail.includeRoomCodes.Add("DBL.ST"); //avail.includeRoomCodes.Add("DBL.SU"); ////avail.includeRoomCodes.AddRange(new string[]{ "DBL.ST", "DBL.SU" }); //avail.excludeRoomCodes = new List<string>(); //avail.excludeRoomCodes.Add("TPL.ST"); AvailabilityRQ availabilityRQ = avail.toAvailabilityRQ(); if (availabilityRQ == null) { throw new Exception("Availability RQ can't be null", new ArgumentNullException()); } Console.WriteLine("Availability Request:"); Console.WriteLine(JsonConvert.SerializeObject(availabilityRQ, Formatting.Indented, new JsonSerializerSettings() { DefaultValueHandling = DefaultValueHandling.Ignore })); AvailabilityRS responseAvail = client.doAvailability(availabilityRQ); if (responseAvail != null && responseAvail.hotels != null && responseAvail.hotels.hotels != null && responseAvail.hotels.hotels.Count > 0) { Console.WriteLine(string.Format("Availability answered with {0} hotels!", responseAvail.hotels.hotels.Count)); Console.WriteLine(JsonConvert.SerializeObject(responseAvail, Formatting.Indented, new JsonSerializerSettings() { DefaultValueHandling = DefaultValueHandling.Ignore })); // *********************************** // Try to check reservation with rate // *********************************** Hotel firstHotel = responseAvail.hotels.hotels.First(); string rateKey = string.Empty; for (int r = 0; r < firstHotel.rooms.Count && String.IsNullOrEmpty(rateKey); r++) { for (int rk = 0; firstHotel.rooms[r].rates != null && rk < firstHotel.rooms[r].rates.Count && String.IsNullOrEmpty(rateKey); rk++) { rateKey = firstHotel.rooms[r].rates[rk].rateKey; } } if (String.IsNullOrEmpty(rateKey)) { Console.WriteLine("No hotel available"); return; } Console.WriteLine("Checking reservation with rate " + rateKey); ConfirmRoom confirmRoom = new ConfirmRoom(); confirmRoom.details = new List <RoomDetail>(); confirmRoom.detailed(RoomDetail.GuestType.ADULT, 30, "NombrePasajero1", "ApellidoPasajero1", 1); confirmRoom.detailed(RoomDetail.GuestType.ADULT, 30, "NombrePasajero2", "ApellidoPasajero2", 1); BookingCheck bookingCheck = new BookingCheck(); bookingCheck.addRoom(rateKey, confirmRoom); CheckRateRQ checkRateRQ = bookingCheck.toCheckRateRQ(); if (checkRateRQ != null) { CheckRateRS responseRate = client.doCheck(checkRateRQ); if (responseRate != null && responseRate.error == null) { Console.WriteLine("CheckRate Response:"); Console.WriteLine(JsonConvert.SerializeObject(responseRate, Formatting.Indented, new JsonSerializerSettings() { DefaultValueHandling = DefaultValueHandling.Ignore })); com.hotelbeds.distribution.hotel_api_sdk.helpers.Booking booking = new com.hotelbeds.distribution.hotel_api_sdk.helpers.Booking(); booking.createHolder("Rosetta", "Pruebas"); booking.clientReference = "SDK Test"; booking.remark = "***SDK***TESTING"; //NOTE: ONLY LIBERATE (PAY AT HOTEL MODEL) USES PAYMENT DATA NODES. FOR OTHER PRICING MODELS THESE NODES MUST NOT BE USED. booking.cardType = "VI"; booking.cardNumber = "4444333322221111"; booking.expiryDate = "0620"; booking.cardCVC = "0620"; booking.email = "*****@*****.**"; booking.phoneNumber = "654654654"; booking.cardHolderName = "AUTHORISED"; booking.addRoom(rateKey, confirmRoom); BookingRQ bookingRQ = booking.toBookingRQ(); if (bookingRQ != null) { BookingRS responseBooking = client.confirm(bookingRQ); Console.WriteLine("Booking Response:"); if (responseBooking != null) { Console.WriteLine(JsonConvert.SerializeObject(responseBooking, Formatting.Indented, new JsonSerializerSettings() { DefaultValueHandling = DefaultValueHandling.Ignore })); } else { Console.WriteLine("ResponseBooking Object Response is null"); } if (responseBooking != null && responseBooking.error == null && responseBooking.booking != null) { Console.WriteLine("Confirmation succedded. Canceling reservation with id " + responseBooking.booking.reference); param = new List <Tuple <string, string> > { new Tuple <string, string>("${bookingId}", responseBooking.booking.reference), //new Tuple<string, string>("${bookingId}", "1-3087550"), new Tuple <string, string>("${flag}", "C") }; BookingCancellationRS bookingCancellationRS = client.Cancel(param); if (bookingCancellationRS != null) { Console.WriteLine("Id cancelled: " + responseBooking.booking.reference); Console.WriteLine(JsonConvert.SerializeObject(bookingCancellationRS, Formatting.Indented, new JsonSerializerSettings() { DefaultValueHandling = DefaultValueHandling.Ignore })); Console.ReadLine(); Console.WriteLine("Getting detail after cancelation of id " + responseBooking.booking.reference); param = new List <Tuple <string, string> > { new Tuple <string, string>("${bookingId}", responseBooking.booking.reference) }; BookingDetailRS bookingDetailRS = client.Detail(param); if (bookingDetailRS != null) { Console.WriteLine(JsonConvert.SerializeObject(bookingDetailRS, Formatting.Indented, new JsonSerializerSettings() { DefaultValueHandling = DefaultValueHandling.Ignore })); } } } } } else { Console.WriteLine("No hotel available"); } } } else { Console.WriteLine("No availability!"); } Console.WriteLine("Requesting booking list..."); param = new List <Tuple <string, string> > { new Tuple <string, string>("${start}", DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd")), new Tuple <string, string>("${end}", DateTime.Now.ToString("yyyy-MM-dd")), new Tuple <string, string>("${includeCancelled}", "true"), new Tuple <string, string>("${filterType}", "CREATION"), new Tuple <string, string>("${from}", "1"), new Tuple <string, string>("${to}", "25"), }; BookingListRS bookingListRS = client.List(param); if (bookingListRS != null) { Console.WriteLine(JsonConvert.SerializeObject(bookingListRS, Formatting.Indented, new JsonSerializerSettings() { DefaultValueHandling = DefaultValueHandling.Ignore })); foreach (com.hotelbeds.distribution.hotel_api_model.auto.model.Booking booking in bookingListRS.bookings.bookings) { param = new List <Tuple <string, string> > { new Tuple <string, string>("${bookingId}", booking.reference) }; BookingDetailRS bookingDetailRS = client.Detail(param); if (bookingDetailRS != null) { Console.WriteLine(JsonConvert.SerializeObject(bookingDetailRS, Formatting.Indented, new JsonSerializerSettings() { DefaultValueHandling = DefaultValueHandling.Ignore })); } } } } catch (Exception e) { Console.WriteLine("Error: " + e.Message + " " + e.StackTrace); } Console.ReadLine(); }
/// <summary> /// /// </summary> /// <returns></returns> public AvailabilityRQ toAvailabilityRQ() { try { AvailabilityRQ availabilityRQ = new AvailabilityRQ(); availabilityRQ.language = this.language; availabilityRQ.stay = new Stay(checkIn, checkOut, shiftDays, true); if (rooms != null && rooms.Count > 0) { availabilityRQ.occupancies = new List <Occupancy>(); for (int i = 0; i < rooms.Count; i++) { Occupancy occupancy = new Occupancy(); occupancy.adults = rooms[i].adults; occupancy.children = rooms[i].children; occupancy.rooms = rooms[i].numberOfRooms; if (rooms[i].details != null && rooms[i].details.Count > 0) { occupancy.paxes = new List <Pax>(); Pax[] paxes = new Pax[rooms[i].details.Count]; for (int d = 0; d < rooms[i].details.Count; d++) { Pax pax = new Pax(); pax.type = (rooms[i].details[d].getType() == RoomDetail.GuestType.ADULT) ? SimpleTypes.HotelbedsCustomerType.AD : SimpleTypes.HotelbedsCustomerType.CH; pax.age = rooms[i].details[d].getAge(); pax.name = rooms[i].details[d].getName(); pax.surname = rooms[i].details[d].getSurname(); paxes[d] = pax; } occupancy.paxes.AddRange(paxes); } availabilityRQ.occupancies.Add(occupancy); } } // Linea 224 Availability.java if (withinThis != null) { GeoLocation geolocation = new GeoLocation(); geolocation.unit = UnitMeasure.UnitMeasureType.km; if (withinThis.GetType() == typeof(Circle)) { Circle circle = (Circle)withinThis; geolocation.latitude = circle.latitude; geolocation.longitude = circle.longitude; geolocation.radius = circle.radiusInKilometers; } else if (withinThis.GetType() == typeof(Square)) { Square square = (Square)withinThis; geolocation.latitude = square.northEastLatitude; geolocation.longitude = square.northEastLongitude; geolocation.secondaryLatitude = square.southWestLatitude; geolocation.secondaryLongitude = square.southWestLongitude; } availabilityRQ.geolocation = geolocation; } if (!String.IsNullOrEmpty(destination)) { Destination dest = new Destination(); dest.code = destination; if (zone != null) { dest.zone = zone.Value; } availabilityRQ.destination = dest; } if (matchingKeywords != null && matchingKeywords.Count > 0) { availabilityRQ.keywords = new KeywordsFilter(matchingKeywords.ToList <int>(), keywordsMatcher.Equals(Matcher.ALL));// matchingKeywords.ToList(); } if (includeHotels != null && includeHotels.Count > 0 && excludeHotels != null && excludeHotels.Count > 0) { foreach (int e in excludeHotels) { includeHotels.RemoveAll(i => i == e); } } if (includeHotels != null && includeHotels.Count > 0) { HotelsFilter hotelsFilter = new HotelsFilter(); hotelsFilter.included = true; hotelsFilter.hotel = includeHotels; hotelsFilter.type = (useGiataCodes) ? SimpleTypes.HotelCodeType.GIATA : SimpleTypes.HotelCodeType.HOTELBEDS; availabilityRQ.hotels = hotelsFilter; } else if (excludeHotels != null && excludeHotels.Count > 0) { HotelsFilter hotelsFilter = new HotelsFilter(); hotelsFilter.included = false; hotelsFilter.hotel = excludeHotels; hotelsFilter.type = (useGiataCodes) ? SimpleTypes.HotelCodeType.GIATA : SimpleTypes.HotelCodeType.HOTELBEDS; availabilityRQ.hotels = hotelsFilter; } if (includeBoards != null && includeBoards.Count > 0) { Boards boardFilter = new Boards(); boardFilter.included = true; boardFilter.board = includeBoards; availabilityRQ.boards = boardFilter; } else if (excludeBoards != null && excludeBoards.Count > 0) { Boards boardFilter = new Boards(); boardFilter.included = false; boardFilter.board = excludeBoards; availabilityRQ.boards = boardFilter; } if (includeRoomCodes != null && includeRoomCodes.Count > 0) { Rooms roomFilter = new Rooms(); roomFilter.included = true; roomFilter.room = includeRoomCodes; availabilityRQ.rooms = roomFilter; } else if (excludeRoomCodes != null && excludeRoomCodes.Count > 0) { Rooms roomFilter = new Rooms(); roomFilter.included = false; roomFilter.room = excludeRoomCodes; availabilityRQ.rooms = roomFilter; } availabilityRQ.dailyRate = dailyRate; if (ofTypes != null && ofTypes.Count > 0) { availabilityRQ.accommodations = new List <SimpleTypes.AccommodationType>(); availabilityRQ.accommodations.AddRange(ofTypes); } List <ReviewFilter> reviewsFilter = new List <ReviewFilter>(); if (hbScoreHigherThan != null || hbScoreLowerThan != null || numberOfHBReviewsHigherThan != null) { ReviewFilter reviewFilter = new ReviewFilter(); if (hbScoreLowerThan.HasValue) { reviewFilter.maxRate = hbScoreLowerThan.Value; } if (hbScoreHigherThan.HasValue) { reviewFilter.minRate = hbScoreHigherThan.Value; } if (numberOfHBReviewsHigherThan.HasValue) { reviewFilter.minReviewCount = numberOfHBReviewsHigherThan.Value; } reviewFilter.type = SimpleTypes.ReviewsType.HOTELBEDS; reviewsFilter.Add(reviewFilter); } if (tripAdvisorScoreHigherThan != null || tripAdvisorScoreLowerThan != null || numberOfTripAdvisorReviewsHigherThan != null) { ReviewFilter reviewFilter = new ReviewFilter(); if (tripAdvisorScoreLowerThan.HasValue) { reviewFilter.maxRate = tripAdvisorScoreLowerThan.Value; } if (tripAdvisorScoreHigherThan.HasValue) { reviewFilter.minRate = tripAdvisorScoreHigherThan.Value; } if (numberOfTripAdvisorReviewsHigherThan.HasValue) { reviewFilter.minReviewCount = numberOfTripAdvisorReviewsHigherThan.Value; } reviewFilter.type = SimpleTypes.ReviewsType.TRIPDAVISOR; reviewsFilter.Add(reviewFilter); } if (reviewsFilter.Count > 1) { availabilityRQ.reviews = reviewsFilter; } if (limitHotelsTo != null || maxCategory != null || minCategory != null || limitRoomsPerHotelTo != null || limitRatesPerRoomTo != null || ratesLowerThan != null || ratesHigherThan != null || packaging != null || payed != null) { Filter filter = new Filter(); if (maxCategory.HasValue) { filter.maxCategory = maxCategory.Value; } if (minCategory.HasValue) { filter.minCategory = minCategory.Value; } if (packaging.HasValue) { filter.packaging = packaging.Value; } if (limitHotelsTo.HasValue) { filter.maxHotels = limitHotelsTo.Value; } if (limitRoomsPerHotelTo.HasValue) { filter.maxRooms = limitRoomsPerHotelTo.Value; } if (limitRatesPerRoomTo.HasValue) { filter.maxRatesPerRoom = limitRatesPerRoomTo.Value; } if (ratesLowerThan.HasValue) { filter.maxRate = ratesLowerThan.Value; } if (ratesHigherThan.HasValue) { filter.minRate = ratesHigherThan.Value; } if (payed.HasValue) { switch (payed.Value) { case Pay.AT_HOTEL: filter.paymentType = SimpleTypes.ShowDirectPaymentType.AT_HOTEL; break; case Pay.AT_WEB: filter.paymentType = SimpleTypes.ShowDirectPaymentType.AT_WEB; break; case Pay.INDIFFERENT: filter.paymentType = SimpleTypes.ShowDirectPaymentType.BOTH; break; } } availabilityRQ.filter = filter; } availabilityRQ.Validate(); return(availabilityRQ); } catch (Exception e) { throw e; } }