from telethon.tl.mtproto_request import MTProtoRequest


class SaveRecentStickerRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    messages.saveRecentSticker#392718f8 flags:None attached:flags.0?true id:InputDocument unsave:Bool = Bool"""

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

    def __init__(self, id, unsave, attached=None):
        """
        :param attached: Telegram type: «true».
        :param id: Telegram type: «InputDocument».
        :param unsave: Telegram type: «Bool».
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.attached = attached
        self.id = id
        self.unsave = unsave

    def on_send(self, writer):
        writer.write_int(SaveRecentStickerRequest.constructor_id, signed=False)
        # Calculate the flags. This equals to those flag arguments which are NOT None
        flags = 0
        flags |= (1 << 0) if self.attached else 0
        writer.write_int(flags)

        self.id.on_send(writer)
        writer.tgwrite_bool(self.unsave)

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

    def on_response(self, reader):
        self.result = reader.tgread_object()

    def __repr__(self):
        return 'messages.saveRecentSticker#392718f8 flags:None attached:flags.0?true id:InputDocument unsave:Bool = Bool'

    def __str__(self):
        return '(messages.saveRecentSticker (ID: 0x392718f8) = (attached={}, id={}, unsave={}))'.format(str(self.attached), str(self.id), str(self.unsave))
