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


class Photo(TLObject):
    CONSTRUCTOR_ID = 0x20212ca8
    SUBCLASS_OF_ID = 0xc292bd24

    def __init__(self, photo, users):
        """
        :param TLObject photo:
        :param list[TLObject] users:

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

        self.photo = photo
        self.users = users

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

    def to_bytes(self):
        return b''.join((
            b'\xa8,! ',
            self.photo.to_bytes(),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(x.to_bytes() for x in self.users),
        ))

    @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 __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 list[TLObject] photos:
        :param list[TLObject] users:

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

        self.photos = photos
        self.users = users

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

    def to_bytes(self):
        return b''.join((
            b'\xa5j\xca\x8d',
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.photos)),b''.join(x.to_bytes() for x in self.photos),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(x.to_bytes() for x in self.users),
        ))

    @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 __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 int count:
        :param list[TLObject] photos:
        :param list[TLObject] users:

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

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

    def to_dict(self, recursive=True):
        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]) if recursive else self.photos,
            'users': ([] if self.users is None else [None if x is None else x.to_dict() for x in self.users]) if recursive else self.users,
        }

    def to_bytes(self):
        return b''.join((
            b'T\x1f\x05\x15',
            struct.pack('<i', self.count),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.photos)),b''.join(x.to_bytes() for x in self.photos),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(x.to_bytes() for x in self.users),
        ))

    @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 __str__(self):
        return TLObject.pretty_format(self)

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