aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/list_joined_rooms.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/list_joined_rooms.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/list_joined_rooms.cpp')
-rw-r--r--lib/csapi/list_joined_rooms.cpp33
1 files changed, 4 insertions, 29 deletions
diff --git a/lib/csapi/list_joined_rooms.cpp b/lib/csapi/list_joined_rooms.cpp
index 34eb0d42..8d7e267f 100644
--- a/lib/csapi/list_joined_rooms.cpp
+++ b/lib/csapi/list_joined_rooms.cpp
@@ -4,45 +4,20 @@
#include "list_joined_rooms.h"
-#include "converters.h"
-
#include <QtCore/QStringBuilder>
using namespace Quotient;
-static const auto basePath = QStringLiteral("/_matrix/client/r0");
-
-class GetJoinedRoomsJob::Private {
-public:
- QStringList joinedRooms;
-};
-
QUrl GetJoinedRoomsJob::makeRequestUrl(QUrl baseUrl)
{
return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/joined_rooms");
+ QStringLiteral("/_matrix/client/r0")
+ % "/joined_rooms");
}
GetJoinedRoomsJob::GetJoinedRoomsJob()
: BaseJob(HttpVerb::Get, QStringLiteral("GetJoinedRoomsJob"),
- basePath % "/joined_rooms")
- , d(new Private)
-{}
-
-GetJoinedRoomsJob::~GetJoinedRoomsJob() = default;
-
-const QStringList& GetJoinedRoomsJob::joinedRooms() const
+ QStringLiteral("/_matrix/client/r0") % "/joined_rooms")
{
- return d->joinedRooms;
-}
-
-BaseJob::Status GetJoinedRoomsJob::parseJson(const QJsonDocument& data)
-{
- auto json = data.object();
- if (!json.contains("joined_rooms"_ls))
- return { IncorrectResponse,
- "The key 'joined_rooms' not found in the response" };
- fromJson(json.value("joined_rooms"_ls), d->joinedRooms);
-
- return Success;
+ addExpectedKey("joined_rooms");
}