"""File generated by TLObjects' generator. All changes will be ERASED"""
from ..._misc.tlobject import TLObject, TLRequest
from typing import Optional, List, Union, TYPE_CHECKING
from . import account, auth, bots, channels, contacts, folders, help, langpack, messages, payments, phone, photos, stats, stickers, updates, upload, users
import os
import struct
import dataclasses
from datetime import datetime
if TYPE_CHECKING:
    from .. import TypeInputClientProxy, TypeJSONValue, TypeMessageRange, TypeType, TypeX



@dataclasses.dataclass(init=False, frozen=True)
class DestroyAuthKey(TLRequest):
    """
    :returns DestroyAuthKeyRes: Instance of either DestroyAuthKeyOk, DestroyAuthKeyNone, DestroyAuthKeyFail.
    """
    __slots__ = ()
    CONSTRUCTOR_ID = 0xd1435160
    SUBCLASS_OF_ID = 0x8291e68e

    def _bytes(self):
        return b''.join((
            b'`QC\xd1',
        ))

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


@dataclasses.dataclass(init=False, frozen=True)
class DestroySession(TLRequest):
    """
    :returns DestroySessionRes: Instance of either DestroySessionOk, DestroySessionNone.
    """
    __slots__ = ('session_id',)
    CONSTRUCTOR_ID = 0xe7512126
    SUBCLASS_OF_ID = 0xaf0ce7bd

    session_id: int
    def __init__(self, session_id: int):
        object.__setattr__(self, 'session_id', session_id)

    def _bytes(self):
        return b''.join((
            b'&!Q\xe7',
            struct.pack('<q', self.session_id),
        ))

    @classmethod
    def _from_reader(cls, reader):
        _session_id = reader.read_long()
        return cls(session_id=_session_id)


@dataclasses.dataclass(init=False, frozen=True)
class GetFutureSalts(TLRequest):
    """
    :returns FutureSalts: Instance of FutureSalts.
    """
    __slots__ = ('num',)
    CONSTRUCTOR_ID = 0xb921bd04
    SUBCLASS_OF_ID = 0x1090f517

    num: int
    def __init__(self, num: int):
        object.__setattr__(self, 'num', num)

    def _bytes(self):
        return b''.join((
            b'\x04\xbd!\xb9',
            struct.pack('<i', self.num),
        ))

    @classmethod
    def _from_reader(cls, reader):
        _num = reader.read_int()
        return cls(num=_num)


@dataclasses.dataclass(init=False, frozen=True)
class InitConnection(TLRequest):
    """
    :returns X: This type has no constructors.
    """
    __slots__ = ('api_id', 'device_model', 'system_version', 'app_version', 'system_lang_code', 'lang_pack', 'lang_code', 'query', 'proxy', 'params',)
    CONSTRUCTOR_ID = 0xc1cd5ea9
    SUBCLASS_OF_ID = 0xb7b2364b

    api_id: int
    device_model: str
    system_version: str
    app_version: str
    system_lang_code: str
    lang_pack: str
    lang_code: str
    query: 'TypeX'
    proxy: Optional['TypeInputClientProxy']
    params: Optional['TypeJSONValue']
    def __init__(self, api_id: int, device_model: str, system_version: str, app_version: str, system_lang_code: str, lang_pack: str, lang_code: str, query: 'TypeX', proxy: Optional['TypeInputClientProxy']=None, params: Optional['TypeJSONValue']=None):
        object.__setattr__(self, 'api_id', api_id)
        object.__setattr__(self, 'device_model', device_model)
        object.__setattr__(self, 'system_version', system_version)
        object.__setattr__(self, 'app_version', app_version)
        object.__setattr__(self, 'system_lang_code', system_lang_code)
        object.__setattr__(self, 'lang_pack', lang_pack)
        object.__setattr__(self, 'lang_code', lang_code)
        object.__setattr__(self, 'query', query)
        object.__setattr__(self, 'proxy', proxy)
        object.__setattr__(self, 'params', params)

    def _bytes(self):
        return b''.join((
            b'\xa9^\xcd\xc1',
            struct.pack('<I', (0 if self.proxy is None or self.proxy is False else 1) | (0 if self.params is None or self.params is False else 2)),
            struct.pack('<i', self.api_id),
            self._serialize_bytes(self.device_model),
            self._serialize_bytes(self.system_version),
            self._serialize_bytes(self.app_version),
            self._serialize_bytes(self.system_lang_code),
            self._serialize_bytes(self.lang_pack),
            self._serialize_bytes(self.lang_code),
            b'' if self.proxy is None or self.proxy is False else (self.proxy._bytes()),
            b'' if self.params is None or self.params is False else (self.params._bytes()),
            self.query._bytes(),
        ))

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

        _api_id = reader.read_int()
        _device_model = reader.tgread_string()
        _system_version = reader.tgread_string()
        _app_version = reader.tgread_string()
        _system_lang_code = reader.tgread_string()
        _lang_pack = reader.tgread_string()
        _lang_code = reader.tgread_string()
        if flags & 1:
            _proxy = reader.tgread_object()
        else:
            _proxy = None
        if flags & 2:
            _params = reader.tgread_object()
        else:
            _params = None
        _query = reader.tgread_object()
        return cls(api_id=_api_id, device_model=_device_model, system_version=_system_version, app_version=_app_version, system_lang_code=_system_lang_code, lang_pack=_lang_pack, lang_code=_lang_code, query=_query, proxy=_proxy, params=_params)


@dataclasses.dataclass(init=False, frozen=True)
class InvokeAfterMsg(TLRequest):
    """
    :returns X: This type has no constructors.
    """
    __slots__ = ('msg_id', 'query',)
    CONSTRUCTOR_ID = 0xcb9f372d
    SUBCLASS_OF_ID = 0xb7b2364b

    msg_id: int
    query: 'TypeX'
    def __init__(self, msg_id: int, query: 'TypeX'):
        object.__setattr__(self, 'msg_id', msg_id)
        object.__setattr__(self, 'query', query)

    def _bytes(self):
        return b''.join((
            b'-7\x9f\xcb',
            struct.pack('<q', self.msg_id),
            self.query._bytes(),
        ))

    @classmethod
    def _from_reader(cls, reader):
        _msg_id = reader.read_long()
        _query = reader.tgread_object()
        return cls(msg_id=_msg_id, query=_query)


@dataclasses.dataclass(init=False, frozen=True)
class InvokeAfterMsgs(TLRequest):
    """
    :returns X: This type has no constructors.
    """
    __slots__ = ('msg_ids', 'query',)
    CONSTRUCTOR_ID = 0x3dc4b4f0
    SUBCLASS_OF_ID = 0xb7b2364b

    msg_ids: List[int]
    query: 'TypeX'
    def __init__(self, msg_ids: List[int], query: 'TypeX'):
        object.__setattr__(self, 'msg_ids', msg_ids)
        object.__setattr__(self, 'query', query)

    def _bytes(self):
        return b''.join((
            b'\xf0\xb4\xc4=',
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.msg_ids)),b''.join(struct.pack('<q', x) for x in self.msg_ids),
            self.query._bytes(),
        ))

    @classmethod
    def _from_reader(cls, reader):
        reader.read_int()
        _msg_ids = []
        for _ in range(reader.read_int()):
            _x = reader.read_long()
            _msg_ids.append(_x)

        _query = reader.tgread_object()
        return cls(msg_ids=_msg_ids, query=_query)


@dataclasses.dataclass(init=False, frozen=True)
class InvokeWithLayer(TLRequest):
    """
    :returns X: This type has no constructors.
    """
    __slots__ = ('layer', 'query',)
    CONSTRUCTOR_ID = 0xda9b0d0d
    SUBCLASS_OF_ID = 0xb7b2364b

    layer: int
    query: 'TypeX'
    def __init__(self, layer: int, query: 'TypeX'):
        object.__setattr__(self, 'layer', layer)
        object.__setattr__(self, 'query', query)

    def _bytes(self):
        return b''.join((
            b'\r\r\x9b\xda',
            struct.pack('<i', self.layer),
            self.query._bytes(),
        ))

    @classmethod
    def _from_reader(cls, reader):
        _layer = reader.read_int()
        _query = reader.tgread_object()
        return cls(layer=_layer, query=_query)


@dataclasses.dataclass(init=False, frozen=True)
class InvokeWithMessagesRange(TLRequest):
    """
    :returns X: This type has no constructors.
    """
    __slots__ = ('range', 'query',)
    CONSTRUCTOR_ID = 0x365275f2
    SUBCLASS_OF_ID = 0xb7b2364b

    range: 'TypeMessageRange'
    query: 'TypeX'
    # noinspection PyShadowingBuiltins
    def __init__(self, range: 'TypeMessageRange', query: 'TypeX'):
        object.__setattr__(self, 'range', range)
        object.__setattr__(self, 'query', query)

    def _bytes(self):
        return b''.join((
            b'\xf2uR6',
            self.range._bytes(),
            self.query._bytes(),
        ))

    @classmethod
    def _from_reader(cls, reader):
        _range = reader.tgread_object()
        _query = reader.tgread_object()
        return cls(range=_range, query=_query)


@dataclasses.dataclass(init=False, frozen=True)
class InvokeWithTakeout(TLRequest):
    """
    :returns X: This type has no constructors.
    """
    __slots__ = ('takeout_id', 'query',)
    CONSTRUCTOR_ID = 0xaca9fd2e
    SUBCLASS_OF_ID = 0xb7b2364b

    takeout_id: int
    query: 'TypeX'
    def __init__(self, takeout_id: int, query: 'TypeX'):
        object.__setattr__(self, 'takeout_id', takeout_id)
        object.__setattr__(self, 'query', query)

    def _bytes(self):
        return b''.join((
            b'.\xfd\xa9\xac',
            struct.pack('<q', self.takeout_id),
            self.query._bytes(),
        ))

    @classmethod
    def _from_reader(cls, reader):
        _takeout_id = reader.read_long()
        _query = reader.tgread_object()
        return cls(takeout_id=_takeout_id, query=_query)


@dataclasses.dataclass(init=False, frozen=True)
class InvokeWithoutUpdates(TLRequest):
    """
    :returns X: This type has no constructors.
    """
    __slots__ = ('query',)
    CONSTRUCTOR_ID = 0xbf9459b7
    SUBCLASS_OF_ID = 0xb7b2364b

    query: 'TypeX'
    def __init__(self, query: 'TypeX'):
        object.__setattr__(self, 'query', query)

    def _bytes(self):
        return b''.join((
            b'\xb7Y\x94\xbf',
            self.query._bytes(),
        ))

    @classmethod
    def _from_reader(cls, reader):
        _query = reader.tgread_object()
        return cls(query=_query)


@dataclasses.dataclass(init=False, frozen=True)
class Ping(TLRequest):
    """
    :returns Pong: Instance of Pong.
    """
    __slots__ = ('ping_id',)
    CONSTRUCTOR_ID = 0x7abe77ec
    SUBCLASS_OF_ID = 0x816aee71

    ping_id: int
    def __init__(self, ping_id: int):
        object.__setattr__(self, 'ping_id', ping_id)

    def _bytes(self):
        return b''.join((
            b'\xecw\xbez',
            struct.pack('<q', self.ping_id),
        ))

    @classmethod
    def _from_reader(cls, reader):
        _ping_id = reader.read_long()
        return cls(ping_id=_ping_id)


@dataclasses.dataclass(init=False, frozen=True)
class PingDelayDisconnect(TLRequest):
    """
    :returns Pong: Instance of Pong.
    """
    __slots__ = ('ping_id', 'disconnect_delay',)
    CONSTRUCTOR_ID = 0xf3427b8c
    SUBCLASS_OF_ID = 0x816aee71

    ping_id: int
    disconnect_delay: int
    def __init__(self, ping_id: int, disconnect_delay: int):
        object.__setattr__(self, 'ping_id', ping_id)
        object.__setattr__(self, 'disconnect_delay', disconnect_delay)

    def _bytes(self):
        return b''.join((
            b'\x8c{B\xf3',
            struct.pack('<q', self.ping_id),
            struct.pack('<i', self.disconnect_delay),
        ))

    @classmethod
    def _from_reader(cls, reader):
        _ping_id = reader.read_long()
        _disconnect_delay = reader.read_int()
        return cls(ping_id=_ping_id, disconnect_delay=_disconnect_delay)


@dataclasses.dataclass(init=False, frozen=True)
class ReqDHParams(TLRequest):
    """
    :returns Server_DH_Params: Instance of either ServerDHParamsFail, ServerDHParamsOk.
    """
    __slots__ = ('nonce', 'server_nonce', 'p', 'q', 'public_key_fingerprint', 'encrypted_data',)
    CONSTRUCTOR_ID = 0xd712e4be
    SUBCLASS_OF_ID = 0xa6188d9e

    nonce: int
    server_nonce: int
    p: bytes
    q: bytes
    public_key_fingerprint: int
    encrypted_data: bytes
    def __init__(self, nonce: int, server_nonce: int, p: bytes, q: bytes, public_key_fingerprint: int, encrypted_data: bytes):
        object.__setattr__(self, 'nonce', nonce)
        object.__setattr__(self, 'server_nonce', server_nonce)
        object.__setattr__(self, 'p', p)
        object.__setattr__(self, 'q', q)
        object.__setattr__(self, 'public_key_fingerprint', public_key_fingerprint)
        object.__setattr__(self, 'encrypted_data', encrypted_data)

    def _bytes(self):
        return b''.join((
            b'\xbe\xe4\x12\xd7',
            self.nonce.to_bytes(16, 'little', signed=True),
            self.server_nonce.to_bytes(16, 'little', signed=True),
            self._serialize_bytes(self.p),
            self._serialize_bytes(self.q),
            struct.pack('<q', self.public_key_fingerprint),
            self._serialize_bytes(self.encrypted_data),
        ))

    @classmethod
    def _from_reader(cls, reader):
        _nonce = reader.read_large_int(bits=128)
        _server_nonce = reader.read_large_int(bits=128)
        _p = reader.tgread_bytes()
        _q = reader.tgread_bytes()
        _public_key_fingerprint = reader.read_long()
        _encrypted_data = reader.tgread_bytes()
        return cls(nonce=_nonce, server_nonce=_server_nonce, p=_p, q=_q, public_key_fingerprint=_public_key_fingerprint, encrypted_data=_encrypted_data)


@dataclasses.dataclass(init=False, frozen=True)
class ReqPq(TLRequest):
    """
    :returns ResPQ: Instance of ResPQ.
    """
    __slots__ = ('nonce',)
    CONSTRUCTOR_ID = 0x60469778
    SUBCLASS_OF_ID = 0x786986b8

    nonce: int
    def __init__(self, nonce: int):
        object.__setattr__(self, 'nonce', nonce)

    def _bytes(self):
        return b''.join((
            b'x\x97F`',
            self.nonce.to_bytes(16, 'little', signed=True),
        ))

    @classmethod
    def _from_reader(cls, reader):
        _nonce = reader.read_large_int(bits=128)
        return cls(nonce=_nonce)


@dataclasses.dataclass(init=False, frozen=True)
class ReqPqMulti(TLRequest):
    """
    :returns ResPQ: Instance of ResPQ.
    """
    __slots__ = ('nonce',)
    CONSTRUCTOR_ID = 0xbe7e8ef1
    SUBCLASS_OF_ID = 0x786986b8

    nonce: int
    def __init__(self, nonce: int):
        object.__setattr__(self, 'nonce', nonce)

    def _bytes(self):
        return b''.join((
            b'\xf1\x8e~\xbe',
            self.nonce.to_bytes(16, 'little', signed=True),
        ))

    @classmethod
    def _from_reader(cls, reader):
        _nonce = reader.read_large_int(bits=128)
        return cls(nonce=_nonce)


@dataclasses.dataclass(init=False, frozen=True)
class RpcDropAnswer(TLRequest):
    """
    :returns RpcDropAnswer: Instance of either RpcAnswerUnknown, RpcAnswerDroppedRunning, RpcAnswerDropped.
    """
    __slots__ = ('req_msg_id',)
    CONSTRUCTOR_ID = 0x58e4a740
    SUBCLASS_OF_ID = 0x4bca7570

    req_msg_id: int
    def __init__(self, req_msg_id: int):
        object.__setattr__(self, 'req_msg_id', req_msg_id)

    def _bytes(self):
        return b''.join((
            b'@\xa7\xe4X',
            struct.pack('<q', self.req_msg_id),
        ))

    @classmethod
    def _from_reader(cls, reader):
        _req_msg_id = reader.read_long()
        return cls(req_msg_id=_req_msg_id)


@dataclasses.dataclass(init=False, frozen=True)
class SetClientDHParams(TLRequest):
    """
    :returns Set_client_DH_params_answer: Instance of either DhGenOk, DhGenRetry, DhGenFail.
    """
    __slots__ = ('nonce', 'server_nonce', 'encrypted_data',)
    CONSTRUCTOR_ID = 0xf5045f1f
    SUBCLASS_OF_ID = 0x55dd6cdb

    nonce: int
    server_nonce: int
    encrypted_data: bytes
    def __init__(self, nonce: int, server_nonce: int, encrypted_data: bytes):
        object.__setattr__(self, 'nonce', nonce)
        object.__setattr__(self, 'server_nonce', server_nonce)
        object.__setattr__(self, 'encrypted_data', encrypted_data)

    def _bytes(self):
        return b''.join((
            b'\x1f_\x04\xf5',
            self.nonce.to_bytes(16, 'little', signed=True),
            self.server_nonce.to_bytes(16, 'little', signed=True),
            self._serialize_bytes(self.encrypted_data),
        ))

    @classmethod
    def _from_reader(cls, reader):
        _nonce = reader.read_large_int(bits=128)
        _server_nonce = reader.read_large_int(bits=128)
        _encrypted_data = reader.tgread_bytes()
        return cls(nonce=_nonce, server_nonce=_server_nonce, encrypted_data=_encrypted_data)

