5 #include <Quotient/csapi/definitions/user_identifier.h>
6 #include <Quotient/csapi/definitions/wellknown/full.h>
8 #include <Quotient/jobs/basejob.h>
31 bool getLoginToken{
false };
36 explicit GetLoginFlowsJob();
42 static QUrl makeRequestUrl(
const HomeserverData& hsData);
47 QVector<LoginFlow> flows()
const {
return loadFromJson<QVector<LoginFlow>>(
"flows"_L1); }
50 inline auto collectResponse(
const GetLoginFlowsJob* job) {
return job->flows(); }
53 struct QUOTIENT_API JsonObjectConverter<GetLoginFlowsJob::LoginFlow> {
54 static void fillFrom(
const QJsonObject& jo, GetLoginFlowsJob::LoginFlow& result)
56 fillFromJson(jo.value(
"type"_L1), result.type);
57 fillFromJson(jo.value(
"get_login_token"_L1), result.getLoginToken);
105 explicit LoginJob(
const QString& type,
106 const std::optional<UserIdentifier>& identifier = std::nullopt,
107 const QString& password = {},
const QString& token = {},
108 const QString& deviceId = {},
const QString& initialDeviceDisplayName = {},
109 std::optional<
bool> refreshToken = std::nullopt);
114 QString userId()
const {
return loadFromJson<QString>(
"user_id"_L1); }
118 QString accessToken()
const {
return loadFromJson<QString>(
"access_token"_L1); }
123 QString refreshToken()
const {
return loadFromJson<QString>(
"refresh_token"_L1); }
131 std::optional<
int> expiresInMs()
const
133 return loadFromJson<std::optional<
int>>(
"expires_in_ms"_L1);
138 QString deviceId()
const {
return loadFromJson<QString>(
"device_id"_L1); }
144 std::optional<DiscoveryInformation> wellKnown()
const
146 return loadFromJson<std::optional<DiscoveryInformation>>(
"well_known"_L1);
155 QString accessToken{};
160 QString refreshToken{};
168 std::optional<
int> expiresInMs{};
178 std::optional<DiscoveryInformation> wellKnown{};
182 template <std::derived_from<LoginJob> JobT>
183 constexpr inline auto doCollectResponse<JobT> = [](JobT* j) -> LoginJob::Response {
184 return { j->userId(), j->accessToken(), j->refreshToken(),
185 j->expiresInMs(), j->deviceId(), j->wellKnown() };