from ....tl.mtproto_request import MTProtoRequest


class GetCommonChatsRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    messages.getCommonChats#0d0a48c4 user_id:InputUser max_id:int limit:int = messages.Chats"""

    # Telegram's constructor (U)ID for this class
    constructor_id = 0xd0a48c4
    # Also the ID of its resulting type for fast checks
    subclass_of_id = 0x99d5cb14

    def __init__(self, user_id, max_id, limit):
        """
        :param user_id: Telegram type: "InputUser".
        :param max_id: Telegram type: "int".
        :param limit: Telegram type: "int".

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

        self.user_id = user_id
        self.max_id = max_id
        self.limit = limit

    def to_dict(self):
        return {
            'user_id': None if self.user_id is None else self.user_id.to_dict(),
            'max_id': self.max_id,
            'limit': self.limit,
        }

    def on_send(self, writer):
        writer.write_int(GetCommonChatsRequest.constructor_id, signed=False)
        self.user_id.on_send(writer)
        writer.write_int(self.max_id)
        writer.write_int(self.limit)

    @staticmethod
    def empty():
        """Returns an "empty" instance (attributes=None)"""
        return GetCommonChatsRequest(None, None, None)

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

    def __repr__(self):
        return 'messages.getCommonChats#0d0a48c4 user_id:InputUser max_id:int limit:int = messages.Chats'

    def __str__(self):
        return '(messages.getCommonChats (ID: 0xd0a48c4) = (user_id={}, max_id={}, limit={}))'.format(str(self.user_id), str(self.max_id), str(self.limit))
