from ....tl.mtproto_request import MTProtoRequest


class DiscardCallRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    phone.discardCall#78d413a6 peer:InputPhoneCall duration:int reason:PhoneCallDiscardReason connection_id:long = Updates"""

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

    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, UpdatesTg, UpdateShortSentMessage.
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.peer = peer
        self.duration = duration
        self.reason = reason
        self.connection_id = 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():
        """Returns an "empty" instance (all attributes are None)"""
        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 '(phone.discardCall (ID: 0x78d413a6) = (peer={}, duration={}, reason={}, connection_id={}))'.format(str(self.peer), str(self.duration), str(self.reason), str(self.connection_id))
