from ....tl.mtproto_request import MTProtoRequest


class ReorderPinnedDialogsRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    messages.reorderPinnedDialogs#959ff644 flags:# force:flags.0?true order:Vector<InputPeer> = Bool"""

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

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

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

        self.force = force
        self.order = order

    def on_send(self, writer):
        writer.write_int(ReorderPinnedDialogsRequest.constructor_id, signed=False)
        # Calculate the flags. This equals to those flag arguments which are NOT None
        flags = 0
        flags |= (1 << 0) if self.force 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:
            order_item.on_send(writer)

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

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

    def __repr__(self):
        return 'messages.reorderPinnedDialogs#959ff644 flags:# force:flags.0?true order:Vector<InputPeer> = Bool'

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