aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/users.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2020-06-07 19:46:40 +0200
committerKitsune Ral <Kitsune-Ral@users.sf.net>2020-06-07 19:46:40 +0200
commit32729d9a7519cd2c4cddb0174b8329c6fd4a4a83 (patch)
tree9a966d7dc0bf628f610d5de1ad64c8d29b6b26f8 /lib/csapi/users.cpp
parenta0430b1fb722a77ad7cbd28f181727d46d92b3a2 (diff)
downloadlibquotient-32729d9a7519cd2c4cddb0174b8329c6fd4a4a83.tar.gz
libquotient-32729d9a7519cd2c4cddb0174b8329c6fd4a4a83.zip
Update generated files according to gtad/* changes
Diffstat (limited to 'lib/csapi/users.cpp')
-rw-r--r--lib/csapi/users.cpp57
1 files changed, 4 insertions, 53 deletions
diff --git a/lib/csapi/users.cpp b/lib/csapi/users.cpp
index 5d2a6133..a0279d7e 100644
--- a/lib/csapi/users.cpp
+++ b/lib/csapi/users.cpp
@@ -4,68 +4,19 @@
#include "users.h"
-#include "converters.h"
-
#include <QtCore/QStringBuilder>
using namespace Quotient;
-static const auto basePath = QStringLiteral("/_matrix/client/r0");
-
-// Converters
-namespace Quotient {
-
-template <>
-struct JsonObjectConverter<SearchUserDirectoryJob::User> {
- static void fillFrom(const QJsonObject& jo,
- SearchUserDirectoryJob::User& result)
- {
- fromJson(jo.value("user_id"_ls), result.userId);
- fromJson(jo.value("display_name"_ls), result.displayName);
- fromJson(jo.value("avatar_url"_ls), result.avatarUrl);
- }
-};
-
-} // namespace Quotient
-
-class SearchUserDirectoryJob::Private {
-public:
- QVector<User> results;
- bool limited;
-};
-
SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm,
Omittable<int> limit)
: BaseJob(HttpVerb::Post, QStringLiteral("SearchUserDirectoryJob"),
- basePath % "/user_directory/search")
- , d(new Private)
+ QStringLiteral("/_matrix/client/r0") % "/user_directory/search")
{
QJsonObject _data;
addParam<>(_data, QStringLiteral("search_term"), searchTerm);
addParam<IfNotEmpty>(_data, QStringLiteral("limit"), limit);
- setRequestData(_data);
-}
-
-SearchUserDirectoryJob::~SearchUserDirectoryJob() = default;
-
-const QVector<SearchUserDirectoryJob::User>& SearchUserDirectoryJob::results() const
-{
- return d->results;
-}
-
-bool SearchUserDirectoryJob::limited() const { return d->limited; }
-
-BaseJob::Status SearchUserDirectoryJob::parseJson(const QJsonDocument& data)
-{
- auto json = data.object();
- if (!json.contains("results"_ls))
- return { IncorrectResponse,
- "The key 'results' not found in the response" };
- fromJson(json.value("results"_ls), d->results);
- if (!json.contains("limited"_ls))
- return { IncorrectResponse,
- "The key 'limited' not found in the response" };
- fromJson(json.value("limited"_ls), d->limited);
-
- return Success;
+ setRequestData(std::move(_data));
+ addExpectedKey("results");
+ addExpectedKey("limited");
}