from ....tl.mtproto_request import MTProtoRequest


class CheckChatInviteRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    messages.checkChatInvite#3eadb1bb hash:string = ChatInvite"""

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

    def __init__(self, hash):
        """
        :param hash: Telegram type: "string".

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

        self.hash = hash

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

    def on_send(self, writer):
        writer.write_int(CheckChatInviteRequest.constructor_id, signed=False)
        writer.tgwrite_string(self.hash)

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

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

    def __repr__(self):
        return 'messages.checkChatInvite#3eadb1bb hash:string = ChatInvite'

    def __str__(self):
        return '(messages.checkChatInvite (ID: 0x3eadb1bb) = (hash={}))'.format(str(self.hash))
