diff options
Diffstat (limited to 'lib/csapi/account-data.cpp')
-rw-r--r-- | lib/csapi/account-data.cpp | 62 |
1 files changed, 45 insertions, 17 deletions
diff --git a/lib/csapi/account-data.cpp b/lib/csapi/account-data.cpp index 5021c73a..8c71f6c5 100644 --- a/lib/csapi/account-data.cpp +++ b/lib/csapi/account-data.cpp @@ -4,29 +4,57 @@ #include "account-data.h" -#include "converters.h" +using namespace Quotient; -#include <QtCore/QStringBuilder> - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -static const auto SetAccountDataJobName = QStringLiteral("SetAccountDataJob"); +SetAccountDataJob::SetAccountDataJob(const QString& userId, const QString& type, + const QJsonObject& content) + : BaseJob(HttpVerb::Put, QStringLiteral("SetAccountDataJob"), + makePath("/_matrix/client/v3", "/user/", userId, "/account_data/", + type)) +{ + setRequestData({ toJson(content) }); +} -SetAccountDataJob::SetAccountDataJob(const QString& userId, const QString& type, const QJsonObject& content) - : BaseJob(HttpVerb::Put, SetAccountDataJobName, - basePath % "/user/" % userId % "/account_data/" % type) +QUrl GetAccountDataJob::makeRequestUrl(QUrl baseUrl, const QString& userId, + const QString& type) { - setRequestData(Data(toJson(content))); + return BaseJob::makeRequestUrl(std::move(baseUrl), + makePath("/_matrix/client/v3", "/user/", + userId, "/account_data/", type)); } -static const auto SetAccountDataPerRoomJobName = QStringLiteral("SetAccountDataPerRoomJob"); +GetAccountDataJob::GetAccountDataJob(const QString& userId, const QString& type) + : BaseJob(HttpVerb::Get, QStringLiteral("GetAccountDataJob"), + makePath("/_matrix/client/v3", "/user/", userId, "/account_data/", + type)) +{} + +SetAccountDataPerRoomJob::SetAccountDataPerRoomJob(const QString& userId, + const QString& roomId, + const QString& type, + const QJsonObject& content) + : BaseJob(HttpVerb::Put, QStringLiteral("SetAccountDataPerRoomJob"), + makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", + roomId, "/account_data/", type)) +{ + setRequestData({ toJson(content) }); +} -SetAccountDataPerRoomJob::SetAccountDataPerRoomJob(const QString& userId, const QString& roomId, const QString& type, const QJsonObject& content) - : BaseJob(HttpVerb::Put, SetAccountDataPerRoomJobName, - basePath % "/user/" % userId % "/rooms/" % roomId % "/account_data/" % type) +QUrl GetAccountDataPerRoomJob::makeRequestUrl(QUrl baseUrl, + const QString& userId, + const QString& roomId, + const QString& type) { - setRequestData(Data(toJson(content))); + return BaseJob::makeRequestUrl(std::move(baseUrl), + makePath("/_matrix/client/v3", "/user/", + userId, "/rooms/", roomId, + "/account_data/", type)); } +GetAccountDataPerRoomJob::GetAccountDataPerRoomJob(const QString& userId, + const QString& roomId, + const QString& type) + : BaseJob(HttpVerb::Get, QStringLiteral("GetAccountDataPerRoomJob"), + makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", + roomId, "/account_data/", type)) +{} |