/****************************************************************************** * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN */ #include "users.h" #include "converters.h" #include using namespace QMatrixClient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); namespace QMatrixClient { // Converters template <> struct FromJsonObject { SearchUserDirectoryJob::User operator()(const QJsonObject& jo) const { SearchUserDirectoryJob::User result; result.userId = fromJson(jo.value("user_id"_ls)); result.displayName = fromJson(jo.value("display_name"_ls)); result.avatarUrl = fromJson(jo.value("avatar_url"_ls)); return result; } }; } // namespace QMatrixClient class SearchUserDirectoryJob::Private { public: QVector results; bool limited; }; static const auto SearchUserDirectoryJobName = QStringLiteral("SearchUserDirectoryJob"); SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, Omittable limit) : BaseJob(HttpVerb::Post, SearchUserDirectoryJobName, basePath % "/user_directory/search") , d(new Private) { QJsonObject _data; addParam<>(_data, QStringLiteral("search_term"), searchTerm); addParam(_data, QStringLiteral("limit"), limit); setRequestData(_data); } SearchUserDirectoryJob::~SearchUserDirectoryJob() = default; const QVector& 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 { JsonParseError, "The key 'results' not found in the response" }; d->results = fromJson>(json.value("results"_ls)); if (!json.contains("limited"_ls)) return { JsonParseError, "The key 'limited' not found in the response" }; d->limited = fromJson(json.value("limited"_ls)); return Success; }