Beispiel #1
0
    def get_rooms(self, facilities="ids", **kwargs):
        """
        Return complete list of rooms with amenities and other filled params.
        :param facilities: Fetch room facilities (as names, ids or none).
        :param hotel_ids:  Limit the result to these hotels.
        :param city_ids:   Limit the results to these cities. (optional)
        :param countrycodes:  Limit the results to these countries. (optional)
        :return: :rtype: List of Room objects
        """
        rooms = list_to_dict(self.getRooms(**kwargs), 'room_id')

        if facilities:
            rooms_facilities = self.getRoomFacilities(**kwargs)

            for room_facility in rooms_facilities:
                try:
                    if facilities == "names":
                        rooms[room_facility.room_id].facilities.append(self.room_facility_types[room_facility.roomfacilitytype_id].name)
                    elif facilities == "ids":
                        rooms[room_facility.room_id].facilities.append(int(room_facility.roomfacilitytype_id))
                except KeyError:
                    pass
                except AttributeError:
                    if facilities == "names":
                        rooms[room_facility.room_id].facilities = [self.room_facility_types[room_facility.roomfacilitytype_id].name]
                    elif facilities == "ids":
                        rooms[room_facility.room_id].facilities = [int(room_facility.roomfacilitytype_id)]
            to_delete = []
            for room in rooms.itervalues():
                if not hasattr(room, 'facilities'):
                    to_delete.append(room.room_id)
            for room_id in to_delete:
                del rooms[room_id]

        return BaseCollection(*rooms.values())
Beispiel #2
0
    def get_hotels(self, facilities="ids", rooms=False, **kwargs):
        """
        Return complete list of hotels with amenities and rooms and other filled params.
        :param facilities: Fetch hotel facilities (as names, ids or none).
        :param rooms:  Fetch rooms.
        :param hotel_ids:  Limit the result to these hotels.
        :param city_ids:   Limit the results to these cities. (optional)
        :param countrycodes:  Limit the results to these countries. (optional)
        :return: :rtype: List of Hotel objects
        """
        hotels = list_to_dict(self.getHotels(**kwargs), 'hotel_id')

        if facilities:
            hotels_facilities = self.getHotelFacilities(
                hotel_ids=','.join(hotels.keys()))

            for hotel_facility in hotels_facilities:
                try:
                    if facilities == "names":
                        hotels[hotel_facility.hotel_id].facilities.append(
                            self.hotel_facility_types[
                                hotel_facility.hotelfacilitytype_id].name)
                    elif facilities == "ids":
                        hotels[hotel_facility.hotel_id].facilities.append(
                            int(hotel_facility.hotelfacilitytype_id))
                except AttributeError:
                    if facilities == "names":
                        hotels[hotel_facility.hotel_id].facilities = [
                            self.hotel_facility_types[
                                hotel_facility.hotelfacilitytype_id].name
                        ]
                    elif facilities == "ids":
                        hotels[hotel_facility.hotel_id].facilities = [
                            int(hotel_facility.hotelfacilitytype_id)
                        ]

        if rooms:
            rooms = self.get_rooms(hotel_ids=','.join(hotels.keys()),
                                   facilities=facilities)

            for room in rooms:
                try:
                    hotels[room.hotel_id].rooms.append(room)
                except AttributeError:
                    hotels[room.hotel_id].rooms = BaseCollection(room)

        return BaseCollection(*hotels.values())
Beispiel #3
0
    def get_rooms(self, facilities="ids", **kwargs):
        """
        Return complete list of rooms with amenities and other filled params.
        :param facilities: Fetch room facilities (as names, ids or none).
        :param hotel_ids:  Limit the result to these hotels.
        :param city_ids:   Limit the results to these cities. (optional)
        :param countrycodes:  Limit the results to these countries. (optional)
        :return: :rtype: List of Room objects
        """
        rooms = list_to_dict(self.getRooms(**kwargs), 'room_id')

        if facilities:
            rooms_facilities = self.getRoomFacilities(**kwargs)

            for room_facility in rooms_facilities:
                try:
                    if facilities == "names":
                        rooms[room_facility.room_id].facilities.append(
                            self.room_facility_types[
                                room_facility.roomfacilitytype_id].name)
                    elif facilities == "ids":
                        rooms[room_facility.room_id].facilities.append(
                            int(room_facility.roomfacilitytype_id))
                except KeyError:
                    pass
                except AttributeError:
                    if facilities == "names":
                        rooms[room_facility.room_id].facilities = [
                            self.room_facility_types[
                                room_facility.roomfacilitytype_id].name
                        ]
                    elif facilities == "ids":
                        rooms[room_facility.room_id].facilities = [
                            int(room_facility.roomfacilitytype_id)
                        ]
            to_delete = []
            for room in rooms.itervalues():
                if not hasattr(room, 'facilities'):
                    to_delete.append(room.room_id)
            for room_id in to_delete:
                del rooms[room_id]

        return BaseCollection(*rooms.values())
Beispiel #4
0
    def get_hotels(self, facilities="ids", rooms=False, **kwargs):
        """
        Return complete list of hotels with amenities and rooms and other filled params.
        :param facilities: Fetch hotel facilities (as names, ids or none).
        :param rooms:  Fetch rooms.
        :param hotel_ids:  Limit the result to these hotels.
        :param city_ids:   Limit the results to these cities. (optional)
        :param countrycodes:  Limit the results to these countries. (optional)
        :return: :rtype: List of Hotel objects
        """
        hotels = list_to_dict(self.getHotels(**kwargs), 'hotel_id')

        if facilities:
            hotels_facilities = self.getHotelFacilities(hotel_ids=','.join(hotels.keys()))

            for hotel_facility in hotels_facilities:
                try:
                    if facilities == "names":
                        hotels[hotel_facility.hotel_id].facilities.append(self.hotel_facility_types[hotel_facility.hotelfacilitytype_id].name)
                    elif facilities == "ids":
                        hotels[hotel_facility.hotel_id].facilities.append(int(hotel_facility.hotelfacilitytype_id))
                except AttributeError:
                    if facilities == "names":
                        hotels[hotel_facility.hotel_id].facilities = [self.hotel_facility_types[hotel_facility.hotelfacilitytype_id].name]
                    elif facilities == "ids":
                        hotels[hotel_facility.hotel_id].facilities = [int(hotel_facility.hotelfacilitytype_id)]

        if rooms:
            rooms = self.get_rooms(hotel_ids=','.join(hotels.keys()), facilities=facilities)

            for room in rooms:
                try:
                    hotels[room.hotel_id].rooms.append(room)
                except AttributeError:
                    hotels[room.hotel_id].rooms = BaseCollection(room)

        return BaseCollection(*hotels.values())
Beispiel #5
0
 def room_facility_types(self):
     return list_to_dict(self.getRoomFacilityTypes(), 'roomfacilitytype_id')
Beispiel #6
0
 def hotel_facility_types(self):
     return list_to_dict(self.getHotelFacilityTypes(), 'hotelfacilitytype_id')
Beispiel #7
0
 def countries(self):
     return list_to_dict(self.getCountries(), 'countrycode')
Beispiel #8
0
 def room_facility_types(self):
     return list_to_dict(self.getRoomFacilityTypes(), 'roomfacilitytype_id')
Beispiel #9
0
 def hotel_facility_types(self):
     return list_to_dict(self.getHotelFacilityTypes(),
                         'hotelfacilitytype_id')
Beispiel #10
0
 def countries(self):
     return list_to_dict(self.getCountries(), 'countrycode')