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


class Authorization(TLObject):
    CONSTRUCTOR_ID = 0xcd050916
    SUBCLASS_OF_ID = 0xb9e04e39

    def __init__(self, user, tmp_sessions=None):
        """
        :param int | None tmp_sessions:
        :param TLObject user:

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

        self.tmp_sessions = tmp_sessions
        self.user = user

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

    def to_bytes(self):
        return b''.join((
            b'\x16\t\x05\xcd',
            struct.pack('<I', (1 if self.tmp_sessions else 0)),
            b'' if not self.tmp_sessions else (struct.pack('<i', self.tmp_sessions)),
            self.user.to_bytes(),
        ))

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

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

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

        self.user = reader.tgread_object()

    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 TLObject phone_registered:

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

        self.phone_registered = phone_registered

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

    def to_bytes(self):
        return b''.join((
            b'\x8e\xa2\x1e\x81',
            b'\xb5ur\x99' if self.phone_registered else b'7\x97y\xbc',
        ))

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

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

    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__()

    def to_dict(self, recursive=True):
        return {}

    def to_bytes(self):
        return b''.join((
            b'\xe3\xd3\x1ct',
        ))

    @staticmethod
    def empty():
        return CodeTypeCall()

    def on_response(self, reader):
        pass

    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__()

    def to_dict(self, recursive=True):
        return {}

    def to_bytes(self):
        return b''.join((
            b'\xfb\xcel"',
        ))

    @staticmethod
    def empty():
        return CodeTypeFlashCall()

    def on_response(self, reader):
        pass

    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__()

    def to_dict(self, recursive=True):
        return {}

    def to_bytes(self):
        return b''.join((
            b'\x8c\x15\xa3r',
        ))

    @staticmethod
    def empty():
        return CodeTypeSms()

    def on_response(self, reader):
        pass

    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 int id:
        :param bytes bytes:

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

        self.id = id
        self.bytes = bytes

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

    def to_bytes(self):
        return b''.join((
            b'-\x9c\x96\xdf',
            struct.pack('<i', self.id),
            TLObject.serialize_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 __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 str email_pattern:

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

        self.email_pattern = email_pattern

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

    def to_bytes(self):
        return b''.join((
            b'\xa5Hy\x13',
            TLObject.serialize_bytes(self.email_pattern),
        ))

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

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

    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 bool | None phone_registered:
        :param TLObject type:
        :param str phone_code_hash:
        :param TLObject | None next_type:
        :param int | None timeout:

        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, recursive=True):
        return {
            'phone_registered': self.phone_registered,
            'type': (None if self.type is None else self.type.to_dict()) if recursive else self.type,
            'phone_code_hash': self.phone_code_hash,
            'next_type': (None if self.next_type is None else self.next_type.to_dict()) if recursive else self.next_type,
            'timeout': self.timeout,
        }

    def to_bytes(self):
        return b''.join((
            b'\x02%\x00^',
            struct.pack('<I', (1 if self.phone_registered else 0) | (2 if self.next_type else 0) | (4 if self.timeout else 0)),
            self.type.to_bytes(),
            TLObject.serialize_bytes(self.phone_code_hash),
            b'' if not self.next_type else (self.next_type.to_bytes()),
            b'' if not self.timeout else (struct.pack('<i', self.timeout)),
        ))

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

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

        if flags & 1:
            self.phone_registered = True

        self.type = reader.tgread_object()
        self.phone_code_hash = reader.tgread_string()
        if flags & 2:
            self.next_type = reader.tgread_object()

        if flags & 4:
            self.timeout = reader.read_int()

    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 int length:

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

        self.length = length

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

    def to_bytes(self):
        return b''.join((
            b'\x86Y\xbb=',
            struct.pack('<i', self.length),
        ))

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

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

    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 int length:

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

        self.length = length

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

    def to_bytes(self):
        return b''.join((
            b'\xa7\xe5SS',
            struct.pack('<i', self.length),
        ))

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

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

    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 str pattern:

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

        self.pattern = pattern

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

    def to_bytes(self):
        return b''.join((
            b'\xd9\xc6\x03\xab',
            TLObject.serialize_bytes(self.pattern),
        ))

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

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

    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 int length:

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

        self.length = length

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

    def to_bytes(self):
        return b''.join((
            b'\xa2\xbb\x00\xc0',
            struct.pack('<i', self.length),
        ))

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

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

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

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