aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/whoami.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/csapi/whoami.cpp')
-rw-r--r--lib/csapi/whoami.cpp41
1 files changed, 6 insertions, 35 deletions
diff --git a/lib/csapi/whoami.cpp b/lib/csapi/whoami.cpp
index aebdf5d3..73f0298e 100644
--- a/lib/csapi/whoami.cpp
+++ b/lib/csapi/whoami.cpp
@@ -4,49 +4,20 @@
#include "whoami.h"
-#include "converters.h"
-
#include <QtCore/QStringBuilder>
-using namespace QMatrixClient;
-
-static const auto basePath = QStringLiteral("/_matrix/client/r0");
-
-class GetTokenOwnerJob::Private
-{
- public:
- QString userId;
-};
+using namespace Quotient;
QUrl GetTokenOwnerJob::makeRequestUrl(QUrl baseUrl)
{
return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/account/whoami");
+ QStringLiteral("/_matrix/client/r0")
+ % "/account/whoami");
}
-static const auto GetTokenOwnerJobName = QStringLiteral("GetTokenOwnerJob");
-
GetTokenOwnerJob::GetTokenOwnerJob()
- : BaseJob(HttpVerb::Get, GetTokenOwnerJobName,
- basePath % "/account/whoami")
- , d(new Private)
+ : BaseJob(HttpVerb::Get, QStringLiteral("GetTokenOwnerJob"),
+ QStringLiteral("/_matrix/client/r0") % "/account/whoami")
{
+ addExpectedKey("user_id");
}
-
-GetTokenOwnerJob::~GetTokenOwnerJob() = default;
-
-const QString& GetTokenOwnerJob::userId() const
-{
- return d->userId;
-}
-
-BaseJob::Status GetTokenOwnerJob::parseJson(const QJsonDocument& data)
-{
- auto json = data.object();
- if (!json.contains("user_id"_ls))
- return { JsonParseError,
- "The key 'user_id' not found in the response" };
- fromJson(json.value("user_id"_ls), d->userId);
- return Success;
-}
-