libkazv
Loading...
Searching...
No Matches
pusher.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
9
10namespace Kazv::Api {
11
16class GetPushersJob : public BaseJob {
17public:
18 // Inner data structures
19
23 {
26 std::optional<std::string> url;
29 std::optional<std::string> format;
30
31 };
32
34 struct Pusher
35 {
39 std::string pushkey;
42 std::string kind;
45 std::string appId;
48 std::string appDisplayName;
51 std::string deviceDisplayName;
54 std::string lang;
60 std::optional<std::string> profileTag;
61
62 };
63
64
65
66class JobResponse : public Response
67{
68
69public:
71 bool success() const;
72
73 // Result properties
74
75
76
77
79immer::array<Pusher> pushers() const;
80
81};
82 static constexpr auto needsAuth() {
83 return true
84 ;
85 }
86
87
88// Construction/destruction
89
91 explicit GetPushersJob(std::string serverUrl
92 , std::string _accessToken
93
94
95 );
96
97
99 );
100
101 static BaseJob::Body buildBody();
102
103
104
105
106
109 };
111 }
112 namespace nlohmann
113 {
114 using namespace Kazv;
115 using namespace Kazv::Api;
116 template<>
117 struct adl_serializer<GetPushersJob::PusherData> {
118
119 static void to_json(json& jo, const GetPushersJob::PusherData &pod)
120 {
121 if (! jo.is_object()) { jo = json::object(); }
122
123
124
125 addToJsonIfNeeded(jo, "url"s, pod.url);
126
127 addToJsonIfNeeded(jo, "format"s, pod.format);
128 }
129
130 static void from_json(const json &jo, GetPushersJob::PusherData& result)
131 {
132
133 if (jo.contains("url"s)) {
134 result.url = jo.at("url"s);
135 }
136 if (jo.contains("format"s)) {
137 result.format = jo.at("format"s);
138 }
139
140 }
141
142};
143 template<>
144 struct adl_serializer<GetPushersJob::Pusher> {
145
146 static void to_json(json& jo, const GetPushersJob::Pusher &pod)
147 {
148 if (! jo.is_object()) { jo = json::object(); }
149
150
151 jo["pushkey"s] = pod.pushkey;
152
153 jo["kind"s] = pod.kind;
154
155 jo["app_id"s] = pod.appId;
156
157 jo["app_display_name"s] = pod.appDisplayName;
158
159 jo["device_display_name"s] = pod.deviceDisplayName;
160
161 jo["lang"s] = pod.lang;
162
163 jo["data"s] = pod.data;
164
165
166 addToJsonIfNeeded(jo, "profile_tag"s, pod.profileTag);
167 }
168
169 static void from_json(const json &jo, GetPushersJob::Pusher& result)
170 {
171
172 if (jo.contains("pushkey"s)) {
173 result.pushkey = jo.at("pushkey"s);
174 }
175 if (jo.contains("kind"s)) {
176 result.kind = jo.at("kind"s);
177 }
178 if (jo.contains("app_id"s)) {
179 result.appId = jo.at("app_id"s);
180 }
181 if (jo.contains("app_display_name"s)) {
182 result.appDisplayName = jo.at("app_display_name"s);
183 }
184 if (jo.contains("device_display_name"s)) {
185 result.deviceDisplayName = jo.at("device_display_name"s);
186 }
187 if (jo.contains("lang"s)) {
188 result.lang = jo.at("lang"s);
189 }
190 if (jo.contains("data"s)) {
191 result.data = jo.at("data"s);
192 }
193 if (jo.contains("profile_tag"s)) {
194 result.profileTag = jo.at("profile_tag"s);
195 }
196
197 }
198
199};
200 }
201
202 namespace Kazv::Api
203 {
204
211class PostPusherJob : public BaseJob {
212public:
213 // Inner data structures
214
219 {
223 std::optional<std::string> url;
229 std::optional<std::string> format;
230
231 };
232
233
234
235class JobResponse : public Response
236{
237
238public:
240 bool success() const;
241
242};
243 static constexpr auto needsAuth() {
244 return true
245 ;
246 }
247
248
249// Construction/destruction
250
305 explicit PostPusherJob(std::string serverUrl
306 , std::string _accessToken
307 ,
308 std::string pushkey , std::string kind , std::string appId , std::string appDisplayName , std::string deviceDisplayName , std::string lang , PusherData data , std::optional<std::string> profileTag = std::nullopt, std::optional<bool> append = std::nullopt
309 );
310
311
313 );
314
315 static BaseJob::Body buildBody(std::string pushkey, std::string kind, std::string appId, std::string appDisplayName, std::string deviceDisplayName, std::string lang, PusherData data, std::optional<std::string> profileTag, std::optional<bool> append);
316
317
318
319
320
323 };
325 }
326 namespace nlohmann
327 {
328 using namespace Kazv;
329 using namespace Kazv::Api;
330 template<>
331 struct adl_serializer<PostPusherJob::PusherData> {
332
333 static void to_json(json& jo, const PostPusherJob::PusherData &pod)
334 {
335 if (! jo.is_object()) { jo = json::object(); }
336
337
338
339 addToJsonIfNeeded(jo, "url"s, pod.url);
340
341 addToJsonIfNeeded(jo, "format"s, pod.format);
342 }
343
344 static void from_json(const json &jo, PostPusherJob::PusherData& result)
345 {
346
347 if (jo.contains("url"s)) {
348 result.url = jo.at("url"s);
349 }
350 if (jo.contains("format"s)) {
351 result.format = jo.at("format"s);
352 }
353
354 }
355
356};
357 }
358
359 namespace Kazv::Api
360 {
361
362} // namespace Kazv::Api
bool success() const
Definition pusher.cpp:70
immer::array< Pusher > pushers() const
An array containing the current pushers for the user.
Definition pusher.cpp:80
Gets the current pushers for the authenticated user.
Definition pusher.hpp:16
GetPushersJob withData(JsonWrap j) &&
Definition pusher.cpp:53
static constexpr auto needsAuth()
Definition pusher.hpp:82
static BaseJob::Query buildQuery()
Definition pusher.cpp:13
static BaseJob::Body buildBody()
Definition pusher.cpp:21
Definition pusher.hpp:236
bool success() const
Definition pusher.cpp:171
Modify a pusher for this user on the homeserver.
Definition pusher.hpp:211
static BaseJob::Body buildBody(std::string pushkey, std::string kind, std::string appId, std::string appDisplayName, std::string deviceDisplayName, std::string lang, PusherData data, std::optional< std::string > profileTag, std::optional< bool > append)
Definition pusher.cpp:100
static constexpr auto needsAuth()
Definition pusher.hpp:243
static BaseJob::Query buildQuery()
Definition pusher.cpp:92
PostPusherJob withData(JsonWrap j) &&
Definition pusher.cpp:154
Definition basejob.hpp:94
Definition basejob.hpp:68
::Kazv::Body Body
Definition basejob.hpp:103
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
A dictionary of information for the pusher implementation itself.
Definition pusher.hpp:23
std::optional< std::string > url
Required if kind is http.
Definition pusher.hpp:26
std::optional< std::string > format
The format to use when sending notifications to the Push Gateway.
Definition pusher.hpp:29
Gets all currently active pushers for the authenticated user.
Definition pusher.hpp:35
std::string appId
This is a reverse-DNS style identifier for the application.
Definition pusher.hpp:45
std::optional< std::string > profileTag
This string determines which set of device specific rules this pusher executes.
Definition pusher.hpp:60
std::string deviceDisplayName
A string that will allow the user to identify what device owns this pusher.
Definition pusher.hpp:51
PusherData data
A dictionary of information for the pusher implementation itself.
Definition pusher.hpp:57
std::string kind
The kind of pusher.
Definition pusher.hpp:42
std::string lang
The preferred language for receiving notifications (e.g.
Definition pusher.hpp:54
std::string appDisplayName
A string that will allow the user to identify what application owns this pusher.
Definition pusher.hpp:48
std::string pushkey
This is a unique identifier for this pusher.
Definition pusher.hpp:39
A dictionary of information for the pusher implementation itself.
Definition pusher.hpp:219
std::optional< std::string > format
The format to send notifications in to Push Gateways if the kind is http.
Definition pusher.hpp:229
std::optional< std::string > url
Required if kind is http.
Definition pusher.hpp:223
Definition basejob.hpp:49
static void to_json(json &jo, const GetPushersJob::PusherData &pod)
Definition pusher.hpp:119
static void from_json(const json &jo, GetPushersJob::PusherData &result)
Definition pusher.hpp:130
static void from_json(const json &jo, GetPushersJob::Pusher &result)
Definition pusher.hpp:169
static void to_json(json &jo, const GetPushersJob::Pusher &pod)
Definition pusher.hpp:146
static void from_json(const json &jo, PostPusherJob::PusherData &result)
Definition pusher.hpp:344
static void to_json(json &jo, const PostPusherJob::PusherData &pod)
Definition pusher.hpp:333