"""File auto-generated by tglib TL generator. Do not edit manually."""
from ..tlobject import TLObject
from ..tlobject import TLRequest
from typing import Optional, List, Union
import os
import struct
from datetime import datetime


class AcceptLoginTokenRequest(TLRequest):
    """TL type: auth.acceptLoginToken"""
    CONSTRUCTOR_ID = 0xe894ad4d
    SUBCLASS_OF_ID = 0xc913c01a

    def __init__(self, token: bytes):
        self.token = token

    def to_dict(self):
        return {
            '_': 'AcceptLoginTokenRequest',
            'token': self.token,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.token))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_token = reader.tgread_bytes()
        _args['token'] = _val_token
        return cls(**_args)


class BindTempAuthKeyRequest(TLRequest):
    """TL type: auth.bindTempAuthKey"""
    CONSTRUCTOR_ID = 0xcdd42a05
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, perm_auth_key_id: int, nonce: int, expires_at: Optional[datetime], encrypted_message: bytes):
        self.perm_auth_key_id = perm_auth_key_id
        self.nonce = nonce
        self.expires_at = expires_at
        self.encrypted_message = encrypted_message

    def to_dict(self):
        return {
            '_': 'BindTempAuthKeyRequest',
            'perm_auth_key_id': self.perm_auth_key_id,
            'nonce': self.nonce,
            'expires_at': self.expires_at,
            'encrypted_message': self.encrypted_message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.perm_auth_key_id))
        buf.write(struct.pack('<q', self.nonce))
        buf.write(struct.pack('<i', self.expires_at))
        buf.write(TLObject.serialize_bytes(self.encrypted_message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_perm_auth_key_id = reader.read_long()
        _args['perm_auth_key_id'] = _val_perm_auth_key_id
        _val_nonce = reader.read_long()
        _args['nonce'] = _val_nonce
        _val_expires_at = reader.read_int()
        _args['expires_at'] = _val_expires_at
        _val_encrypted_message = reader.tgread_bytes()
        _args['encrypted_message'] = _val_encrypted_message
        return cls(**_args)


class CancelCodeRequest(TLRequest):
    """TL type: auth.cancelCode"""
    CONSTRUCTOR_ID = 0x1f040578
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, phone_number: str, phone_code_hash: str):
        self.phone_number = phone_number
        self.phone_code_hash = phone_code_hash

    def to_dict(self):
        return {
            '_': 'CancelCodeRequest',
            'phone_number': self.phone_number,
            'phone_code_hash': self.phone_code_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.phone_number))
        buf.write(TLObject.serialize_bytes(self.phone_code_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_phone_number = reader.tgread_string()
        _args['phone_number'] = _val_phone_number
        _val_phone_code_hash = reader.tgread_string()
        _args['phone_code_hash'] = _val_phone_code_hash
        return cls(**_args)


class CheckPaidAuthRequest(TLRequest):
    """TL type: auth.checkPaidAuth"""
    CONSTRUCTOR_ID = 0x56e59f9c
    SUBCLASS_OF_ID = 0x6ce87081

    def __init__(self, phone_number: str, phone_code_hash: str, form_id: int):
        self.phone_number = phone_number
        self.phone_code_hash = phone_code_hash
        self.form_id = form_id

    def to_dict(self):
        return {
            '_': 'CheckPaidAuthRequest',
            'phone_number': self.phone_number,
            'phone_code_hash': self.phone_code_hash,
            'form_id': self.form_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.phone_number))
        buf.write(TLObject.serialize_bytes(self.phone_code_hash))
        buf.write(struct.pack('<q', self.form_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_phone_number = reader.tgread_string()
        _args['phone_number'] = _val_phone_number
        _val_phone_code_hash = reader.tgread_string()
        _args['phone_code_hash'] = _val_phone_code_hash
        _val_form_id = reader.read_long()
        _args['form_id'] = _val_form_id
        return cls(**_args)


class CheckPasswordRequest(TLRequest):
    """TL type: auth.checkPassword"""
    CONSTRUCTOR_ID = 0xd18b4d16
    SUBCLASS_OF_ID = 0xb9e04e39

    def __init__(self, password: 'TypeInputCheckPasswordSRP'):
        self.password = password

    def to_dict(self):
        return {
            '_': 'CheckPasswordRequest',
            'password': self.password,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.password))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_password = reader.tgread_object()
        _args['password'] = _val_password
        return cls(**_args)


class CheckRecoveryPasswordRequest(TLRequest):
    """TL type: auth.checkRecoveryPassword"""
    CONSTRUCTOR_ID = 0x0d36bf79
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, code: str):
        self.code = code

    def to_dict(self):
        return {
            '_': 'CheckRecoveryPasswordRequest',
            'code': self.code,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.code))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_code = reader.tgread_string()
        _args['code'] = _val_code
        return cls(**_args)


class DropTempAuthKeysRequest(TLRequest):
    """TL type: auth.dropTempAuthKeys"""
    CONSTRUCTOR_ID = 0x8e48a188
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, except_auth_keys: List[int]):
        self.except_auth_keys = except_auth_keys

    def to_dict(self):
        return {
            '_': 'DropTempAuthKeysRequest',
            'except_auth_keys': self.except_auth_keys,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.except_auth_keys)))
        for item in self.except_auth_keys:
            buf.write(struct.pack('<q', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_except_auth_keys = reader.read_int()
        _list_except_auth_keys = []
        for _ in range(_count_except_auth_keys):
            _item_except_auth_keys = reader.read_long()
            _list_except_auth_keys.append(_item_except_auth_keys)
        _args['except_auth_keys'] = _list_except_auth_keys
        return cls(**_args)


class ExportAuthorizationRequest(TLRequest):
    """TL type: auth.exportAuthorization"""
    CONSTRUCTOR_ID = 0xe5bfffcd
    SUBCLASS_OF_ID = 0x5fd1ec51

    def __init__(self, dc_id: int):
        self.dc_id = dc_id

    def to_dict(self):
        return {
            '_': 'ExportAuthorizationRequest',
            'dc_id': self.dc_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.dc_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_dc_id = reader.read_int()
        _args['dc_id'] = _val_dc_id
        return cls(**_args)


class ExportLoginTokenRequest(TLRequest):
    """TL type: auth.exportLoginToken"""
    CONSTRUCTOR_ID = 0xb7e085fe
    SUBCLASS_OF_ID = 0x6b55f636

    def __init__(self, api_id: int, api_hash: str, except_ids: List[int]):
        self.api_id = api_id
        self.api_hash = api_hash
        self.except_ids = except_ids

    def to_dict(self):
        return {
            '_': 'ExportLoginTokenRequest',
            'api_id': self.api_id,
            'api_hash': self.api_hash,
            'except_ids': self.except_ids,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.api_id))
        buf.write(TLObject.serialize_bytes(self.api_hash))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.except_ids)))
        for item in self.except_ids:
            buf.write(struct.pack('<q', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_api_id = reader.read_int()
        _args['api_id'] = _val_api_id
        _val_api_hash = reader.tgread_string()
        _args['api_hash'] = _val_api_hash
        reader.read_int(signed=False)  # skip vector id
        _count_except_ids = reader.read_int()
        _list_except_ids = []
        for _ in range(_count_except_ids):
            _item_except_ids = reader.read_long()
            _list_except_ids.append(_item_except_ids)
        _args['except_ids'] = _list_except_ids
        return cls(**_args)


class FinishPasskeyLoginRequest(TLRequest):
    """TL type: auth.finishPasskeyLogin"""
    CONSTRUCTOR_ID = 0x9857ad07
    SUBCLASS_OF_ID = 0xb9e04e39

    def __init__(self, credential: 'TypeInputPasskeyCredential', from_dc_id: Optional[int] = None, from_auth_key_id: Optional[int] = None):
        self.credential = credential
        self.from_dc_id = from_dc_id
        self.from_auth_key_id = from_auth_key_id

    def to_dict(self):
        return {
            '_': 'FinishPasskeyLoginRequest',
            'credential': self.credential,
            'from_dc_id': self.from_dc_id,
            'from_auth_key_id': self.from_auth_key_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.from_auth_key_id is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.credential))
        if self.from_dc_id is not None:
            buf.write(struct.pack('<i', self.from_dc_id))
        if self.from_auth_key_id is not None:
            buf.write(struct.pack('<q', self.from_auth_key_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_credential = reader.tgread_object()
        _args['credential'] = _val_credential
        if flags & (1 << 0):
            _val_from_dc_id = reader.read_int()
            _args['from_dc_id'] = _val_from_dc_id
        else:
            _args['from_dc_id'] = None
        if flags & (1 << 0):
            _val_from_auth_key_id = reader.read_long()
            _args['from_auth_key_id'] = _val_from_auth_key_id
        else:
            _args['from_auth_key_id'] = None
        return cls(**_args)


class ImportAuthorizationRequest(TLRequest):
    """TL type: auth.importAuthorization"""
    CONSTRUCTOR_ID = 0xa57a7dad
    SUBCLASS_OF_ID = 0xb9e04e39

    def __init__(self, id: int, bytes: bytes):
        self.id = id
        self.bytes = bytes

    def to_dict(self):
        return {
            '_': 'ImportAuthorizationRequest',
            'id': self.id,
            'bytes': self.bytes,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(TLObject.serialize_bytes(self.bytes))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_bytes = reader.tgread_bytes()
        _args['bytes'] = _val_bytes
        return cls(**_args)


class ImportBotAuthorizationRequest(TLRequest):
    """TL type: auth.importBotAuthorization"""
    CONSTRUCTOR_ID = 0x67a3ff2c
    SUBCLASS_OF_ID = 0xb9e04e39

    def __init__(self, flags: int, api_id: int, api_hash: str, bot_auth_token: str):
        self.flags = flags
        self.api_id = api_id
        self.api_hash = api_hash
        self.bot_auth_token = bot_auth_token

    def to_dict(self):
        return {
            '_': 'ImportBotAuthorizationRequest',
            'flags': self.flags,
            'api_id': self.api_id,
            'api_hash': self.api_hash,
            'bot_auth_token': self.bot_auth_token,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.flags))
        buf.write(struct.pack('<i', self.api_id))
        buf.write(TLObject.serialize_bytes(self.api_hash))
        buf.write(TLObject.serialize_bytes(self.bot_auth_token))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_flags = reader.read_int()
        _args['flags'] = _val_flags
        _val_api_id = reader.read_int()
        _args['api_id'] = _val_api_id
        _val_api_hash = reader.tgread_string()
        _args['api_hash'] = _val_api_hash
        _val_bot_auth_token = reader.tgread_string()
        _args['bot_auth_token'] = _val_bot_auth_token
        return cls(**_args)


class ImportLoginTokenRequest(TLRequest):
    """TL type: auth.importLoginToken"""
    CONSTRUCTOR_ID = 0x95ac5ce4
    SUBCLASS_OF_ID = 0x6b55f636

    def __init__(self, token: bytes):
        self.token = token

    def to_dict(self):
        return {
            '_': 'ImportLoginTokenRequest',
            'token': self.token,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.token))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_token = reader.tgread_bytes()
        _args['token'] = _val_token
        return cls(**_args)


class ImportWebTokenAuthorizationRequest(TLRequest):
    """TL type: auth.importWebTokenAuthorization"""
    CONSTRUCTOR_ID = 0x2db873a9
    SUBCLASS_OF_ID = 0xb9e04e39

    def __init__(self, api_id: int, api_hash: str, web_auth_token: str):
        self.api_id = api_id
        self.api_hash = api_hash
        self.web_auth_token = web_auth_token

    def to_dict(self):
        return {
            '_': 'ImportWebTokenAuthorizationRequest',
            'api_id': self.api_id,
            'api_hash': self.api_hash,
            'web_auth_token': self.web_auth_token,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.api_id))
        buf.write(TLObject.serialize_bytes(self.api_hash))
        buf.write(TLObject.serialize_bytes(self.web_auth_token))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_api_id = reader.read_int()
        _args['api_id'] = _val_api_id
        _val_api_hash = reader.tgread_string()
        _args['api_hash'] = _val_api_hash
        _val_web_auth_token = reader.tgread_string()
        _args['web_auth_token'] = _val_web_auth_token
        return cls(**_args)


class InitPasskeyLoginRequest(TLRequest):
    """TL type: auth.initPasskeyLogin"""
    CONSTRUCTOR_ID = 0x518ad0b7
    SUBCLASS_OF_ID = 0xd9793032

    def __init__(self, api_id: int, api_hash: str):
        self.api_id = api_id
        self.api_hash = api_hash

    def to_dict(self):
        return {
            '_': 'InitPasskeyLoginRequest',
            'api_id': self.api_id,
            'api_hash': self.api_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.api_id))
        buf.write(TLObject.serialize_bytes(self.api_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_api_id = reader.read_int()
        _args['api_id'] = _val_api_id
        _val_api_hash = reader.tgread_string()
        _args['api_hash'] = _val_api_hash
        return cls(**_args)


class LogOutRequest(TLRequest):
    """TL type: auth.logOut"""
    CONSTRUCTOR_ID = 0x3e72ba19
    SUBCLASS_OF_ID = 0x0a804315

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'LogOutRequest',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

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


class RecoverPasswordRequest(TLRequest):
    """TL type: auth.recoverPassword"""
    CONSTRUCTOR_ID = 0x37096c70
    SUBCLASS_OF_ID = 0xb9e04e39

    def __init__(self, code: str, new_settings: Optional['TypePasswordInputSettings'] = None):
        self.code = code
        self.new_settings = new_settings

    def to_dict(self):
        return {
            '_': 'RecoverPasswordRequest',
            'code': self.code,
            'new_settings': self.new_settings,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.new_settings is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.code))
        if self.new_settings is not None:
            buf.write(bytes(self.new_settings))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_code = reader.tgread_string()
        _args['code'] = _val_code
        if flags & (1 << 0):
            _val_new_settings = reader.tgread_object()
            _args['new_settings'] = _val_new_settings
        else:
            _args['new_settings'] = None
        return cls(**_args)


class ReportMissingCodeRequest(TLRequest):
    """TL type: auth.reportMissingCode"""
    CONSTRUCTOR_ID = 0xcb9deff6
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, phone_number: str, phone_code_hash: str, mnc: str):
        self.phone_number = phone_number
        self.phone_code_hash = phone_code_hash
        self.mnc = mnc

    def to_dict(self):
        return {
            '_': 'ReportMissingCodeRequest',
            'phone_number': self.phone_number,
            'phone_code_hash': self.phone_code_hash,
            'mnc': self.mnc,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.phone_number))
        buf.write(TLObject.serialize_bytes(self.phone_code_hash))
        buf.write(TLObject.serialize_bytes(self.mnc))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_phone_number = reader.tgread_string()
        _args['phone_number'] = _val_phone_number
        _val_phone_code_hash = reader.tgread_string()
        _args['phone_code_hash'] = _val_phone_code_hash
        _val_mnc = reader.tgread_string()
        _args['mnc'] = _val_mnc
        return cls(**_args)


class RequestFirebaseSmsRequest(TLRequest):
    """TL type: auth.requestFirebaseSms"""
    CONSTRUCTOR_ID = 0x8e39261e
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, phone_number: str, phone_code_hash: str, safety_net_token: Optional[str] = None, play_integrity_token: Optional[str] = None, ios_push_secret: Optional[str] = None):
        self.phone_number = phone_number
        self.phone_code_hash = phone_code_hash
        self.safety_net_token = safety_net_token
        self.play_integrity_token = play_integrity_token
        self.ios_push_secret = ios_push_secret

    def to_dict(self):
        return {
            '_': 'RequestFirebaseSmsRequest',
            'phone_number': self.phone_number,
            'phone_code_hash': self.phone_code_hash,
            'safety_net_token': self.safety_net_token,
            'play_integrity_token': self.play_integrity_token,
            'ios_push_secret': self.ios_push_secret,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.safety_net_token is not None:
            flags |= (1 << 0)
        if self.play_integrity_token is not None:
            flags |= (1 << 2)
        if self.ios_push_secret is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.phone_number))
        buf.write(TLObject.serialize_bytes(self.phone_code_hash))
        if self.safety_net_token is not None:
            buf.write(TLObject.serialize_bytes(self.safety_net_token))
        if self.play_integrity_token is not None:
            buf.write(TLObject.serialize_bytes(self.play_integrity_token))
        if self.ios_push_secret is not None:
            buf.write(TLObject.serialize_bytes(self.ios_push_secret))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_phone_number = reader.tgread_string()
        _args['phone_number'] = _val_phone_number
        _val_phone_code_hash = reader.tgread_string()
        _args['phone_code_hash'] = _val_phone_code_hash
        if flags & (1 << 0):
            _val_safety_net_token = reader.tgread_string()
            _args['safety_net_token'] = _val_safety_net_token
        else:
            _args['safety_net_token'] = None
        if flags & (1 << 2):
            _val_play_integrity_token = reader.tgread_string()
            _args['play_integrity_token'] = _val_play_integrity_token
        else:
            _args['play_integrity_token'] = None
        if flags & (1 << 1):
            _val_ios_push_secret = reader.tgread_string()
            _args['ios_push_secret'] = _val_ios_push_secret
        else:
            _args['ios_push_secret'] = None
        return cls(**_args)


class RequestPasswordRecoveryRequest(TLRequest):
    """TL type: auth.requestPasswordRecovery"""
    CONSTRUCTOR_ID = 0xd897bc66
    SUBCLASS_OF_ID = 0xfa72d43a

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'RequestPasswordRecoveryRequest',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

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


class ResendCodeRequest(TLRequest):
    """TL type: auth.resendCode"""
    CONSTRUCTOR_ID = 0xcae47523
    SUBCLASS_OF_ID = 0x6ce87081

    def __init__(self, phone_number: str, phone_code_hash: str, reason: Optional[str] = None):
        self.phone_number = phone_number
        self.phone_code_hash = phone_code_hash
        self.reason = reason

    def to_dict(self):
        return {
            '_': 'ResendCodeRequest',
            'phone_number': self.phone_number,
            'phone_code_hash': self.phone_code_hash,
            'reason': self.reason,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.reason is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.phone_number))
        buf.write(TLObject.serialize_bytes(self.phone_code_hash))
        if self.reason is not None:
            buf.write(TLObject.serialize_bytes(self.reason))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_phone_number = reader.tgread_string()
        _args['phone_number'] = _val_phone_number
        _val_phone_code_hash = reader.tgread_string()
        _args['phone_code_hash'] = _val_phone_code_hash
        if flags & (1 << 0):
            _val_reason = reader.tgread_string()
            _args['reason'] = _val_reason
        else:
            _args['reason'] = None
        return cls(**_args)


class ResetAuthorizationsRequest(TLRequest):
    """TL type: auth.resetAuthorizations"""
    CONSTRUCTOR_ID = 0x9fab0d1a
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ResetAuthorizationsRequest',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

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


class ResetLoginEmailRequest(TLRequest):
    """TL type: auth.resetLoginEmail"""
    CONSTRUCTOR_ID = 0x7e960193
    SUBCLASS_OF_ID = 0x6ce87081

    def __init__(self, phone_number: str, phone_code_hash: str):
        self.phone_number = phone_number
        self.phone_code_hash = phone_code_hash

    def to_dict(self):
        return {
            '_': 'ResetLoginEmailRequest',
            'phone_number': self.phone_number,
            'phone_code_hash': self.phone_code_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.phone_number))
        buf.write(TLObject.serialize_bytes(self.phone_code_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_phone_number = reader.tgread_string()
        _args['phone_number'] = _val_phone_number
        _val_phone_code_hash = reader.tgread_string()
        _args['phone_code_hash'] = _val_phone_code_hash
        return cls(**_args)


class SendCodeRequest(TLRequest):
    """TL type: auth.sendCode"""
    CONSTRUCTOR_ID = 0xa677244f
    SUBCLASS_OF_ID = 0x6ce87081

    def __init__(self, phone_number: str, api_id: int, api_hash: str, settings: 'TypeCodeSettings'):
        self.phone_number = phone_number
        self.api_id = api_id
        self.api_hash = api_hash
        self.settings = settings

    def to_dict(self):
        return {
            '_': 'SendCodeRequest',
            'phone_number': self.phone_number,
            'api_id': self.api_id,
            'api_hash': self.api_hash,
            'settings': self.settings,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.phone_number))
        buf.write(struct.pack('<i', self.api_id))
        buf.write(TLObject.serialize_bytes(self.api_hash))
        buf.write(bytes(self.settings))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_phone_number = reader.tgread_string()
        _args['phone_number'] = _val_phone_number
        _val_api_id = reader.read_int()
        _args['api_id'] = _val_api_id
        _val_api_hash = reader.tgread_string()
        _args['api_hash'] = _val_api_hash
        _val_settings = reader.tgread_object()
        _args['settings'] = _val_settings
        return cls(**_args)


class SignInRequest(TLRequest):
    """TL type: auth.signIn"""
    CONSTRUCTOR_ID = 0x8d52a951
    SUBCLASS_OF_ID = 0xb9e04e39

    def __init__(self, phone_number: str, phone_code_hash: str, phone_code: Optional[str] = None, email_verification: Optional['TypeEmailVerification'] = None):
        self.phone_number = phone_number
        self.phone_code_hash = phone_code_hash
        self.phone_code = phone_code
        self.email_verification = email_verification

    def to_dict(self):
        return {
            '_': 'SignInRequest',
            'phone_number': self.phone_number,
            'phone_code_hash': self.phone_code_hash,
            'phone_code': self.phone_code,
            'email_verification': self.email_verification,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.phone_code is not None:
            flags |= (1 << 0)
        if self.email_verification is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.phone_number))
        buf.write(TLObject.serialize_bytes(self.phone_code_hash))
        if self.phone_code is not None:
            buf.write(TLObject.serialize_bytes(self.phone_code))
        if self.email_verification is not None:
            buf.write(bytes(self.email_verification))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_phone_number = reader.tgread_string()
        _args['phone_number'] = _val_phone_number
        _val_phone_code_hash = reader.tgread_string()
        _args['phone_code_hash'] = _val_phone_code_hash
        if flags & (1 << 0):
            _val_phone_code = reader.tgread_string()
            _args['phone_code'] = _val_phone_code
        else:
            _args['phone_code'] = None
        if flags & (1 << 1):
            _val_email_verification = reader.tgread_object()
            _args['email_verification'] = _val_email_verification
        else:
            _args['email_verification'] = None
        return cls(**_args)


class SignUpRequest(TLRequest):
    """TL type: auth.signUp"""
    CONSTRUCTOR_ID = 0xaac7b717
    SUBCLASS_OF_ID = 0xb9e04e39

    def __init__(self, phone_number: str, phone_code_hash: str, first_name: str, last_name: str, no_joined_notifications: Optional[bool] = None):
        self.phone_number = phone_number
        self.phone_code_hash = phone_code_hash
        self.first_name = first_name
        self.last_name = last_name
        self.no_joined_notifications = no_joined_notifications

    def to_dict(self):
        return {
            '_': 'SignUpRequest',
            'phone_number': self.phone_number,
            'phone_code_hash': self.phone_code_hash,
            'first_name': self.first_name,
            'last_name': self.last_name,
            'no_joined_notifications': self.no_joined_notifications,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.no_joined_notifications:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.phone_number))
        buf.write(TLObject.serialize_bytes(self.phone_code_hash))
        buf.write(TLObject.serialize_bytes(self.first_name))
        buf.write(TLObject.serialize_bytes(self.last_name))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['no_joined_notifications'] = bool(flags & (1 << 0))
        _val_phone_number = reader.tgread_string()
        _args['phone_number'] = _val_phone_number
        _val_phone_code_hash = reader.tgread_string()
        _args['phone_code_hash'] = _val_phone_code_hash
        _val_first_name = reader.tgread_string()
        _args['first_name'] = _val_first_name
        _val_last_name = reader.tgread_string()
        _args['last_name'] = _val_last_name
        return cls(**_args)

