from ....tl.tlobject import TLObject


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

    # Telegram's constructor (U)ID for this class
    constructor_id = 0x78d413a6
    # Also the ID of its resulting type for fast checks
    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, UpdatesTg, 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():
        """Returns an "empty" instance (attributes=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 TLObject.pretty_format(self)

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