/****************************************************************************** * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN */ #include "notifications.h" #include "converters.h" #include using namespace QMatrixClient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); namespace QMatrixClient { // Converters template <> struct FromJson { GetNotificationsJob::Notification operator()(const QJsonValue& jv) { const auto& _json = jv.toObject(); GetNotificationsJob::Notification result; result.actions = fromJson>(_json.value("actions")); result.event = fromJson(_json.value("event")); result.profileTag = fromJson(_json.value("profile_tag")); result.read = fromJson(_json.value("read")); result.roomId = fromJson(_json.value("room_id")); result.ts = fromJson(_json.value("ts")); return result; } }; } // namespace QMatrixClient class GetNotificationsJob::Private { public: QString nextToken; std::vector notifications; }; BaseJob::Query queryToGetNotifications(const QString& from, Omittable limit, const QString& only) { BaseJob::Query _q; addParam(_q, "from", from); addParam(_q, "limit", limit); addParam(_q, "only", only); return _q; } QUrl GetNotificationsJob::makeRequestUrl(QUrl baseUrl, const QString& from, Omittable limit, const QString& only) { return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/notifications", queryToGetNotifications(from, limit, only)); } GetNotificationsJob::GetNotificationsJob(const QString& from, Omittable limit, const QString& only) : BaseJob(HttpVerb::Get, "GetNotificationsJob", basePath % "/notifications", queryToGetNotifications(from, limit, only)) , d(new Private) { } GetNotificationsJob::~GetNotificationsJob() = default; const QString& GetNotificationsJob::nextToken() const { return d->nextToken; } std::vector&& GetNotificationsJob::notifications() { return std::move(d->notifications); } BaseJob::Status GetNotificationsJob::parseJson(const QJsonDocument& data) { auto json = data.object(); d->nextToken = fromJson(json.value("next_token")); if (!json.contains("notifications")) return { JsonParseError, "The key 'notifications' not found in the response" }; d->notifications = fromJson>(json.value("notifications")); return Success; }