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


class AcceptCallRequest(TLObject):
    constructor_id = 0x3bd2b4a0
    subclass_of_id = 0xd48afe4f

    def __init__(self, peer, g_b, protocol):
        """
        :param peer: Telegram type: "InputPhoneCall".
        :param g_b: Telegram type: "bytes".
        :param protocol: Telegram type: "PhoneCallProtocol".

        :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):
        return {
            'peer': None if self.peer is None else self.peer.to_dict(),
            'g_b': self.g_b,
            'protocol': None if self.protocol is None else self.protocol.to_dict(),
        }

    def on_send(self, writer):
        writer.write_int(AcceptCallRequest.constructor_id, signed=False)
        self.peer.on_send(writer)
        writer.tgwrite_bytes(self.g_b)
        self.protocol.on_send(writer)

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

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

    def __repr__(self):
        return 'phone.acceptCall#3bd2b4a0 peer:InputPhoneCall g_b:bytes protocol:PhoneCallProtocol = phone.PhoneCall'

    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 peer: Telegram type: "InputPhoneCall".
        :param g_a: Telegram type: "bytes".
        :param key_fingerprint: Telegram type: "long".
        :param protocol: Telegram type: "PhoneCallProtocol".

        :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):
        return {
            'peer': None if self.peer is None else self.peer.to_dict(),
            'g_a': self.g_a,
            'key_fingerprint': self.key_fingerprint,
            'protocol': None if self.protocol is None else self.protocol.to_dict(),
        }

    def on_send(self, writer):
        writer.write_int(ConfirmCallRequest.constructor_id, signed=False)
        self.peer.on_send(writer)
        writer.tgwrite_bytes(self.g_a)
        writer.write_long(self.key_fingerprint)
        self.protocol.on_send(writer)

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

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

    def __repr__(self):
        return 'phone.confirmCall#2efe1722 peer:InputPhoneCall g_a:bytes key_fingerprint:long protocol:PhoneCallProtocol = phone.PhoneCall'

    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 peer: Telegram type: "InputPhoneCall".
        :param duration: Telegram type: "int".
        :param reason: Telegram type: "PhoneCallDiscardReason".
        :param connection_id: Telegram type: "long".

        :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):
        return {
            'peer': None if self.peer is None else self.peer.to_dict(),
            'duration': self.duration,
            'reason': None if self.reason is None else self.reason.to_dict(),
            'connection_id': self.connection_id,
        }

    def on_send(self, writer):
        writer.write_int(DiscardCallRequest.constructor_id, signed=False)
        self.peer.on_send(writer)
        writer.write_int(self.duration)
        self.reason.on_send(writer)
        writer.write_long(self.connection_id)

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

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

    def __repr__(self):
        return 'phone.discardCall#78d413a6 peer:InputPhoneCall duration:int reason:PhoneCallDiscardReason connection_id:long = Updates'

    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

    @staticmethod
    def to_dict():
        return {}

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

    @staticmethod
    def empty():
        return GetCallConfigRequest()

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

    def __repr__(self):
        return 'phone.getCallConfig#55451fa9 = DataJSON'

    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 peer: Telegram type: "InputPhoneCall".

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

        self.peer = peer

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

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

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

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

    def __repr__(self):
        return 'phone.receivedCall#17d54f61 peer:InputPhoneCall = Bool'

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

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

from ...utils import get_input_user
import os


class RequestCallRequest(TLObject):
    constructor_id = 0x5b95b3d4
    subclass_of_id = 0xd48afe4f

    def __init__(self, user_id, g_a_hash, protocol, random_id=None):
        """
        :param user_id: Telegram type: "InputUser".
        :param random_id: Telegram type: "int".
        :param g_a_hash: Telegram type: "bytes".
        :param protocol: Telegram type: "PhoneCallProtocol".

        :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), signed=True, byteorder='little')
        self.g_a_hash = g_a_hash
        self.protocol = protocol

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

    def on_send(self, writer):
        writer.write_int(RequestCallRequest.constructor_id, signed=False)
        self.user_id.on_send(writer)
        writer.write_int(self.random_id)
        writer.tgwrite_bytes(self.g_a_hash)
        self.protocol.on_send(writer)

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

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

    def __repr__(self):
        return 'phone.requestCall#5b95b3d4 user_id:InputUser random_id:int g_a_hash:bytes protocol:PhoneCallProtocol = phone.PhoneCall'

    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 peer: Telegram type: "InputPhoneCall".
        :param debug: Telegram type: "DataJSON".

        :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):
        return {
            'peer': None if self.peer is None else self.peer.to_dict(),
            'debug': None if self.debug is None else self.debug.to_dict(),
        }

    def on_send(self, writer):
        writer.write_int(SaveCallDebugRequest.constructor_id, signed=False)
        self.peer.on_send(writer)
        self.debug.on_send(writer)

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

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

    def __repr__(self):
        return 'phone.saveCallDebug#277add7e peer:InputPhoneCall debug:DataJSON = Bool'

    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 peer: Telegram type: "InputPhoneCall".
        :param rating: Telegram type: "int".
        :param comment: Telegram type: "string".

        :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):
        return {
            'peer': None if self.peer is None else self.peer.to_dict(),
            'rating': self.rating,
            'comment': self.comment,
        }

    def on_send(self, writer):
        writer.write_int(SetCallRatingRequest.constructor_id, signed=False)
        self.peer.on_send(writer)
        writer.write_int(self.rating)
        writer.tgwrite_string(self.comment)

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

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

    def __repr__(self):
        return 'phone.setCallRating#1c536a34 peer:InputPhoneCall rating:int comment:string = Updates'

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

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

