aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/notifications.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/csapi/notifications.h')
-rw-r--r--lib/csapi/notifications.h38
1 files changed, 21 insertions, 17 deletions
diff --git a/lib/csapi/notifications.h b/lib/csapi/notifications.h
index 0e86e424..095e9325 100644
--- a/lib/csapi/notifications.h
+++ b/lib/csapi/notifications.h
@@ -4,19 +4,11 @@
#pragma once
-#include "converters.h"
-
#include "events/eventloader.h"
#include "jobs/basejob.h"
-#include <QtCore/QJsonObject>
-#include <QtCore/QVariant>
-#include <QtCore/QVector>
-
namespace Quotient {
-// Operations
-
/*! \brief Gets a list of events that the user has been notified about
*
* This API is used to paginate through the list of events that the
@@ -50,10 +42,13 @@ public:
/*! \brief Gets a list of events that the user has been notified about
*
+ *
* \param from
* Pagination token given to retrieve the next set of events.
+ *
* \param limit
* Limit on the number of events to return in this request.
+ *
* \param only
* Allows basic filtering of events returned. Supply ``highlight``
* to return only events where the notification had the highlight
@@ -71,24 +66,33 @@ public:
static QUrl makeRequestUrl(QUrl baseUrl, const QString& from = {},
Omittable<int> limit = none,
const QString& only = {});
- ~GetNotificationsJob() override;
// Result properties
/// The token to supply in the ``from`` param of the next
/// ``/notifications`` request in order to request more
/// events. If this is absent, there are no more results.
- const QString& nextToken() const;
+ QString nextToken() const { return loadFromJson<QString>("next_token"_ls); }
/// The list of events that triggered notifications.
- std::vector<Notification>&& notifications();
-
-protected:
- Status parseJson(const QJsonDocument& data) override;
+ std::vector<Notification> notifications()
+ {
+ return takeFromJson<std::vector<Notification>>("notifications"_ls);
+ }
+};
-private:
- class Private;
- QScopedPointer<Private> d;
+template <>
+struct JsonObjectConverter<GetNotificationsJob::Notification> {
+ static void fillFrom(const QJsonObject& jo,
+ GetNotificationsJob::Notification& result)
+ {
+ fromJson(jo.value("actions"_ls), result.actions);
+ fromJson(jo.value("event"_ls), result.event);
+ fromJson(jo.value("profile_tag"_ls), result.profileTag);
+ fromJson(jo.value("read"_ls), result.read);
+ fromJson(jo.value("room_id"_ls), result.roomId);
+ fromJson(jo.value("ts"_ls), result.ts);
+ }
};
} // namespace Quotient