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;
29  Event event;
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
Kazv::Api::GetNotificationsJob::withData
GetNotificationsJob withData(JsonWrap j) &&
Definition: notifications.cpp:60
Kazv::Api::GetNotificationsJob::buildQuery
static BaseJob::Query buildQuery(std::optional< std::string > from, std::optional< int > limit, std::optional< std::string > only)
Definition: notifications.cpp:15
nlohmann
Definition: location.hpp:26
Kazv::Api::GetNotificationsJob::JobResponse
Definition: notifications.hpp:49
event.hpp
Kazv::Api::GetNotificationsJob::JobResponse::nextToken
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:88
Kazv
Definition: location.hpp:10
Kazv::BaseJob::Query
Definition: basejob.hpp:90
nlohmann::adl_serializer< GetNotificationsJob::Notification >::from_json
static void from_json(const json &jo, GetNotificationsJob::Notification &result)
Definition: notifications.hpp:136
Kazv::Api::GetNotificationsJob::Notification
This API is used to paginate through the list of events that the user has been, or would have been no...
Definition: notifications.hpp:27
Kazv::Api::GetNotificationsJob::Notification::profileTag
std::optional< std::string > profileTag
The profile tag of the rule that matched this event.
Definition: notifications.hpp:45
Kazv::json
nlohmann::json json
Definition: jsonwrap.hpp:20
Kazv::Api::GetNotificationsJob::Notification::ts
std::int_fast64_t ts
The unix timestamp at which the event notification was sent, in milliseconds.
Definition: notifications.hpp:43
Kazv::Api
Definition: location.hpp:10
Kazv::Api::GetNotificationsJob::Notification::actions
immer::array< Variant > actions
The action(s) to perform when the conditions for this rule are met.
Definition: notifications.hpp:33
Kazv::Api::GetNotificationsJob::JobResponse::JobResponse
JobResponse(Response r)
Definition: notifications.cpp:74
Kazv::Api::GetNotificationsJob::Notification::read
bool read
Indicates whether the user has sent a read receipt indicating that they have read this message.
Definition: notifications.hpp:38
Kazv::Api::GetNotificationsJob::Notification::event
Event event
The Event object for the event that triggered the notification.
Definition: notifications.hpp:35
Kazv::addToJsonIfNeeded
void addToJsonIfNeeded(json &j, std::string name, T &&arg)
Definition: types.hpp:80
basejob.hpp
Kazv::JsonWrap
Definition: jsonwrap.hpp:22
Kazv::Api::GetNotificationsJob::JobResponse::success
bool success() const
Definition: notifications.cpp:77
Kazv::Api::GetNotificationsJob::needsAuth
static constexpr auto needsAuth()
Definition: notifications.hpp:71
Kazv::Event
Definition: event.hpp:20
Kazv::Api::GetNotificationsJob::Notification::roomId
std::string roomId
The ID of the room in which the event was posted.
Definition: notifications.hpp:40
nlohmann::adl_serializer< GetNotificationsJob::Notification >::to_json
static void to_json(json &jo, const GetNotificationsJob::Notification &pod)
Definition: notifications.hpp:117
Kazv::BaseJob::Body
::Kazv::Body Body
Definition: basejob.hpp:100
Kazv::Api::GetNotificationsJob::JobResponse::notifications
immer::array< Notification > notifications() const
The list of events that triggered notifications.
Definition: notifications.cpp:99
Kazv::Api::GetNotificationsJob
Gets a list of events that the user has been notified about.
Definition: notifications.hpp:19
Kazv::Api::GetNotificationsJob::buildBody
static BaseJob::Body buildBody(std::optional< std::string > from, std::optional< int > limit, std::optional< std::string > only)
Definition: notifications.cpp:28
Kazv::Api::GetNotificationsJob::GetNotificationsJob
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:40
Kazv::Response
Definition: basejob.hpp:50