/// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public CheckRateRQ toCheckRateRQ()
        {
            try
            {
                CheckRateRQ checkRateRQ = new CheckRateRQ();
                checkRateRQ.rooms = new List<hotel_api_model.auto.model.BookingRoom>();

                for (int i = 0; i < this.rooms.Count; i++)
                {
                    BookingRoom bookingRoom = new BookingRoom();
                    bookingRoom.rateKey = rooms[i].rateKey;
                    bookingRoom.paxes = new List<Pax>();
                    Pax[] paxes = new Pax[this.rooms[i].details.Count];
                    for (int d = 0; d < this.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;
                    }
                    bookingRoom.paxes.AddRange(paxes);
                    checkRateRQ.rooms.Add(bookingRoom);
                }

                checkRateRQ.Validate();

                return checkRateRQ;
            }
            catch(HotelSDKException e)
            {
                throw e;
            }
        }
예제 #2
0
        public BookingRQ toBookingRQ()
        {
            BookingRQ bookingRQ = new BookingRQ();
            bookingRQ.holder = this.holder;
            bookingRQ.clientReference = this.clientReference;
            bookingRQ.remark = this.remark;
            if ( !String.IsNullOrEmpty(cardType) && !String.IsNullOrEmpty(cardNumber) && !String.IsNullOrEmpty(cardHolderName) && !String.IsNullOrEmpty(expiryDate) && cardCVC != null ||
                !String.IsNullOrEmpty(email) && !String.IsNullOrEmpty(phoneNumber))
            {
                PaymentData paymentData = new PaymentData();
                if ( !String.IsNullOrEmpty(cardType) && !String.IsNullOrEmpty(cardNumber) && !String.IsNullOrEmpty(cardHolderName) && !String.IsNullOrEmpty(expiryDate) && !String.IsNullOrEmpty(cardCVC))
                    paymentData.paymentCard = new PaymentCard() { cardType = cardType, cardNumber = cardNumber, cardHolderName = cardHolderName, expiryDate = expiryDate, cardCVC = cardCVC  };

                if (!String.IsNullOrEmpty(email) && !String.IsNullOrEmpty(phoneNumber))
                    paymentData.contactData = new PaymentContactData() { email = email, phoneNumber = phoneNumber };

                bookingRQ.paymentData = paymentData;
            }

            for(int i = 0; i < rooms.Count; i++)
            {
                BookingRoom room = new BookingRoom();
                room.rateKey = rooms[i].rateKey;
                room.paxes = new List<Pax>();
                for(int p = 0; p < rooms[i].details.Count; p++)
                {
                    Pax pax = new Pax();
                    pax.type = (rooms[i].details[p].getType() == RoomDetail.GuestType.ADULT) ? SimpleTypes.HotelbedsCustomerType.AD : SimpleTypes.HotelbedsCustomerType.CH;
                    pax.age = rooms[i].details[p].getAge();
                    pax.name = rooms[i].details[p].getName();
                    pax.surname = rooms[i].details[p].getSurname();
                    pax.roomId = rooms[i].details[p].getRoomId();
                    room.paxes.Add(pax);
                }
                bookingRQ.rooms.Add(room);
            }

            bookingRQ.Validate();

            return bookingRQ;
        }
예제 #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public AvailabilityRQ toAvailabilityRQ()
        {
            try
            {
                AvailabilityRQ availabilityRQ = new AvailabilityRQ();
                availabilityRQ.language = this.language;
                availabilityRQ.stay = new hotel_api_model.auto.model.Stay(checkIn, checkOut, 1, 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 = i + 1;

                        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;
            }
        }