5 #include <Quotient/csapi/definitions/auth_data.h>
6 #include <Quotient/csapi/definitions/request_email_validation.h>
7 #include <Quotient/csapi/definitions/request_msisdn_validation.h>
8 #include <Quotient/csapi/definitions/request_token_response.h>
10 #include <Quotient/jobs/basejob.h>
93 explicit RegisterJob(
const QString& kind = u"user"_s,
94 const std::optional<AuthenticationData>& auth = std::nullopt,
95 const QString& username = {},
const QString& password = {},
96 const QString& deviceId = {},
const QString& initialDeviceDisplayName = {},
97 std::optional<
bool> inhibitLogin = std::nullopt,
98 std::optional<
bool> refreshToken = std::nullopt);
106 QString userId()
const {
return loadFromJson<QString>(
"user_id"_L1); }
111 QString accessToken()
const {
return loadFromJson<QString>(
"access_token"_L1); }
118 QString refreshToken()
const {
return loadFromJson<QString>(
"refresh_token"_L1); }
128 std::optional<
int> expiresInMs()
const
130 return loadFromJson<std::optional<
int>>(
"expires_in_ms"_L1);
136 QString deviceId()
const {
return loadFromJson<QString>(
"device_id"_L1); }
148 QString accessToken{};
155 QString refreshToken{};
165 std::optional<
int> expiresInMs{};
174 template <std::derived_from<RegisterJob> JobT>
175 constexpr inline auto doCollectResponse<JobT> = [](JobT* j) -> RegisterJob::Response {
176 return { j->userId(), j->accessToken(), j->refreshToken(), j->expiresInMs(), j->deviceId() };
187 explicit RequestTokenToRegisterEmailJob(
const EmailValidationData& data);
194 RequestTokenResponse response()
const {
return fromJson<RequestTokenResponse>(jsonData()); }
197 inline auto collectResponse(
const RequestTokenToRegisterEmailJob* job) {
return job->response(); }
208 explicit RequestTokenToRegisterMSISDNJob(
const MsisdnValidationData& data);
215 RequestTokenResponse response()
const {
return fromJson<RequestTokenResponse>(jsonData()); }
218 inline auto collectResponse(
const RequestTokenToRegisterMSISDNJob* job) {
return job->response(); }
249 explicit ChangePasswordJob(
const QString& newPassword,
bool logoutDevices =
true,
250 const std::optional<AuthenticationData>& auth = std::nullopt);
271 class QUOTIENT_API RequestTokenToResetPasswordEmailJob :
public BaseJob {
273 explicit RequestTokenToResetPasswordEmailJob(
const EmailValidationData& data);
278 RequestTokenResponse response()
const {
return fromJson<RequestTokenResponse>(jsonData()); }
281 inline auto collectResponse(
const RequestTokenToResetPasswordEmailJob* job)
283 return job->response();
304 class QUOTIENT_API RequestTokenToResetPasswordMSISDNJob :
public BaseJob {
306 explicit RequestTokenToResetPasswordMSISDNJob(
const MsisdnValidationData& data);
311 RequestTokenResponse response()
const {
return fromJson<RequestTokenResponse>(jsonData()); }
314 inline auto collectResponse(
const RequestTokenToResetPasswordMSISDNJob* job)
316 return job->response();
367 explicit DeactivateAccountJob(
const std::optional<AuthenticationData>& auth = std::nullopt,
368 const QString& idServer = {},
369 std::optional<
bool> erase = std::nullopt);
381 QString idServerUnbindResult()
const
383 return loadFromJson<QString>(
"id_server_unbind_result"_L1);
387 inline auto collectResponse(
const DeactivateAccountJob* job) {
return job->idServerUnbindResult(); }
407 explicit CheckUsernameAvailabilityJob(
const QString& username);
413 static QUrl makeRequestUrl(
const HomeserverData& hsData,
const QString& username);
419 std::optional<
bool> available()
const
421 return loadFromJson<std::optional<
bool>>(
"available"_L1);
425 inline auto collectResponse(
const CheckUsernameAvailabilityJob* job) {
return job->available(); }