"""File generated by TLObjects' generator. All changes will be ERASED"""
from ...tl.tlobject import TLObject


class Photo(TLObject):
    constructor_id = 0x20212ca8
    subclass_of_id = 0xc292bd24

    def __init__(self, photo, users):
        """
        :param photo: Telegram type: "Photo".
        :param users: Telegram type: "User". Must be a list.

        Constructor for photos.Photo: Instance of Photo.
        """
        super().__init__()

        self.photo = photo
        self.users = users

    def to_dict(self):
        return {
            'photo': None if self.photo is None else self.photo.to_dict(),
            'users': [] if self.users is None else [None if x is None else x.to_dict() for x in self.users],
        }

    def on_send(self, writer):
        writer.write_int(Photo.constructor_id, signed=False)
        self.photo.on_send(writer)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.users))
        for _x in self.users:
            _x.on_send(writer)

    @staticmethod
    def empty():
        return Photo(None, None)

    def on_response(self, reader):
        self.photo = reader.tgread_object()
        reader.read_int()
        self.users = []
        _len = reader.read_int()
        for _ in range(_len):
            _x = reader.tgread_object()
            self.users.append(_x)

    def __repr__(self):
        return 'photos.photo#20212ca8 photo:Photo users:Vector<User> = photos.Photo'

    def __str__(self):
        return TLObject.pretty_format(self)

    def stringify(self):
        return TLObject.pretty_format(self, indent=0)



class Photos(TLObject):
    constructor_id = 0x8dca6aa5
    subclass_of_id = 0x27cfb967

    def __init__(self, photos, users):
        """
        :param photos: Telegram type: "Photo". Must be a list.
        :param users: Telegram type: "User". Must be a list.

        Constructor for photos.Photos: Instance of either Photos, PhotosSlice.
        """
        super().__init__()

        self.photos = photos
        self.users = users

    def to_dict(self):
        return {
            'photos': [] if self.photos is None else [None if x is None else x.to_dict() for x in self.photos],
            'users': [] if self.users is None else [None if x is None else x.to_dict() for x in self.users],
        }

    def on_send(self, writer):
        writer.write_int(Photos.constructor_id, signed=False)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.photos))
        for _x in self.photos:
            _x.on_send(writer)

        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.users))
        for _x in self.users:
            _x.on_send(writer)

    @staticmethod
    def empty():
        return Photos(None, None)

    def on_response(self, reader):
        reader.read_int()
        self.photos = []
        _len = reader.read_int()
        for _ in range(_len):
            _x = reader.tgread_object()
            self.photos.append(_x)

        reader.read_int()
        self.users = []
        _len = reader.read_int()
        for _ in range(_len):
            _x = reader.tgread_object()
            self.users.append(_x)

    def __repr__(self):
        return 'photos.photos#8dca6aa5 photos:Vector<Photo> users:Vector<User> = photos.Photos'

    def __str__(self):
        return TLObject.pretty_format(self)

    def stringify(self):
        return TLObject.pretty_format(self, indent=0)



class PhotosSlice(TLObject):
    constructor_id = 0x15051f54
    subclass_of_id = 0x27cfb967

    def __init__(self, count, photos, users):
        """
        :param count: Telegram type: "int".
        :param photos: Telegram type: "Photo". Must be a list.
        :param users: Telegram type: "User". Must be a list.

        Constructor for photos.Photos: Instance of either Photos, PhotosSlice.
        """
        super().__init__()

        self.count = count
        self.photos = photos
        self.users = users

    def to_dict(self):
        return {
            'count': self.count,
            'photos': [] if self.photos is None else [None if x is None else x.to_dict() for x in self.photos],
            'users': [] if self.users is None else [None if x is None else x.to_dict() for x in self.users],
        }

    def on_send(self, writer):
        writer.write_int(PhotosSlice.constructor_id, signed=False)
        writer.write_int(self.count)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.photos))
        for _x in self.photos:
            _x.on_send(writer)

        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.users))
        for _x in self.users:
            _x.on_send(writer)

    @staticmethod
    def empty():
        return PhotosSlice(None, None, None)

    def on_response(self, reader):
        self.count = reader.read_int()
        reader.read_int()
        self.photos = []
        _len = reader.read_int()
        for _ in range(_len):
            _x = reader.tgread_object()
            self.photos.append(_x)

        reader.read_int()
        self.users = []
        _len = reader.read_int()
        for _ in range(_len):
            _x = reader.tgread_object()
            self.users.append(_x)

    def __repr__(self):
        return 'photos.photosSlice#15051f54 count:int photos:Vector<Photo> users:Vector<User> = photos.Photos'

    def __str__(self):
        return TLObject.pretty_format(self)

    def stringify(self):
        return TLObject.pretty_format(self, indent=0)

