1/******************************************************************************
2 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
3 */
4
5#pragma once
6
7#include <Quotient/events/event.h>
8#include <Quotient/jobs/basejob.h>
9
10namespace Quotient {
11
12/*! \brief Gets a list of events that the user has been notified about
13 *
14 * This API is used to paginate through the list of events that the
15 * user has been, or would have been notified about.
16 */
17class QUOTIENT_API GetNotificationsJob : public BaseJob {
18public:
19 // Inner data structures
20
21 /// This API is used to paginate through the list of events that the
22 /// user has been, or would have been notified about.
23 struct Notification {
24 /// The action(s) to perform when the conditions for this rule are met.
25 /// See [Push Rules: API](/client-server-api/#push-rules-api).
26 QVector<QVariant> actions;
27 /// The Event object for the event that triggered the notification.
28 EventPtr event;
29 /// Indicates whether the user has sent a read receipt indicating
30 /// that they have read this message.
31 bool read;
32 /// The ID of the room in which the event was posted.
33 QString roomId;
34 /// The unix timestamp at which the event notification was sent,
35 /// in milliseconds.
36 qint64 ts;
37 /// The profile tag of the rule that matched this event.
38 QString profileTag{};
39 };
40
41 // Construction/destruction
42
43 /*! \brief Gets a list of events that the user has been notified about
44 *
45 * \param from
46 * Pagination token to continue from. This should be the `next_token`
47 * returned from an earlier call to this endpoint.
48 *
49 * \param limit
50 * Limit on the number of events to return in this request.
51 *
52 * \param only
53 * Allows basic filtering of events returned. Supply `highlight`
54 * to return only events where the notification had the highlight
55 * tweak set.
56 */
57 explicit GetNotificationsJob(const QString& from = {},
58 Omittable<int> limit = none,
59 const QString& only = {});
60
61 /*! \brief Construct a URL without creating a full-fledged job object
62 *
63 * This function can be used when a URL for GetNotificationsJob
64 * is necessary but the job itself isn't.
65 */
66 static QUrl makeRequestUrl(QUrl baseUrl, const QString& from = {},
67 Omittable<int> limit = none,
68 const QString& only = {});
69
70 // Result properties
71
72 /// The token to supply in the `from` param of the next
73 /// `/notifications` request in order to request more
74 /// events. If this is absent, there are no more results.
75 QString nextToken() const { return loadFromJson<QString>(keyName: "next_token"_ls); }
76
77 /// The list of events that triggered notifications.
78 std::vector<Notification> notifications()
79 {
80 return takeFromJson<std::vector<Notification>>(key: "notifications"_ls);
81 }
82};
83
84template <>
85struct JsonObjectConverter<GetNotificationsJob::Notification> {
86 static void fillFrom(const QJsonObject& jo,
87 GetNotificationsJob::Notification& result)
88 {
89 fillFromJson(jv: jo.value(key: "actions"_ls), pod&: result.actions);
90 fillFromJson(jv: jo.value(key: "event"_ls), pod&: result.event);
91 fillFromJson(jv: jo.value(key: "read"_ls), pod&: result.read);
92 fillFromJson(jv: jo.value(key: "room_id"_ls), pod&: result.roomId);
93 fillFromJson(jv: jo.value(key: "ts"_ls), pod&: result.ts);
94 fillFromJson(jv: jo.value(key: "profile_tag"_ls), pod&: result.profileTag);
95 }
96};
97
98} // namespace Quotient
99