from ....tl.mtproto_request import MTProtoRequest


class GetPeerDialogsRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    messages.getPeerDialogs#2d9776b9 peers:Vector<InputPeer> = messages.PeerDialogs"""

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

    def __init__(self, peers):
        """
        :param peers: Telegram type: «InputPeer». Must be a list.

        :returns messages.PeerDialogs: Instance of PeerDialogs.
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.peers = peers

    def on_send(self, writer):
        writer.write_int(GetPeerDialogsRequest.constructor_id, signed=False)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.peers))
        for peers_item in self.peers:
            peers_item.on_send(writer)

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

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

    def __repr__(self):
        return 'messages.getPeerDialogs#2d9776b9 peers:Vector<InputPeer> = messages.PeerDialogs'

    def __str__(self):
        return '(messages.getPeerDialogs (ID: 0x2d9776b9) = (peers={}))'.format(None if not self.peers else [str(_) for _ in self.peers])
