libkazv
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 
10 namespace Kazv::Api {
11 
16 class GetPushersJob : public BaseJob {
17 public:
18  // Inner data structures
19 
22  struct PusherData
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 
66 class JobResponse : public Response
67 {
68 
69 public:
71  bool success() const;
72 
73  // Result properties
74 
75 
76 
77 
79 immer::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 
108  GetPushersJob withData(JsonWrap j) const &;
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 
211 class PostPusherJob : public BaseJob {
212 public:
213  // Inner data structures
214 
218  struct PusherData
219  {
223  std::optional<std::string> url;
229  std::optional<std::string> format;
230 
231  };
232 
233 
234 
235 class JobResponse : public Response
236 {
237 
238 public:
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 
312  static BaseJob::Query buildQuery(
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 
321  PostPusherJob withData(JsonWrap j) &&;
322  PostPusherJob withData(JsonWrap j) const &;
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
Kazv::Api::GetPushersJob::withData
GetPushersJob withData(JsonWrap j) &&
Definition: pusher.cpp:55
Kazv::Api::GetPushersJob::needsAuth
static constexpr auto needsAuth()
Definition: pusher.hpp:86
Kazv::Api::PostPusherJob
Modify a pusher for this user on the homeserver.
Definition: pusher.hpp:211
Kazv::Api::GetPushersJob::Pusher
Gets all currently active pushers for the authenticated user.
Definition: pusher.hpp:38
nlohmann::adl_serializer< GetPushersJob::Pusher >::from_json
static void from_json(const json &jo, GetPushersJob::Pusher &result)
Definition: pusher.hpp:169
Kazv::Api::GetPushersJob::PusherData::url
std::optional< std::string > url
Required if kind is http.
Definition: pusher.hpp:32
Kazv::Api::GetPushersJob::buildBody
static BaseJob::Body buildBody()
Definition: pusher.cpp:23
nlohmann
Definition: location.hpp:26
Kazv::Api::GetPushersJob::Pusher::appId
std::string appId
This is a reverse-DNS style identifier for the application.
Definition: pusher.hpp:49
Kazv::Api::GetPushersJob::buildQuery
static BaseJob::Query buildQuery()
Definition: pusher.cpp:15
Kazv::Api::GetPushersJob::Pusher::lang
std::string lang
The preferred language for receiving notifications (e.g.
Definition: pusher.hpp:58
Kazv::Api::GetPushersJob::Pusher::kind
std::string kind
The kind of pusher.
Definition: pusher.hpp:46
Kazv::Api::GetPushersJob::JobResponse
Definition: pusher.hpp:70
Kazv::Api::PostPusherJob::PusherData::format
std::optional< std::string > format
The format to send notifications in to Push Gateways if the kind is http.
Definition: pusher.hpp:229
Kazv
Definition: location.hpp:10
Kazv::Api::PostPusherJob::PusherData
A dictionary of information for the pusher implementation itself.
Definition: pusher.hpp:218
Kazv::Api::GetPushersJob::GetPushersJob
GetPushersJob(std::string serverUrl, std::string _accessToken)
Gets the current pushers for the authenticated user.
Definition: pusher.cpp:35
Kazv::Api::GetPushersJob
Gets the current pushers for the authenticated user.
Definition: pusher.hpp:18
Kazv::BaseJob::Query
Definition: basejob.hpp:90
nlohmann::adl_serializer< PostPusherJob::PusherData >::from_json
static void from_json(const json &jo, PostPusherJob::PusherData &result)
Definition: pusher.hpp:344
nlohmann::adl_serializer< GetPushersJob::PusherData >::from_json
static void from_json(const json &jo, GetPushersJob::PusherData &result)
Definition: pusher.hpp:130
Kazv::Api::GetPushersJob::Pusher::data
PusherData data
A dictionary of information for the pusher implementation itself.
Definition: pusher.hpp:61
nlohmann::adl_serializer< PostPusherJob::PusherData >::to_json
static void to_json(json &jo, const PostPusherJob::PusherData &pod)
Definition: pusher.hpp:333
Kazv::Api::PostPusherJob::PusherData::url
std::optional< std::string > url
Required if kind is http.
Definition: pusher.hpp:223
nlohmann::adl_serializer< GetPushersJob::Pusher >::to_json
static void to_json(json &jo, const GetPushersJob::Pusher &pod)
Definition: pusher.hpp:146
Kazv::Api::GetPushersJob::Pusher::appDisplayName
std::string appDisplayName
A string that will allow the user to identify what application owns this pusher.
Definition: pusher.hpp:52
Kazv::json
nlohmann::json json
Definition: jsonwrap.hpp:20
Kazv::Api
Definition: location.hpp:10
Kazv::Api::GetPushersJob::JobResponse::JobResponse
JobResponse(Response r)
Definition: pusher.cpp:69
Kazv::Api::GetPushersJob::JobResponse::success
bool success() const
Definition: pusher.cpp:72
Kazv::addToJsonIfNeeded
void addToJsonIfNeeded(json &j, std::string name, T &&arg)
Definition: types.hpp:80
Kazv::Api::PostPusherJob::JobResponse
Definition: pusher.hpp:235
basejob.hpp
Kazv::Api::GetPushersJob::JobResponse::pushers
immer::array< Pusher > pushers() const
An array containing the current pushers for the user.
Definition: pusher.cpp:82
Kazv::JsonWrap
Definition: jsonwrap.hpp:22
Kazv::Api::GetPushersJob::Pusher::deviceDisplayName
std::string deviceDisplayName
A string that will allow the user to identify what device owns this pusher.
Definition: pusher.hpp:55
Kazv::BaseJob
Definition: basejob.hpp:76
Kazv::BaseJob::Body
::Kazv::Body Body
Definition: basejob.hpp:100
nlohmann::adl_serializer< GetPushersJob::PusherData >::to_json
static void to_json(json &jo, const GetPushersJob::PusherData &pod)
Definition: pusher.hpp:119
Kazv::Api::PostPusherJob::needsAuth
static constexpr auto needsAuth()
Definition: pusher.hpp:243
Kazv::Api::GetPushersJob::PusherData::format
std::optional< std::string > format
The format to use when sending notifications to the Push Gateway.
Definition: pusher.hpp:35
Kazv::Api::GetPushersJob::Pusher::profileTag
std::optional< std::string > profileTag
This string determines which set of device specific rules this pusher executes.
Definition: pusher.hpp:64
Kazv::Api::GetPushersJob::Pusher::pushkey
std::string pushkey
This is a unique identifier for this pusher.
Definition: pusher.hpp:43
Kazv::Api::GetPushersJob::PusherData
A dictionary of information for the pusher implementation itself.
Definition: pusher.hpp:26
Kazv::Response
Definition: basejob.hpp:50