File indexing completed on 2024-12-22 04:45:23

0001 /*
0002    SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "librocketchatrestapi-qt_export.h"
0010 #include "restapiabstractjob.h"
0011 namespace RocketChatRestApi
0012 {
0013 class LIBROCKETCHATRESTAPI_QT_EXPORT GeneratePersonalAccessTokenJob : public RestApiAbstractJob
0014 {
0015     Q_OBJECT
0016 public:
0017     explicit GeneratePersonalAccessTokenJob(QObject *parent = nullptr);
0018     ~GeneratePersonalAccessTokenJob() override;
0019 
0020     [[nodiscard]] bool start() override;
0021     [[nodiscard]] bool requireHttpAuthentication() const override;
0022     [[nodiscard]] bool canStart() const override;
0023     [[nodiscard]] QNetworkRequest request() const override;
0024     [[nodiscard]] bool requireTwoFactorAuthentication() const override;
0025 
0026     [[nodiscard]] QJsonDocument json() const;
0027 
0028     [[nodiscard]] const QString &tokenName() const;
0029     void setTokenName(const QString &newTokenName);
0030 
0031     [[nodiscard]] bool bypassTwoFactor() const;
0032     void setBypassTwoFactor(bool newBypassTwoFactor);
0033 
0034 Q_SIGNALS:
0035     void generateTokenDone(const QJsonObject &obj);
0036 
0037 private:
0038     Q_DISABLE_COPY(GeneratePersonalAccessTokenJob)
0039     LIBROCKETCHATRESTAPI_QT_NO_EXPORT void onPostRequestResponse(const QString &replyErrorString, const QJsonDocument &replyJson) override;
0040     QString mTokenName;
0041     bool mBypassTwoFactor = false;
0042 };
0043 }