aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/room_upgrades.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2020-06-09 08:52:25 +0200
committerGitHub <noreply@github.com>2020-06-09 08:52:25 +0200
commit370d9b3e46332d38df8798cda208c534c58be808 (patch)
treef3db0cd7463468ff52c74446acd608356f8b8ab6 /lib/csapi/room_upgrades.cpp
parente1f5d0aa2c33e6da6c3a609c8bc7e0b5867e748d (diff)
parent10d9ac4673e374a9ac17ff492591136520337c4c (diff)
downloadlibquotient-370d9b3e46332d38df8798cda208c534c58be808.tar.gz
libquotient-370d9b3e46332d38df8798cda208c534c58be808.zip
Merge pull request #405 from quotient-im/kitsune-basejob-store-json-response
Store JSON response in BaseJob + tweaks to the generated code
Diffstat (limited to 'lib/csapi/room_upgrades.cpp')
-rw-r--r--lib/csapi/room_upgrades.cpp34
1 files changed, 4 insertions, 30 deletions
diff --git a/lib/csapi/room_upgrades.cpp b/lib/csapi/room_upgrades.cpp
index 244f5b74..e3791b08 100644
--- a/lib/csapi/room_upgrades.cpp
+++ b/lib/csapi/room_upgrades.cpp
@@ -4,43 +4,17 @@
#include "room_upgrades.h"
-#include "converters.h"
-
#include <QtCore/QStringBuilder>
using namespace Quotient;
-static const auto basePath = QStringLiteral("/_matrix/client/r0");
-
-class UpgradeRoomJob::Private {
-public:
- QString replacementRoom;
-};
-
UpgradeRoomJob::UpgradeRoomJob(const QString& roomId, const QString& newVersion)
: BaseJob(HttpVerb::Post, QStringLiteral("UpgradeRoomJob"),
- basePath % "/rooms/" % roomId % "/upgrade")
- , d(new Private)
+ QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId
+ % "/upgrade")
{
QJsonObject _data;
addParam<>(_data, QStringLiteral("new_version"), newVersion);
- setRequestData(_data);
-}
-
-UpgradeRoomJob::~UpgradeRoomJob() = default;
-
-const QString& UpgradeRoomJob::replacementRoom() const
-{
- return d->replacementRoom;
-}
-
-BaseJob::Status UpgradeRoomJob::parseJson(const QJsonDocument& data)
-{
- auto json = data.object();
- if (!json.contains("replacement_room"_ls))
- return { IncorrectResponse,
- "The key 'replacement_room' not found in the response" };
- fromJson(json.value("replacement_room"_ls), d->replacementRoom);
-
- return Success;
+ setRequestData(std::move(_data));
+ addExpectedKey("replacement_room");
}