aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/whoami.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-05-05 19:36:15 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-05-05 19:36:15 +0900
commita8d2a73c771f188fc0fdc6351b4923af788317d5 (patch)
treeb2795b93149f7c0ae3cd5005331b650a8eb6fd1e /lib/csapi/whoami.cpp
parentda16225dfbec9b155c2c299757203f7676ac6ccf (diff)
parenta63838235134b066c092ad98e1f18ff7991c91c1 (diff)
downloadlibquotient-a8d2a73c771f188fc0fdc6351b4923af788317d5.tar.gz
libquotient-a8d2a73c771f188fc0fdc6351b4923af788317d5.zip
Merge branch 'kitsune-gtad'
Diffstat (limited to 'lib/csapi/whoami.cpp')
-rw-r--r--lib/csapi/whoami.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/csapi/whoami.cpp b/lib/csapi/whoami.cpp
new file mode 100644
index 00000000..4c231b5f
--- /dev/null
+++ b/lib/csapi/whoami.cpp
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#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;
+};
+
+QUrl GetTokenOwnerJob::makeRequestUrl(QUrl baseUrl)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/account/whoami");
+}
+
+GetTokenOwnerJob::GetTokenOwnerJob()
+ : BaseJob(HttpVerb::Get, "GetTokenOwnerJob",
+ basePath % "/account/whoami")
+ , d(new Private)
+{
+}
+
+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"))
+ return { JsonParseError,
+ "The key 'user_id' not found in the response" };
+ d->userId = fromJson<QString>(json.value("user_id"));
+ return Success;
+}
+