from ....tl.mtproto_request import MTProtoRequest


class GetTmpPasswordRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    account.getTmpPassword#4a82327e password_hash:bytes period:int = account.TmpPassword"""

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

    def __init__(self, password_hash, period):
        """
        :param password_hash: Telegram type: «bytes».
        :param period: Telegram type: «int».

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

        self.password_hash = password_hash
        self.period = period

    def on_send(self, writer):
        writer.write_int(GetTmpPasswordRequest.constructor_id, signed=False)
        writer.tgwrite_bytes(self.password_hash)
        writer.write_int(self.period)

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

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

    def __repr__(self):
        return 'account.getTmpPassword#4a82327e password_hash:bytes period:int = account.TmpPassword'

    def __str__(self):
        return '(account.getTmpPassword (ID: 0x4a82327e) = (password_hash={}, period={}))'.format(str(self.password_hash), str(self.period))
