from ....tl.tlobject import TLObject


class SearchRequest(TLObject):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    contacts.search#11f812d8 q:string limit:int = contacts.Found"""

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

    def __init__(self, q, limit):
        """
        :param q: Telegram type: "string".
        :param limit: Telegram type: "int".

        :returns contacts.Found: Instance of Found.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.q = q
        self.limit = limit

    def to_dict(self):
        return {
            'q': self.q,
            'limit': self.limit,
        }

    def on_send(self, writer):
        writer.write_int(SearchRequest.constructor_id, signed=False)
        writer.tgwrite_string(self.q)
        writer.write_int(self.limit)

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

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

    def __repr__(self):
        return 'contacts.search#11f812d8 q:string limit:int = contacts.Found'

    def __str__(self):
        return TLObject.pretty_format(self)

    def stringify(self):
        return TLObject.pretty_format(self, indent=0)
