"""File generated by TLObjects' generator. All changes will be ERASED"""
from ...tl.tlobject import TLObject
from ...utils import get_input_peer, get_input_channel, get_input_user, get_input_media, get_input_photo
import os
import struct


class AcceptCallRequest(TLObject):
    CONSTRUCTOR_ID = 0x3bd2b4a0
    SUBCLASS_OF_ID = 0xd48afe4f

    def __init__(self, peer, g_b, protocol):
        """
        :param TLObject peer:
        :param bytes g_b:
        :param TLObject protocol:

        :returns phone.PhoneCall: Instance of PhoneCall.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.peer = peer
        self.g_b = g_b
        self.protocol = protocol

    def to_dict(self, recursive=True):
        return {
            'peer': (None if self.peer is None else self.peer.to_dict()) if recursive else self.peer,
            'g_b': self.g_b,
            'protocol': (None if self.protocol is None else self.protocol.to_dict()) if recursive else self.protocol,
        }

    def __bytes__(self):
        return b''.join((
            b'\xa0\xb4\xd2;',
            bytes(self.peer),
            TLObject.serialize_bytes(self.g_b),
            bytes(self.protocol),
        ))

    @staticmethod
    def from_reader(reader):
        _peer = reader.tgread_object()
        _g_b = reader.tgread_bytes()
        _protocol = reader.tgread_object()
        return AcceptCallRequest(peer=_peer, g_b=_g_b, protocol=_protocol)

    def on_response(self, reader):
        self.result = reader.tgread_object()

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

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


class ConfirmCallRequest(TLObject):
    CONSTRUCTOR_ID = 0x2efe1722
    SUBCLASS_OF_ID = 0xd48afe4f

    def __init__(self, peer, g_a, key_fingerprint, protocol):
        """
        :param TLObject peer:
        :param bytes g_a:
        :param int key_fingerprint:
        :param TLObject protocol:

        :returns phone.PhoneCall: Instance of PhoneCall.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.peer = peer
        self.g_a = g_a
        self.key_fingerprint = key_fingerprint
        self.protocol = protocol

    def to_dict(self, recursive=True):
        return {
            'peer': (None if self.peer is None else self.peer.to_dict()) if recursive else self.peer,
            'g_a': self.g_a,
            'key_fingerprint': self.key_fingerprint,
            'protocol': (None if self.protocol is None else self.protocol.to_dict()) if recursive else self.protocol,
        }

    def __bytes__(self):
        return b''.join((
            b'"\x17\xfe.',
            bytes(self.peer),
            TLObject.serialize_bytes(self.g_a),
            struct.pack('<q', self.key_fingerprint),
            bytes(self.protocol),
        ))

    @staticmethod
    def from_reader(reader):
        _peer = reader.tgread_object()
        _g_a = reader.tgread_bytes()
        _key_fingerprint = reader.read_long()
        _protocol = reader.tgread_object()
        return ConfirmCallRequest(peer=_peer, g_a=_g_a, key_fingerprint=_key_fingerprint, protocol=_protocol)

    def on_response(self, reader):
        self.result = reader.tgread_object()

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

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


class DiscardCallRequest(TLObject):
    CONSTRUCTOR_ID = 0x78d413a6
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer, duration, reason, connection_id):
        """
        :param TLObject peer:
        :param int duration:
        :param TLObject reason:
        :param int connection_id:

        :returns Updates: Instance of either UpdatesTooLong, UpdateShortMessage, UpdateShortChatMessage, UpdateShort, UpdatesCombined, Updates, UpdateShortSentMessage.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.peer = peer
        self.duration = duration
        self.reason = reason
        self.connection_id = connection_id

    def to_dict(self, recursive=True):
        return {
            'peer': (None if self.peer is None else self.peer.to_dict()) if recursive else self.peer,
            'duration': self.duration,
            'reason': (None if self.reason is None else self.reason.to_dict()) if recursive else self.reason,
            'connection_id': self.connection_id,
        }

    def __bytes__(self):
        return b''.join((
            b'\xa6\x13\xd4x',
            bytes(self.peer),
            struct.pack('<i', self.duration),
            bytes(self.reason),
            struct.pack('<q', self.connection_id),
        ))

    @staticmethod
    def from_reader(reader):
        _peer = reader.tgread_object()
        _duration = reader.read_int()
        _reason = reader.tgread_object()
        _connection_id = reader.read_long()
        return DiscardCallRequest(peer=_peer, duration=_duration, reason=_reason, connection_id=_connection_id)

    def on_response(self, reader):
        self.result = reader.tgread_object()

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

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


class GetCallConfigRequest(TLObject):
    CONSTRUCTOR_ID = 0x55451fa9
    SUBCLASS_OF_ID = 0xad0352e8

    def __init__(self):
        super().__init__()
        self.result = None
        self.content_related = True

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

    def __bytes__(self):
        return b''.join((
            b'\xa9\x1fEU',
        ))

    @staticmethod
    def from_reader(reader):
        return GetCallConfigRequest()

    def on_response(self, reader):
        self.result = reader.tgread_object()

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

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


class ReceivedCallRequest(TLObject):
    CONSTRUCTOR_ID = 0x17d54f61
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, peer):
        """
        :param TLObject peer:

        :returns Bool: This type has no constructors.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.peer = peer

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

    def __bytes__(self):
        return b''.join((
            b'aO\xd5\x17',
            bytes(self.peer),
        ))

    @staticmethod
    def from_reader(reader):
        _peer = reader.tgread_object()
        return ReceivedCallRequest(peer=_peer)

    def on_response(self, reader):
        self.result = reader.tgread_object()

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

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


class RequestCallRequest(TLObject):
    CONSTRUCTOR_ID = 0x5b95b3d4
    SUBCLASS_OF_ID = 0xd48afe4f

    def __init__(self, user_id, g_a_hash, protocol, random_id=None):
        """
        :param TLObject user_id:
        :param int random_id:
        :param bytes g_a_hash:
        :param TLObject protocol:

        :returns phone.PhoneCall: Instance of PhoneCall.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.user_id = get_input_user(user_id)
        self.random_id = random_id if random_id is not None else int.from_bytes(os.urandom(4), 'big', signed=True)
        self.g_a_hash = g_a_hash
        self.protocol = protocol

    def to_dict(self, recursive=True):
        return {
            'user_id': (None if self.user_id is None else self.user_id.to_dict()) if recursive else self.user_id,
            'random_id': self.random_id,
            'g_a_hash': self.g_a_hash,
            'protocol': (None if self.protocol is None else self.protocol.to_dict()) if recursive else self.protocol,
        }

    def __bytes__(self):
        return b''.join((
            b'\xd4\xb3\x95[',
            bytes(self.user_id),
            struct.pack('<i', self.random_id),
            TLObject.serialize_bytes(self.g_a_hash),
            bytes(self.protocol),
        ))

    @staticmethod
    def from_reader(reader):
        _user_id = reader.tgread_object()
        _random_id = reader.read_int()
        _g_a_hash = reader.tgread_bytes()
        _protocol = reader.tgread_object()
        return RequestCallRequest(user_id=_user_id, g_a_hash=_g_a_hash, protocol=_protocol, random_id=_random_id)

    def on_response(self, reader):
        self.result = reader.tgread_object()

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

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


class SaveCallDebugRequest(TLObject):
    CONSTRUCTOR_ID = 0x277add7e
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, peer, debug):
        """
        :param TLObject peer:
        :param TLObject debug:

        :returns Bool: This type has no constructors.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.peer = peer
        self.debug = debug

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

    def __bytes__(self):
        return b''.join((
            b"~\xddz'",
            bytes(self.peer),
            bytes(self.debug),
        ))

    @staticmethod
    def from_reader(reader):
        _peer = reader.tgread_object()
        _debug = reader.tgread_object()
        return SaveCallDebugRequest(peer=_peer, debug=_debug)

    def on_response(self, reader):
        self.result = reader.tgread_object()

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

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


class SetCallRatingRequest(TLObject):
    CONSTRUCTOR_ID = 0x1c536a34
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer, rating, comment):
        """
        :param TLObject peer:
        :param int rating:
        :param str comment:

        :returns Updates: Instance of either UpdatesTooLong, UpdateShortMessage, UpdateShortChatMessage, UpdateShort, UpdatesCombined, Updates, UpdateShortSentMessage.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.peer = peer
        self.rating = rating
        self.comment = comment

    def to_dict(self, recursive=True):
        return {
            'peer': (None if self.peer is None else self.peer.to_dict()) if recursive else self.peer,
            'rating': self.rating,
            'comment': self.comment,
        }

    def __bytes__(self):
        return b''.join((
            b'4jS\x1c',
            bytes(self.peer),
            struct.pack('<i', self.rating),
            TLObject.serialize_bytes(self.comment),
        ))

    @staticmethod
    def from_reader(reader):
        _peer = reader.tgread_object()
        _rating = reader.read_int()
        _comment = reader.tgread_string()
        return SetCallRatingRequest(peer=_peer, rating=_rating, comment=_comment)

    def on_response(self, reader):
        self.result = reader.tgread_object()

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

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