File indexing completed on 2024-06-02 05:07:20
0001 /* 0002 SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "librestapi_private_export.h" 0010 #include "restapiabstractjob.h" 0011 0012 namespace RocketChatRestApi 0013 { 0014 class LIBROCKETCHATRESTAPI_QT_EXPORT RegisterUserJob : public RestApiAbstractJob 0015 { 0016 Q_OBJECT 0017 public: 0018 struct LIBROCKETCHATRESTAPI_QT_EXPORT RegisterUserInfo { 0019 QString username; 0020 QString name; 0021 QString email; 0022 QString password; 0023 [[nodiscard]] bool isValid() const; 0024 }; 0025 0026 explicit RegisterUserJob(QObject *parent = nullptr); 0027 ~RegisterUserJob() override; 0028 0029 [[nodiscard]] bool start() override; 0030 [[nodiscard]] bool requireHttpAuthentication() const override; 0031 0032 [[nodiscard]] QNetworkRequest request() const override; 0033 0034 [[nodiscard]] bool canStart() const override; 0035 0036 [[nodiscard]] QJsonDocument json() const; 0037 0038 [[nodiscard]] RegisterUserInfo registerUserInfo() const; 0039 void setRegisterUserInfo(const RegisterUserInfo ®isterUserInfo); 0040 0041 protected: 0042 [[nodiscard]] QString errorMessage(const QString &str, const QJsonObject &detail) override; 0043 0044 Q_SIGNALS: 0045 void registerUserDone(); 0046 0047 private: 0048 Q_DISABLE_COPY(RegisterUserJob) 0049 LIBROCKETCHATRESTAPI_QT_NO_EXPORT void onPostRequestResponse(const QString &replyErrorString, const QJsonDocument &replyJson) override; 0050 RegisterUserInfo mRegisterUserInfo; 0051 }; 0052 } 0053 Q_DECLARE_TYPEINFO(RocketChatRestApi::RegisterUserJob::RegisterUserInfo, Q_RELOCATABLE_TYPE);