from ....tl.mtproto_request import MTProtoRequest


class ConfirmCallRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    phone.confirmCall#2efe1722 peer:InputPhoneCall g_a:bytes key_fingerprint:long protocol:PhoneCallProtocol = phone.PhoneCall"""

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

    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.confirmed = True  # Confirmed by default

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

    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():
        """Returns an "empty" instance (all attributes are None)"""
        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 '(phone.confirmCall (ID: 0x2efe1722) = (peer={}, g_a={}, key_fingerprint={}, protocol={}))'.format(str(self.peer), str(self.g_a), str(self.key_fingerprint), str(self.protocol))
