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


class Authorization(TLObject):
    constructor_id = 0xcd050916
    subclass_of_id = 0xb9e04e39

    def __init__(self, user, tmp_sessions=None):
        """
        :param tmp_sessions: Telegram type: "int".
        :param user: Telegram type: "User".

        Constructor for auth.Authorization: Instance of Authorization.
        """
        super().__init__()

        self.tmp_sessions = tmp_sessions
        self.user = user

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

    def on_send(self, writer):
        writer.write_int(Authorization.constructor_id, signed=False)
        flags = 0
        flags |= (1 << 0) if self.tmp_sessions else 0
        writer.write_int(flags)

        if self.tmp_sessions:
            writer.write_int(self.tmp_sessions)

        self.user.on_send(writer)

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

    def on_response(self, reader):
        flags = reader.read_int()

        if (flags & (1 << 0)) != 0:
            self.tmp_sessions = reader.read_int()

        self.user = reader.tgread_object()

    def __repr__(self):
        return 'auth.authorization#cd050916 flags:# tmp_sessions:flags.0?int user:User = auth.Authorization'

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

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



class CheckedPhone(TLObject):
    constructor_id = 0x811ea28e
    subclass_of_id = 0x99a3d765

    def __init__(self, phone_registered):
        """
        :param phone_registered: Telegram type: "Bool".

        Constructor for auth.CheckedPhone: Instance of CheckedPhone.
        """
        super().__init__()

        self.phone_registered = phone_registered

    def to_dict(self):
        return {
            'phone_registered': self.phone_registered,
        }

    def on_send(self, writer):
        writer.write_int(CheckedPhone.constructor_id, signed=False)
        writer.tgwrite_bool(self.phone_registered)

    @staticmethod
    def empty():
        return CheckedPhone(None)

    def on_response(self, reader):
        self.phone_registered = reader.tgread_bool()

    def __repr__(self):
        return 'auth.checkedPhone#811ea28e phone_registered:Bool = auth.CheckedPhone'

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

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



class CodeTypeCall(TLObject):
    constructor_id = 0x741cd3e3
    subclass_of_id = 0xb3f3e401

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

    @staticmethod
    def to_dict():
        return {}

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

    @staticmethod
    def empty():
        return CodeTypeCall()

    def on_response(self, reader):
        pass

    def __repr__(self):
        return 'auth.codeTypeCall#741cd3e3 = auth.CodeType'

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

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



class CodeTypeFlashCall(TLObject):
    constructor_id = 0x226ccefb
    subclass_of_id = 0xb3f3e401

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

    @staticmethod
    def to_dict():
        return {}

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

    @staticmethod
    def empty():
        return CodeTypeFlashCall()

    def on_response(self, reader):
        pass

    def __repr__(self):
        return 'auth.codeTypeFlashCall#226ccefb = auth.CodeType'

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

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



class CodeTypeSms(TLObject):
    constructor_id = 0x72a3158c
    subclass_of_id = 0xb3f3e401

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

    @staticmethod
    def to_dict():
        return {}

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

    @staticmethod
    def empty():
        return CodeTypeSms()

    def on_response(self, reader):
        pass

    def __repr__(self):
        return 'auth.codeTypeSms#72a3158c = auth.CodeType'

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

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



class ExportedAuthorization(TLObject):
    constructor_id = 0xdf969c2d
    subclass_of_id = 0x5fd1ec51

    def __init__(self, id, bytes):
        """
        :param id: Telegram type: "int".
        :param bytes: Telegram type: "bytes".

        Constructor for auth.ExportedAuthorization: Instance of ExportedAuthorization.
        """
        super().__init__()

        self.id = id
        self.bytes = bytes

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

    def on_send(self, writer):
        writer.write_int(ExportedAuthorization.constructor_id, signed=False)
        writer.write_int(self.id)
        writer.tgwrite_bytes(self.bytes)

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

    def on_response(self, reader):
        self.id = reader.read_int()
        self.bytes = reader.tgread_bytes()

    def __repr__(self):
        return 'auth.exportedAuthorization#df969c2d id:int bytes:bytes = auth.ExportedAuthorization'

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

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



class PasswordRecovery(TLObject):
    constructor_id = 0x137948a5
    subclass_of_id = 0xfa72d43a

    def __init__(self, email_pattern):
        """
        :param email_pattern: Telegram type: "string".

        Constructor for auth.PasswordRecovery: Instance of PasswordRecovery.
        """
        super().__init__()

        self.email_pattern = email_pattern

    def to_dict(self):
        return {
            'email_pattern': self.email_pattern,
        }

    def on_send(self, writer):
        writer.write_int(PasswordRecovery.constructor_id, signed=False)
        writer.tgwrite_string(self.email_pattern)

    @staticmethod
    def empty():
        return PasswordRecovery(None)

    def on_response(self, reader):
        self.email_pattern = reader.tgread_string()

    def __repr__(self):
        return 'auth.passwordRecovery#137948a5 email_pattern:string = auth.PasswordRecovery'

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

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



class SentCode(TLObject):
    constructor_id = 0x5e002502
    subclass_of_id = 0x6ce87081

    def __init__(self, type, phone_code_hash, phone_registered=None, next_type=None, timeout=None):
        """
        :param phone_registered: Telegram type: "true".
        :param type: Telegram type: "auth.SentCodeType".
        :param phone_code_hash: Telegram type: "string".
        :param next_type: Telegram type: "auth.CodeType".
        :param timeout: Telegram type: "int".

        Constructor for auth.SentCode: Instance of SentCode.
        """
        super().__init__()

        self.phone_registered = phone_registered
        self.type = type
        self.phone_code_hash = phone_code_hash
        self.next_type = next_type
        self.timeout = timeout

    def to_dict(self):
        return {
            'phone_registered': self.phone_registered,
            'type': None if self.type is None else self.type.to_dict(),
            'phone_code_hash': self.phone_code_hash,
            'next_type': None if self.next_type is None else self.next_type.to_dict(),
            'timeout': self.timeout,
        }

    def on_send(self, writer):
        writer.write_int(SentCode.constructor_id, signed=False)
        flags = 0
        flags |= (1 << 0) if self.phone_registered else 0
        flags |= (1 << 1) if self.next_type else 0
        flags |= (1 << 2) if self.timeout else 0
        writer.write_int(flags)

        self.type.on_send(writer)
        writer.tgwrite_string(self.phone_code_hash)
        if self.next_type:
            self.next_type.on_send(writer)

        if self.timeout:
            writer.write_int(self.timeout)

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

    def on_response(self, reader):
        flags = reader.read_int()

        if (flags & (1 << 0)) != 0:
            self.phone_registered = True

        self.type = reader.tgread_object()
        self.phone_code_hash = reader.tgread_string()
        if (flags & (1 << 1)) != 0:
            self.next_type = reader.tgread_object()

        if (flags & (1 << 2)) != 0:
            self.timeout = reader.read_int()

    def __repr__(self):
        return 'auth.sentCode#5e002502 flags:# phone_registered:flags.0?true type:auth.SentCodeType phone_code_hash:string next_type:flags.1?auth.CodeType timeout:flags.2?int = auth.SentCode'

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

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



class SentCodeTypeApp(TLObject):
    constructor_id = 0x3dbb5986
    subclass_of_id = 0xff5b158e

    def __init__(self, length):
        """
        :param length: Telegram type: "int".

        Constructor for auth.SentCodeType: Instance of either SentCodeTypeApp, SentCodeTypeSms, SentCodeTypeCall, SentCodeTypeFlashCall.
        """
        super().__init__()

        self.length = length

    def to_dict(self):
        return {
            'length': self.length,
        }

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

    @staticmethod
    def empty():
        return SentCodeTypeApp(None)

    def on_response(self, reader):
        self.length = reader.read_int()

    def __repr__(self):
        return 'auth.sentCodeTypeApp#3dbb5986 length:int = auth.SentCodeType'

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

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



class SentCodeTypeCall(TLObject):
    constructor_id = 0x5353e5a7
    subclass_of_id = 0xff5b158e

    def __init__(self, length):
        """
        :param length: Telegram type: "int".

        Constructor for auth.SentCodeType: Instance of either SentCodeTypeApp, SentCodeTypeSms, SentCodeTypeCall, SentCodeTypeFlashCall.
        """
        super().__init__()

        self.length = length

    def to_dict(self):
        return {
            'length': self.length,
        }

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

    @staticmethod
    def empty():
        return SentCodeTypeCall(None)

    def on_response(self, reader):
        self.length = reader.read_int()

    def __repr__(self):
        return 'auth.sentCodeTypeCall#5353e5a7 length:int = auth.SentCodeType'

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

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



class SentCodeTypeFlashCall(TLObject):
    constructor_id = 0xab03c6d9
    subclass_of_id = 0xff5b158e

    def __init__(self, pattern):
        """
        :param pattern: Telegram type: "string".

        Constructor for auth.SentCodeType: Instance of either SentCodeTypeApp, SentCodeTypeSms, SentCodeTypeCall, SentCodeTypeFlashCall.
        """
        super().__init__()

        self.pattern = pattern

    def to_dict(self):
        return {
            'pattern': self.pattern,
        }

    def on_send(self, writer):
        writer.write_int(SentCodeTypeFlashCall.constructor_id, signed=False)
        writer.tgwrite_string(self.pattern)

    @staticmethod
    def empty():
        return SentCodeTypeFlashCall(None)

    def on_response(self, reader):
        self.pattern = reader.tgread_string()

    def __repr__(self):
        return 'auth.sentCodeTypeFlashCall#ab03c6d9 pattern:string = auth.SentCodeType'

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

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



class SentCodeTypeSms(TLObject):
    constructor_id = 0xc000bba2
    subclass_of_id = 0xff5b158e

    def __init__(self, length):
        """
        :param length: Telegram type: "int".

        Constructor for auth.SentCodeType: Instance of either SentCodeTypeApp, SentCodeTypeSms, SentCodeTypeCall, SentCodeTypeFlashCall.
        """
        super().__init__()

        self.length = length

    def to_dict(self):
        return {
            'length': self.length,
        }

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

    @staticmethod
    def empty():
        return SentCodeTypeSms(None)

    def on_response(self, reader):
        self.length = reader.read_int()

    def __repr__(self):
        return 'auth.sentCodeTypeSms#c000bba2 length:int = auth.SentCodeType'

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

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

