from ....tl.mtproto_request import MTProtoRequest


class RequestCallRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    phone.requestCall#5b95b3d4 user_id:InputUser random_id:int g_a_hash:bytes protocol:PhoneCallProtocol = phone.PhoneCall"""

    # Telegram's constructor ID (and unique identifier) for this class
    constructor_id = 0x5b95b3d4

    def __init__(self, user_id, random_id, g_a_hash, protocol):
        """
        :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.confirmed = True  # Confirmed by default

        self.user_id = user_id
        self.random_id = random_id
        self.g_a_hash = g_a_hash
        self.protocol = protocol

    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():
        """Returns an "empty" instance (all attributes are None)"""
        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 '(phone.requestCall (ID: 0x5b95b3d4) = (user_id={}, random_id={}, g_a_hash={}, protocol={}))'.format(str(self.user_id), str(self.random_id), str(self.g_a_hash), str(self.protocol))
