from ....tl.mtproto_request import MTProtoRequest


class ReorderStickerSetsRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    messages.reorderStickerSets#78337739 flags:# masks:flags.0?true order:Vector<long> = Bool"""

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

    def __init__(self, order, masks=None):
        """
        :param masks: Telegram type: «true».
        :param order: Telegram type: «long». Must be a list.

        :returns Bool: This type has no constructors.
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.masks = masks
        self.order = order

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

        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.order))
        for order_item in self.order:
            writer.write_long(order_item)

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

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

    def __repr__(self):
        return 'messages.reorderStickerSets#78337739 flags:# masks:flags.0?true order:Vector<long> = Bool'

    def __str__(self):
        return '(messages.reorderStickerSets (ID: 0x78337739) = (masks={}, order={}))'.format(str(self.masks), None if not self.order else [str(_) for _ in self.order])
