aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/profile.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/profile.cpp
parentda16225dfbec9b155c2c299757203f7676ac6ccf (diff)
parenta63838235134b066c092ad98e1f18ff7991c91c1 (diff)
downloadlibquotient-a8d2a73c771f188fc0fdc6351b4923af788317d5.tar.gz
libquotient-a8d2a73c771f188fc0fdc6351b4923af788317d5.zip
Merge branch 'kitsune-gtad'
Diffstat (limited to 'lib/csapi/profile.cpp')
-rw-r--r--lib/csapi/profile.cpp140
1 files changed, 140 insertions, 0 deletions
diff --git a/lib/csapi/profile.cpp b/lib/csapi/profile.cpp
new file mode 100644
index 00000000..d8ddbc14
--- /dev/null
+++ b/lib/csapi/profile.cpp
@@ -0,0 +1,140 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "profile.h"
+
+#include "converters.h"
+
+#include <QtCore/QStringBuilder>
+
+using namespace QMatrixClient;
+
+static const auto basePath = QStringLiteral("/_matrix/client/r0");
+
+SetDisplayNameJob::SetDisplayNameJob(const QString& userId, const QString& displayname)
+ : BaseJob(HttpVerb::Put, "SetDisplayNameJob",
+ basePath % "/profile/" % userId % "/displayname")
+{
+ QJsonObject _data;
+ if (!displayname.isEmpty())
+ _data.insert("displayname", toJson(displayname));
+ setRequestData(_data);
+}
+
+class GetDisplayNameJob::Private
+{
+ public:
+ QString displayname;
+};
+
+QUrl GetDisplayNameJob::makeRequestUrl(QUrl baseUrl, const QString& userId)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/profile/" % userId % "/displayname");
+}
+
+GetDisplayNameJob::GetDisplayNameJob(const QString& userId)
+ : BaseJob(HttpVerb::Get, "GetDisplayNameJob",
+ basePath % "/profile/" % userId % "/displayname", false)
+ , d(new Private)
+{
+}
+
+GetDisplayNameJob::~GetDisplayNameJob() = default;
+
+const QString& GetDisplayNameJob::displayname() const
+{
+ return d->displayname;
+}
+
+BaseJob::Status GetDisplayNameJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ d->displayname = fromJson<QString>(json.value("displayname"));
+ return Success;
+}
+
+SetAvatarUrlJob::SetAvatarUrlJob(const QString& userId, const QString& avatarUrl)
+ : BaseJob(HttpVerb::Put, "SetAvatarUrlJob",
+ basePath % "/profile/" % userId % "/avatar_url")
+{
+ QJsonObject _data;
+ if (!avatarUrl.isEmpty())
+ _data.insert("avatar_url", toJson(avatarUrl));
+ setRequestData(_data);
+}
+
+class GetAvatarUrlJob::Private
+{
+ public:
+ QString avatarUrl;
+};
+
+QUrl GetAvatarUrlJob::makeRequestUrl(QUrl baseUrl, const QString& userId)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/profile/" % userId % "/avatar_url");
+}
+
+GetAvatarUrlJob::GetAvatarUrlJob(const QString& userId)
+ : BaseJob(HttpVerb::Get, "GetAvatarUrlJob",
+ basePath % "/profile/" % userId % "/avatar_url", false)
+ , d(new Private)
+{
+}
+
+GetAvatarUrlJob::~GetAvatarUrlJob() = default;
+
+const QString& GetAvatarUrlJob::avatarUrl() const
+{
+ return d->avatarUrl;
+}
+
+BaseJob::Status GetAvatarUrlJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ d->avatarUrl = fromJson<QString>(json.value("avatar_url"));
+ return Success;
+}
+
+class GetUserProfileJob::Private
+{
+ public:
+ QString avatarUrl;
+ QString displayname;
+};
+
+QUrl GetUserProfileJob::makeRequestUrl(QUrl baseUrl, const QString& userId)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/profile/" % userId);
+}
+
+GetUserProfileJob::GetUserProfileJob(const QString& userId)
+ : BaseJob(HttpVerb::Get, "GetUserProfileJob",
+ basePath % "/profile/" % userId, false)
+ , d(new Private)
+{
+}
+
+GetUserProfileJob::~GetUserProfileJob() = default;
+
+const QString& GetUserProfileJob::avatarUrl() const
+{
+ return d->avatarUrl;
+}
+
+const QString& GetUserProfileJob::displayname() const
+{
+ return d->displayname;
+}
+
+BaseJob::Status GetUserProfileJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ d->avatarUrl = fromJson<QString>(json.value("avatar_url"));
+ d->displayname = fromJson<QString>(json.value("displayname"));
+ return Success;
+}
+