from ...tl.mtproto_request import MTProtoRequest


class InvokeAfterMsgsRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    invokeAfterMsgs#3dc4b4f0 {X:Type} msg_ids:Vector<long> query:!X = X"""

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

    def __init__(self, msg_ids, query):
        """
        :param msg_ids: Telegram type: «long». Must be a list.
        :param query: Telegram type: «X». This should be another MTProtoRequest.

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

        self.msg_ids = msg_ids
        self.query = query

    def on_send(self, writer):
        writer.write_int(InvokeAfterMsgsRequest.constructor_id, signed=False)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.msg_ids))
        for msg_ids_item in self.msg_ids:
            writer.write_long(msg_ids_item)

        self.query.on_send(writer)

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

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

    def __repr__(self):
        return 'invokeAfterMsgs#3dc4b4f0 {X:Type} msg_ids:Vector<long> query:!X = X'

    def __str__(self):
        return '(invokeAfterMsgs (ID: 0x3dc4b4f0) = (msg_ids={}, query={}))'.format(None if not self.msg_ids else [str(_) for _ in self.msg_ids], str(self.query))
