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


class Blocked(TLObject):
    constructor_id = 0x1c138d15
    subclass_of_id = 0xffba4f4f

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

        Constructor for contacts.Blocked: Instance of either Blocked, BlockedSlice.
        """
        super().__init__()

        self.blocked = blocked
        self.users = users

    def to_dict(self):
        return {
            'blocked': [] if self.blocked is None else [None if x is None else x.to_dict() for x in self.blocked],
            '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(Blocked.constructor_id, signed=False)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.blocked))
        for _x in self.blocked:
            _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 Blocked(None, None)

    def on_response(self, reader):
        reader.read_int()
        self.blocked = []
        _len = reader.read_int()
        for _ in range(_len):
            _x = reader.tgread_object()
            self.blocked.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 'contacts.blocked#1c138d15 blocked:Vector<ContactBlocked> users:Vector<User> = contacts.Blocked'

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

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



class BlockedSlice(TLObject):
    constructor_id = 0x900802a1
    subclass_of_id = 0xffba4f4f

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

        Constructor for contacts.Blocked: Instance of either Blocked, BlockedSlice.
        """
        super().__init__()

        self.count = count
        self.blocked = blocked
        self.users = users

    def to_dict(self):
        return {
            'count': self.count,
            'blocked': [] if self.blocked is None else [None if x is None else x.to_dict() for x in self.blocked],
            '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(BlockedSlice.constructor_id, signed=False)
        writer.write_int(self.count)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.blocked))
        for _x in self.blocked:
            _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 BlockedSlice(None, None, None)

    def on_response(self, reader):
        self.count = reader.read_int()
        reader.read_int()
        self.blocked = []
        _len = reader.read_int()
        for _ in range(_len):
            _x = reader.tgread_object()
            self.blocked.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 'contacts.blockedSlice#900802a1 count:int blocked:Vector<ContactBlocked> users:Vector<User> = contacts.Blocked'

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

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



class Contacts(TLObject):
    constructor_id = 0xeae87e42
    subclass_of_id = 0x38be25f6

    def __init__(self, contacts, saved_count, users):
        """
        :param contacts: Telegram type: "Contact". Must be a list.
        :param saved_count: Telegram type: "int".
        :param users: Telegram type: "User". Must be a list.

        Constructor for contacts.Contacts: Instance of either ContactsNotModified, Contacts.
        """
        super().__init__()

        self.contacts = contacts
        self.saved_count = saved_count
        self.users = users

    def to_dict(self):
        return {
            'contacts': [] if self.contacts is None else [None if x is None else x.to_dict() for x in self.contacts],
            'saved_count': self.saved_count,
            '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(Contacts.constructor_id, signed=False)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.contacts))
        for _x in self.contacts:
            _x.on_send(writer)

        writer.write_int(self.saved_count)
        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 Contacts(None, None, None)

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

        self.saved_count = reader.read_int()
        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 'contacts.contacts#eae87e42 contacts:Vector<Contact> saved_count:int users:Vector<User> = contacts.Contacts'

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

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



class ContactsNotModified(TLObject):
    constructor_id = 0xb74ba9d2
    subclass_of_id = 0x38be25f6

    def __init__(self):
        super().__init__()

    @staticmethod
    def to_dict():
        return {}

    def on_send(self, writer):
        writer.write_int(ContactsNotModified.constructor_id, signed=False)

    @staticmethod
    def empty():
        return ContactsNotModified()

    def on_response(self, reader):
        pass

    def __repr__(self):
        return 'contacts.contactsNotModified#b74ba9d2 = contacts.Contacts'

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

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



class Found(TLObject):
    constructor_id = 0x1aa1f784
    subclass_of_id = 0x4386a2e3

    def __init__(self, results, chats, users):
        """
        :param results: Telegram type: "Peer". Must be a list.
        :param chats: Telegram type: "Chat". Must be a list.
        :param users: Telegram type: "User". Must be a list.

        Constructor for contacts.Found: Instance of Found.
        """
        super().__init__()

        self.results = results
        self.chats = chats
        self.users = users

    def to_dict(self):
        return {
            'results': [] if self.results is None else [None if x is None else x.to_dict() for x in self.results],
            'chats': [] if self.chats is None else [None if x is None else x.to_dict() for x in self.chats],
            '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(Found.constructor_id, signed=False)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.results))
        for _x in self.results:
            _x.on_send(writer)

        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.chats))
        for _x in self.chats:
            _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 Found(None, None, None)

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

        reader.read_int()
        self.chats = []
        _len = reader.read_int()
        for _ in range(_len):
            _x = reader.tgread_object()
            self.chats.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 'contacts.found#1aa1f784 results:Vector<Peer> chats:Vector<Chat> users:Vector<User> = contacts.Found'

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

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



class ImportedContacts(TLObject):
    constructor_id = 0x77d01c3b
    subclass_of_id = 0x8172ad93

    def __init__(self, imported, popular_invites, retry_contacts, users):
        """
        :param imported: Telegram type: "ImportedContact". Must be a list.
        :param popular_invites: Telegram type: "PopularContact". Must be a list.
        :param retry_contacts: Telegram type: "long". Must be a list.
        :param users: Telegram type: "User". Must be a list.

        Constructor for contacts.ImportedContacts: Instance of ImportedContacts.
        """
        super().__init__()

        self.imported = imported
        self.popular_invites = popular_invites
        self.retry_contacts = retry_contacts
        self.users = users

    def to_dict(self):
        return {
            'imported': [] if self.imported is None else [None if x is None else x.to_dict() for x in self.imported],
            'popular_invites': [] if self.popular_invites is None else [None if x is None else x.to_dict() for x in self.popular_invites],
            'retry_contacts': [] if self.retry_contacts is None else self.retry_contacts[:],
            '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(ImportedContacts.constructor_id, signed=False)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.imported))
        for _x in self.imported:
            _x.on_send(writer)

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

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

        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 ImportedContacts(None, None, None, None)

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

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

        reader.read_int()
        self.retry_contacts = []
        _len = reader.read_int()
        for _ in range(_len):
            _x = reader.read_long()
            self.retry_contacts.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 'contacts.importedContacts#77d01c3b imported:Vector<ImportedContact> popular_invites:Vector<PopularContact> retry_contacts:Vector<long> users:Vector<User> = contacts.ImportedContacts'

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

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



class Link(TLObject):
    constructor_id = 0x3ace484c
    subclass_of_id = 0x524d5ae9

    def __init__(self, my_link, foreign_link, user):
        """
        :param my_link: Telegram type: "ContactLink".
        :param foreign_link: Telegram type: "ContactLink".
        :param user: Telegram type: "User".

        Constructor for contacts.Link: Instance of Link.
        """
        super().__init__()

        self.my_link = my_link
        self.foreign_link = foreign_link
        self.user = user

    def to_dict(self):
        return {
            'my_link': None if self.my_link is None else self.my_link.to_dict(),
            'foreign_link': None if self.foreign_link is None else self.foreign_link.to_dict(),
            'user': None if self.user is None else self.user.to_dict(),
        }

    def on_send(self, writer):
        writer.write_int(Link.constructor_id, signed=False)
        self.my_link.on_send(writer)
        self.foreign_link.on_send(writer)
        self.user.on_send(writer)

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

    def on_response(self, reader):
        self.my_link = reader.tgread_object()
        self.foreign_link = reader.tgread_object()
        self.user = reader.tgread_object()

    def __repr__(self):
        return 'contacts.link#3ace484c my_link:ContactLink foreign_link:ContactLink user:User = contacts.Link'

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

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



class ResolvedPeer(TLObject):
    constructor_id = 0x7f077ad9
    subclass_of_id = 0xf065b3a8

    def __init__(self, peer, chats, users):
        """
        :param peer: Telegram type: "Peer".
        :param chats: Telegram type: "Chat". Must be a list.
        :param users: Telegram type: "User". Must be a list.

        Constructor for contacts.ResolvedPeer: Instance of ResolvedPeer.
        """
        super().__init__()

        self.peer = peer
        self.chats = chats
        self.users = users

    def to_dict(self):
        return {
            'peer': None if self.peer is None else self.peer.to_dict(),
            'chats': [] if self.chats is None else [None if x is None else x.to_dict() for x in self.chats],
            '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(ResolvedPeer.constructor_id, signed=False)
        self.peer.on_send(writer)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.chats))
        for _x in self.chats:
            _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 ResolvedPeer(None, None, None)

    def on_response(self, reader):
        self.peer = reader.tgread_object()
        reader.read_int()
        self.chats = []
        _len = reader.read_int()
        for _ in range(_len):
            _x = reader.tgread_object()
            self.chats.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 'contacts.resolvedPeer#7f077ad9 peer:Peer chats:Vector<Chat> users:Vector<User> = contacts.ResolvedPeer'

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

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



class TopPeers(TLObject):
    constructor_id = 0x70b772a8
    subclass_of_id = 0x9ee8bb88

    def __init__(self, categories, chats, users):
        """
        :param categories: Telegram type: "TopPeerCategoryPeers". Must be a list.
        :param chats: Telegram type: "Chat". Must be a list.
        :param users: Telegram type: "User". Must be a list.

        Constructor for contacts.TopPeers: Instance of either TopPeersNotModified, TopPeers.
        """
        super().__init__()

        self.categories = categories
        self.chats = chats
        self.users = users

    def to_dict(self):
        return {
            'categories': [] if self.categories is None else [None if x is None else x.to_dict() for x in self.categories],
            'chats': [] if self.chats is None else [None if x is None else x.to_dict() for x in self.chats],
            '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(TopPeers.constructor_id, signed=False)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.categories))
        for _x in self.categories:
            _x.on_send(writer)

        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.chats))
        for _x in self.chats:
            _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 TopPeers(None, None, None)

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

        reader.read_int()
        self.chats = []
        _len = reader.read_int()
        for _ in range(_len):
            _x = reader.tgread_object()
            self.chats.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 'contacts.topPeers#70b772a8 categories:Vector<TopPeerCategoryPeers> chats:Vector<Chat> users:Vector<User> = contacts.TopPeers'

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

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



class TopPeersNotModified(TLObject):
    constructor_id = 0xde266ef5
    subclass_of_id = 0x9ee8bb88

    def __init__(self):
        super().__init__()

    @staticmethod
    def to_dict():
        return {}

    def on_send(self, writer):
        writer.write_int(TopPeersNotModified.constructor_id, signed=False)

    @staticmethod
    def empty():
        return TopPeersNotModified()

    def on_response(self, reader):
        pass

    def __repr__(self):
        return 'contacts.topPeersNotModified#de266ef5 = contacts.TopPeers'

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

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

