"""File generated by TLObjects' generator. All changes will be ERASED"""
from ...tl.tlobject import TLObject
from ...tl.tlobject import TLRequest
from typing import Optional, List, Union, TYPE_CHECKING
import os
import struct
if TYPE_CHECKING:
    from ...tl.types import TypeInputPeer, TypeInputUser, TypeBool, TypeInputContact, TypeTopPeerCategory



class BlockRequest(TLRequest):
    CONSTRUCTOR_ID = 0x332b49fc
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, id):
        """
        :param TypeInputUser id:

        :returns Bool: This type has no constructors.
        """
        self.id = id  # type: TypeInputUser

    async def resolve(self, client, utils):
        self.id = utils.get_input_user(await client.get_input_entity(self.id))

    def to_dict(self):
        return {
            '_': 'BlockRequest',
            'id': self.id.to_dict() if isinstance(self.id, TLObject) else self.id
        }

    def __bytes__(self):
        return b''.join((
            b'\xfcI+3',
            bytes(self.id),
        ))

    @classmethod
    def from_reader(cls, reader):
        _id = reader.tgread_object()
        return cls(id=_id)


class DeleteByPhonesRequest(TLRequest):
    CONSTRUCTOR_ID = 0x1013fd9e
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, phones):
        """
        :param List[str] phones:

        :returns Bool: This type has no constructors.
        """
        self.phones = phones  # type: List[str]

    def to_dict(self):
        return {
            '_': 'DeleteByPhonesRequest',
            'phones': [] if self.phones is None else self.phones[:]
        }

    def __bytes__(self):
        return b''.join((
            b'\x9e\xfd\x13\x10',
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.phones)),b''.join(self.serialize_bytes(x) for x in self.phones),
        ))

    @classmethod
    def from_reader(cls, reader):
        reader.read_int()
        _phones = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_string()
            _phones.append(_x)

        return cls(phones=_phones)


class DeleteContactRequest(TLRequest):
    CONSTRUCTOR_ID = 0x8e953744
    SUBCLASS_OF_ID = 0x524d5ae9

    def __init__(self, id):
        """
        :param TypeInputUser id:

        :returns contacts.Link: Instance of Link.
        """
        self.id = id  # type: TypeInputUser

    async def resolve(self, client, utils):
        self.id = utils.get_input_user(await client.get_input_entity(self.id))

    def to_dict(self):
        return {
            '_': 'DeleteContactRequest',
            'id': self.id.to_dict() if isinstance(self.id, TLObject) else self.id
        }

    def __bytes__(self):
        return b''.join((
            b'D7\x95\x8e',
            bytes(self.id),
        ))

    @classmethod
    def from_reader(cls, reader):
        _id = reader.tgread_object()
        return cls(id=_id)


class DeleteContactsRequest(TLRequest):
    CONSTRUCTOR_ID = 0x59ab389e
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, id):
        """
        :param List[TypeInputUser] id:

        :returns Bool: This type has no constructors.
        """
        self.id = id  # type: List[TypeInputUser]

    async def resolve(self, client, utils):
        _tmp = []
        for _x in self.id:
            _tmp.append(utils.get_input_user(await client.get_input_entity(_x)))

        self.id = _tmp

    def to_dict(self):
        return {
            '_': 'DeleteContactsRequest',
            'id': [] if self.id is None else [x.to_dict() if isinstance(x, TLObject) else x for x in self.id]
        }

    def __bytes__(self):
        return b''.join((
            b'\x9e8\xabY',
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.id)),b''.join(bytes(x) for x in self.id),
        ))

    @classmethod
    def from_reader(cls, reader):
        reader.read_int()
        _id = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _id.append(_x)

        return cls(id=_id)


class GetBlockedRequest(TLRequest):
    CONSTRUCTOR_ID = 0xf57c350f
    SUBCLASS_OF_ID = 0xffba4f4f

    def __init__(self, offset, limit):
        """
        :param int offset:
        :param int limit:

        :returns contacts.Blocked: Instance of either Blocked, BlockedSlice.
        """
        self.offset = offset  # type: int
        self.limit = limit  # type: int

    def to_dict(self):
        return {
            '_': 'GetBlockedRequest',
            'offset': self.offset,
            'limit': self.limit
        }

    def __bytes__(self):
        return b''.join((
            b'\x0f5|\xf5',
            struct.pack('<i', self.offset),
            struct.pack('<i', self.limit),
        ))

    @classmethod
    def from_reader(cls, reader):
        _offset = reader.read_int()
        _limit = reader.read_int()
        return cls(offset=_offset, limit=_limit)


class GetContactIDsRequest(TLRequest):
    CONSTRUCTOR_ID = 0x2caa4a42
    SUBCLASS_OF_ID = 0x5026710f

    def __init__(self, hash):
        """
        :param int hash:

        :returns Vector<int>: This type has no constructors.
        """
        self.hash = hash  # type: int

    def to_dict(self):
        return {
            '_': 'GetContactIDsRequest',
            'hash': self.hash
        }

    def __bytes__(self):
        return b''.join((
            b'BJ\xaa,',
            struct.pack('<i', self.hash),
        ))

    @classmethod
    def from_reader(cls, reader):
        _hash = reader.read_int()
        return cls(hash=_hash)

    @staticmethod
    def read_result(reader):
        reader.read_int()  # Vector ID
        return [reader.read_int() for _ in range(reader.read_int())]


class GetContactsRequest(TLRequest):
    CONSTRUCTOR_ID = 0xc023849f
    SUBCLASS_OF_ID = 0x38be25f6

    def __init__(self, hash):
        """
        :param int hash:

        :returns contacts.Contacts: Instance of either ContactsNotModified, Contacts.
        """
        self.hash = hash  # type: int

    def to_dict(self):
        return {
            '_': 'GetContactsRequest',
            'hash': self.hash
        }

    def __bytes__(self):
        return b''.join((
            b'\x9f\x84#\xc0',
            struct.pack('<i', self.hash),
        ))

    @classmethod
    def from_reader(cls, reader):
        _hash = reader.read_int()
        return cls(hash=_hash)


class GetSavedRequest(TLRequest):
    CONSTRUCTOR_ID = 0x82f1e39f
    SUBCLASS_OF_ID = 0x975dbef

    def to_dict(self):
        return {
            '_': 'GetSavedRequest'
        }

    def __bytes__(self):
        return b''.join((
            b'\x9f\xe3\xf1\x82',
        ))

    @classmethod
    def from_reader(cls, reader):
        return cls()


class GetStatusesRequest(TLRequest):
    CONSTRUCTOR_ID = 0xc4a353ee
    SUBCLASS_OF_ID = 0xdf815c90

    def to_dict(self):
        return {
            '_': 'GetStatusesRequest'
        }

    def __bytes__(self):
        return b''.join((
            b'\xeeS\xa3\xc4',
        ))

    @classmethod
    def from_reader(cls, reader):
        return cls()


class GetTopPeersRequest(TLRequest):
    CONSTRUCTOR_ID = 0xd4982db5
    SUBCLASS_OF_ID = 0x9ee8bb88

    def __init__(self, offset, limit, hash, correspondents=None, bots_pm=None, bots_inline=None, phone_calls=None, groups=None, channels=None):
        """
        :param int offset:
        :param int limit:
        :param int hash:
        :param Optional[bool] correspondents:
        :param Optional[bool] bots_pm:
        :param Optional[bool] bots_inline:
        :param Optional[bool] phone_calls:
        :param Optional[bool] groups:
        :param Optional[bool] channels:

        :returns contacts.TopPeers: Instance of either TopPeersNotModified, TopPeers, TopPeersDisabled.
        """
        self.offset = offset  # type: int
        self.limit = limit  # type: int
        self.hash = hash  # type: int
        self.correspondents = correspondents  # type: Optional[bool]
        self.bots_pm = bots_pm  # type: Optional[bool]
        self.bots_inline = bots_inline  # type: Optional[bool]
        self.phone_calls = phone_calls  # type: Optional[bool]
        self.groups = groups  # type: Optional[bool]
        self.channels = channels  # type: Optional[bool]

    def to_dict(self):
        return {
            '_': 'GetTopPeersRequest',
            'offset': self.offset,
            'limit': self.limit,
            'hash': self.hash,
            'correspondents': self.correspondents,
            'bots_pm': self.bots_pm,
            'bots_inline': self.bots_inline,
            'phone_calls': self.phone_calls,
            'groups': self.groups,
            'channels': self.channels
        }

    def __bytes__(self):
        return b''.join((
            b'\xb5-\x98\xd4',
            struct.pack('<I', (0 if self.correspondents is None or self.correspondents is False else 1) | (0 if self.bots_pm is None or self.bots_pm is False else 2) | (0 if self.bots_inline is None or self.bots_inline is False else 4) | (0 if self.phone_calls is None or self.phone_calls is False else 8) | (0 if self.groups is None or self.groups is False else 1024) | (0 if self.channels is None or self.channels is False else 32768)),
            struct.pack('<i', self.offset),
            struct.pack('<i', self.limit),
            struct.pack('<i', self.hash),
        ))

    @classmethod
    def from_reader(cls, reader):
        flags = reader.read_int()

        _correspondents = bool(flags & 1)
        _bots_pm = bool(flags & 2)
        _bots_inline = bool(flags & 4)
        _phone_calls = bool(flags & 8)
        _groups = bool(flags & 1024)
        _channels = bool(flags & 32768)
        _offset = reader.read_int()
        _limit = reader.read_int()
        _hash = reader.read_int()
        return cls(offset=_offset, limit=_limit, hash=_hash, correspondents=_correspondents, bots_pm=_bots_pm, bots_inline=_bots_inline, phone_calls=_phone_calls, groups=_groups, channels=_channels)


class ImportContactsRequest(TLRequest):
    CONSTRUCTOR_ID = 0x2c800be5
    SUBCLASS_OF_ID = 0x8172ad93

    def __init__(self, contacts):
        """
        :param List[TypeInputContact] contacts:

        :returns contacts.ImportedContacts: Instance of ImportedContacts.
        """
        self.contacts = contacts  # type: List[TypeInputContact]

    def to_dict(self):
        return {
            '_': 'ImportContactsRequest',
            'contacts': [] if self.contacts is None else [x.to_dict() if isinstance(x, TLObject) else x for x in self.contacts]
        }

    def __bytes__(self):
        return b''.join((
            b'\xe5\x0b\x80,',
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.contacts)),b''.join(bytes(x) for x in self.contacts),
        ))

    @classmethod
    def from_reader(cls, reader):
        reader.read_int()
        _contacts = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _contacts.append(_x)

        return cls(contacts=_contacts)


class ResetSavedRequest(TLRequest):
    CONSTRUCTOR_ID = 0x879537f1
    SUBCLASS_OF_ID = 0xf5b399ac

    def to_dict(self):
        return {
            '_': 'ResetSavedRequest'
        }

    def __bytes__(self):
        return b''.join((
            b'\xf17\x95\x87',
        ))

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ResetTopPeerRatingRequest(TLRequest):
    CONSTRUCTOR_ID = 0x1ae373ac
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, category, peer):
        """
        :param TypeTopPeerCategory category:
        :param TypeInputPeer peer:

        :returns Bool: This type has no constructors.
        """
        self.category = category  # type: TypeTopPeerCategory
        self.peer = peer  # type: TypeInputPeer

    async def resolve(self, client, utils):
        self.peer = utils.get_input_peer(await client.get_input_entity(self.peer))

    def to_dict(self):
        return {
            '_': 'ResetTopPeerRatingRequest',
            'category': self.category.to_dict() if isinstance(self.category, TLObject) else self.category,
            'peer': self.peer.to_dict() if isinstance(self.peer, TLObject) else self.peer
        }

    def __bytes__(self):
        return b''.join((
            b'\xacs\xe3\x1a',
            bytes(self.category),
            bytes(self.peer),
        ))

    @classmethod
    def from_reader(cls, reader):
        _category = reader.tgread_object()
        _peer = reader.tgread_object()
        return cls(category=_category, peer=_peer)


class ResolveUsernameRequest(TLRequest):
    CONSTRUCTOR_ID = 0xf93ccba3
    SUBCLASS_OF_ID = 0xf065b3a8

    def __init__(self, username):
        """
        :param str username:

        :returns contacts.ResolvedPeer: Instance of ResolvedPeer.
        """
        self.username = username  # type: str

    def to_dict(self):
        return {
            '_': 'ResolveUsernameRequest',
            'username': self.username
        }

    def __bytes__(self):
        return b''.join((
            b'\xa3\xcb<\xf9',
            self.serialize_bytes(self.username),
        ))

    @classmethod
    def from_reader(cls, reader):
        _username = reader.tgread_string()
        return cls(username=_username)


class SearchRequest(TLRequest):
    CONSTRUCTOR_ID = 0x11f812d8
    SUBCLASS_OF_ID = 0x4386a2e3

    def __init__(self, q, limit):
        """
        :param str q:
        :param int limit:

        :returns contacts.Found: Instance of Found.
        """
        self.q = q  # type: str
        self.limit = limit  # type: int

    def to_dict(self):
        return {
            '_': 'SearchRequest',
            'q': self.q,
            'limit': self.limit
        }

    def __bytes__(self):
        return b''.join((
            b'\xd8\x12\xf8\x11',
            self.serialize_bytes(self.q),
            struct.pack('<i', self.limit),
        ))

    @classmethod
    def from_reader(cls, reader):
        _q = reader.tgread_string()
        _limit = reader.read_int()
        return cls(q=_q, limit=_limit)


class ToggleTopPeersRequest(TLRequest):
    CONSTRUCTOR_ID = 0x8514bdda
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, enabled):
        """
        :param TypeBool enabled:

        :returns Bool: This type has no constructors.
        """
        self.enabled = enabled  # type: TypeBool

    def to_dict(self):
        return {
            '_': 'ToggleTopPeersRequest',
            'enabled': self.enabled
        }

    def __bytes__(self):
        return b''.join((
            b'\xda\xbd\x14\x85',
            b'\xb5ur\x99' if self.enabled else b'7\x97y\xbc',
        ))

    @classmethod
    def from_reader(cls, reader):
        _enabled = reader.tgread_bool()
        return cls(enabled=_enabled)


class UnblockRequest(TLRequest):
    CONSTRUCTOR_ID = 0xe54100bd
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, id):
        """
        :param TypeInputUser id:

        :returns Bool: This type has no constructors.
        """
        self.id = id  # type: TypeInputUser

    async def resolve(self, client, utils):
        self.id = utils.get_input_user(await client.get_input_entity(self.id))

    def to_dict(self):
        return {
            '_': 'UnblockRequest',
            'id': self.id.to_dict() if isinstance(self.id, TLObject) else self.id
        }

    def __bytes__(self):
        return b''.join((
            b'\xbd\x00A\xe5',
            bytes(self.id),
        ))

    @classmethod
    def from_reader(cls, reader):
        _id = reader.tgread_object()
        return cls(id=_id)

