libkazv
notifications.hpp
Go to the documentation of this file.
1 /******************************************************************************
2  * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
3  */
4 
5 #pragma once
6 
7 #include "basejob.hpp"
8 #include "event.hpp"
9 
10 namespace Kazv::Api {
11 
17 class GetNotificationsJob : public BaseJob {
18 public:
19  // Inner data structures
20 
23  struct Notification
24  {
27  immer::array<Variant> actions;
32  bool read;
34  std::string roomId;
37  std::int_fast64_t ts;
39  std::optional<std::string> profileTag;
40 
41  };
42 
43 
44 
45 class JobResponse : public Response
46 {
47 
48 public:
50  bool success() const;
51 
52  // Result properties
53 
54 
55 
56 
60 std::optional<std::string> nextToken() const;
61 
62 
64 immer::array<Notification> notifications() const;
65 
66 };
67  static constexpr auto needsAuth() {
68  return true
69  ;
70  }
71 
72 
73 // Construction/destruction
74 
89  explicit GetNotificationsJob(std::string serverUrl
90  , std::string _accessToken
91  ,
92  std::optional<std::string> from = std::nullopt, std::optional<int> limit = std::nullopt, std::optional<std::string> only = std::nullopt
93  );
94 
95 
97  std::optional<std::string> from, std::optional<int> limit, std::optional<std::string> only);
98 
99  static BaseJob::Body buildBody(std::optional<std::string> from, std::optional<int> limit, std::optional<std::string> only);
100 
101 
102 
103 
104 
107  };
109  }
110  namespace nlohmann
111  {
112  using namespace Kazv;
113  using namespace Kazv::Api;
114  template<>
115  struct adl_serializer<GetNotificationsJob::Notification> {
116 
117  static void to_json(json& jo, const GetNotificationsJob::Notification &pod)
118  {
119  if (! jo.is_object()) { jo = json::object(); }
120 
121 
122  jo["actions"s] = pod.actions;
123 
124  jo["event"s] = pod.event;
125 
126  jo["read"s] = pod.read;
127 
128  jo["room_id"s] = pod.roomId;
129 
130  jo["ts"s] = pod.ts;
131 
132 
133  addToJsonIfNeeded(jo, "profile_tag"s, pod.profileTag);
134  }
135 
136  static void from_json(const json &jo, GetNotificationsJob::Notification& result)
137  {
138 
139  if (jo.contains("actions"s)) {
140  result.actions = jo.at("actions"s);
141  }
142  if (jo.contains("event"s)) {
143  result.event = jo.at("event"s);
144  }
145  if (jo.contains("read"s)) {
146  result.read = jo.at("read"s);
147  }
148  if (jo.contains("room_id"s)) {
149  result.roomId = jo.at("room_id"s);
150  }
151  if (jo.contains("ts"s)) {
152  result.ts = jo.at("ts"s);
153  }
154  if (jo.contains("profile_tag"s)) {
155  result.profileTag = jo.at("profile_tag"s);
156  }
157 
158  }
159 
160 };
161  }
162 
163  namespace Kazv::Api
164  {
165 
166 } // namespace Kazv::Api
Definition: notifications.hpp:46
immer::array< Notification > notifications() const
The list of events that triggered notifications.
Definition: notifications.cpp:97
JobResponse(Response r)
Definition: notifications.cpp:72
std::optional< std::string > nextToken() const
The token to supply in the from param of the next /notifications request in order to request more eve...
Definition: notifications.cpp:86
bool success() const
Definition: notifications.cpp:75
Gets a list of events that the user has been notified about.
Definition: notifications.hpp:17
GetNotificationsJob withData(JsonWrap j) &&
Definition: notifications.cpp:58
static BaseJob::Body buildBody(std::optional< std::string > from, std::optional< int > limit, std::optional< std::string > only)
Definition: notifications.cpp:26
GetNotificationsJob(std::string serverUrl, std::string _accessToken, std::optional< std::string > from=std::nullopt, std::optional< int > limit=std::nullopt, std::optional< std::string > only=std::nullopt)
Gets a list of events that the user has been notified about.
Definition: notifications.cpp:38
static constexpr auto needsAuth()
Definition: notifications.hpp:67
static BaseJob::Query buildQuery(std::optional< std::string > from, std::optional< int > limit, std::optional< std::string > only)
Definition: notifications.cpp:13
Definition: basejob.hpp:91
Definition: basejob.hpp:77
::Kazv::Body Body
Definition: basejob.hpp:100
Definition: event.hpp:21
Definition: jsonwrap.hpp:23
Definition: location.hpp:10
Definition: location.hpp:10
void addToJsonIfNeeded(json &j, std::string name, T &&arg)
Definition: types.hpp:80
nlohmann::json json
Definition: jsonwrap.hpp:20
Definition: location.hpp:27
This API is used to paginate through the list of events that the user has been, or would have been no...
Definition: notifications.hpp:24
Event event
The Event object for the event that triggered the notification.
Definition: notifications.hpp:29
immer::array< Variant > actions
The action(s) to perform when the conditions for this rule are met.
Definition: notifications.hpp:27
std::optional< std::string > profileTag
The profile tag of the rule that matched this event.
Definition: notifications.hpp:39
bool read
Indicates whether the user has sent a read receipt indicating that they have read this message.
Definition: notifications.hpp:32
std::string roomId
The ID of the room in which the event was posted.
Definition: notifications.hpp:34
std::int_fast64_t ts
The unix timestamp at which the event notification was sent, in milliseconds.
Definition: notifications.hpp:37
Definition: basejob.hpp:50
static void from_json(const json &jo, GetNotificationsJob::Notification &result)
Definition: notifications.hpp:136
static void to_json(json &jo, const GetNotificationsJob::Notification &pod)
Definition: notifications.hpp:117