from ...tl.mtproto_request import MTProtoRequest


class UpdateShort(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    updateShort#78d4dec1 update:Update date:date = Updates"""

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

    def __init__(self, update, date):
        """
        :param update: Telegram type: «Update».
        :param date: Telegram type: «date».

        Constructor for Updates: Instance of either UpdatesTooLong, UpdateShortMessage, UpdateShortChatMessage, UpdateShort, UpdatesCombined, UpdatesTg, UpdateShortSentMessage.
        """
        super().__init__()

        self.update = update
        self.date = date

    def on_send(self, writer):
        writer.write_int(UpdateShort.constructor_id, signed=False)
        self.update.on_send(writer)
        writer.tgwrite_date(self.date)

    @staticmethod
    def empty():
        """Returns an "empty" instance (all attributes are None)"""
        return UpdateShort(None, None)

    def on_response(self, reader):
        self.update = reader.tgread_object()
        self.date = reader.tgread_date()

    def __repr__(self):
        return 'updateShort#78d4dec1 update:Update date:date = Updates'

    def __str__(self):
        return '(updateShort (ID: 0x78d4dec1) = (update={}, date={}))'.format(str(self.update), str(self.date))
