libkazv
create_room.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 
56 class CreateRoomJob : public BaseJob {
57 public:
58  // Inner data structures
59 
101  struct Invite3pid
102  {
104  std::string idServer;
108  std::string idAccessToken;
110  std::string medium;
112  std::string address;
113 
114  };
115 
157  struct StateEvent
158  {
160  std::string type;
164  std::optional<std::string> stateKey;
165 
166  };
167 
168 
169 
170 class JobResponse : public Response
171 {
172 
173 public:
175  bool success() const;
176 
177  // Result properties
178 
179 
180 
181 
183 std::string roomId() const;
184 
185 };
186  static constexpr auto needsAuth() {
187  return true
188  ;
189  }
190 
191 
192 // Construction/destruction
193 
276  explicit CreateRoomJob(std::string serverUrl
277  , std::string _accessToken
278  ,
279  std::optional<std::string> visibility = std::nullopt, std::optional<std::string> roomAliasName = std::nullopt, std::optional<std::string> name = std::nullopt, std::optional<std::string> topic = std::nullopt, immer::array<std::string> invite = {}, immer::array<Invite3pid> invite3pid = {}, std::optional<std::string> roomVersion = std::nullopt, JsonWrap creationContent = {}, immer::array<StateEvent> initialState = {}, std::optional<std::string> preset = std::nullopt, std::optional<bool> isDirect = std::nullopt, JsonWrap powerLevelContentOverride = {}
280  );
281 
282 
283  static BaseJob::Query buildQuery(
284  );
285 
286  static BaseJob::Body buildBody(std::optional<std::string> visibility, std::optional<std::string> roomAliasName, std::optional<std::string> name, std::optional<std::string> topic, immer::array<std::string> invite, immer::array<Invite3pid> invite3pid, std::optional<std::string> roomVersion, JsonWrap creationContent, immer::array<StateEvent> initialState, std::optional<std::string> preset, std::optional<bool> isDirect, JsonWrap powerLevelContentOverride);
287 
288 
289 
290 
291 
292  CreateRoomJob withData(JsonWrap j) &&;
293  CreateRoomJob withData(JsonWrap j) const &;
294  };
296  }
297  namespace nlohmann
298  {
299  using namespace Kazv;
300  using namespace Kazv::Api;
301  template<>
302  struct adl_serializer<CreateRoomJob::Invite3pid> {
303 
304  static void to_json(json& jo, const CreateRoomJob::Invite3pid &pod)
305  {
306  if (! jo.is_object()) { jo = json::object(); }
307 
308 
309  jo["id_server"s] = pod.idServer;
310 
311  jo["id_access_token"s] = pod.idAccessToken;
312 
313  jo["medium"s] = pod.medium;
314 
315  jo["address"s] = pod.address;
316 
317  }
318 
319  static void from_json(const json &jo, CreateRoomJob::Invite3pid& result)
320  {
321 
322  if (jo.contains("id_server"s)) {
323  result.idServer = jo.at("id_server"s);
324  }
325  if (jo.contains("id_access_token"s)) {
326  result.idAccessToken = jo.at("id_access_token"s);
327  }
328  if (jo.contains("medium"s)) {
329  result.medium = jo.at("medium"s);
330  }
331  if (jo.contains("address"s)) {
332  result.address = jo.at("address"s);
333  }
334 
335  }
336 
337 };
338  template<>
339  struct adl_serializer<CreateRoomJob::StateEvent> {
340 
341  static void to_json(json& jo, const CreateRoomJob::StateEvent &pod)
342  {
343  if (! jo.is_object()) { jo = json::object(); }
344 
345 
346  jo["type"s] = pod.type;
347 
348  jo["content"s] = pod.content;
349 
350 
351  addToJsonIfNeeded(jo, "state_key"s, pod.stateKey);
352  }
353 
354  static void from_json(const json &jo, CreateRoomJob::StateEvent& result)
355  {
356 
357  if (jo.contains("type"s)) {
358  result.type = jo.at("type"s);
359  }
360  if (jo.contains("content"s)) {
361  result.content = jo.at("content"s);
362  }
363  if (jo.contains("state_key"s)) {
364  result.stateKey = jo.at("state_key"s);
365  }
366 
367  }
368 
369 };
370  }
371 
372  namespace Kazv::Api
373  {
374 
375 } // namespace Kazv::Api
Definition: create_room.hpp:171
std::string roomId() const
The created room's ID.
Definition: create_room.cpp:109
bool success() const
Definition: create_room.cpp:98
JobResponse(Response r)
Definition: create_room.cpp:95
Create a new room.
Definition: create_room.hpp:56
static BaseJob::Body buildBody(std::optional< std::string > visibility, std::optional< std::string > roomAliasName, std::optional< std::string > name, std::optional< std::string > topic, immer::array< std::string > invite, immer::array< Invite3pid > invite3pid, std::optional< std::string > roomVersion, JsonWrap creationContent, immer::array< StateEvent > initialState, std::optional< std::string > preset, std::optional< bool > isDirect, JsonWrap powerLevelContentOverride)
Definition: create_room.cpp:21
static BaseJob::Query buildQuery()
Definition: create_room.cpp:13
CreateRoomJob withData(JsonWrap j) &&
Definition: create_room.cpp:81
static constexpr auto needsAuth()
Definition: create_room.hpp:186
CreateRoomJob(std::string serverUrl, std::string _accessToken, std::optional< std::string > visibility=std::nullopt, std::optional< std::string > roomAliasName=std::nullopt, std::optional< std::string > name=std::nullopt, std::optional< std::string > topic=std::nullopt, immer::array< std::string > invite={}, immer::array< Invite3pid > invite3pid={}, std::optional< std::string > roomVersion=std::nullopt, JsonWrap creationContent={}, immer::array< StateEvent > initialState={}, std::optional< std::string > preset=std::nullopt, std::optional< bool > isDirect=std::nullopt, JsonWrap powerLevelContentOverride={})
Create a new room.
Definition: create_room.cpp:61
Definition: basejob.hpp:77
::Kazv::Body Body
Definition: basejob.hpp:100
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
Create a new room with various configuration options.
Definition: create_room.hpp:102
std::string medium
The kind of address being passed in the address field, for example email.
Definition: create_room.hpp:110
std::string idServer
The hostname+port of the identity server which should be used for third party identifier lookups.
Definition: create_room.hpp:104
std::string idAccessToken
An access token previously registered with the identity server.
Definition: create_room.hpp:108
std::string address
The invitee's third party identifier.
Definition: create_room.hpp:112
Create a new room with various configuration options.
Definition: create_room.hpp:158
std::optional< std::string > stateKey
The state_key of the state event. Defaults to an empty string.
Definition: create_room.hpp:164
JsonWrap content
The content of the event.
Definition: create_room.hpp:162
std::string type
The type of event to send.
Definition: create_room.hpp:160
Definition: basejob.hpp:50
static void from_json(const json &jo, CreateRoomJob::Invite3pid &result)
Definition: create_room.hpp:319
static void to_json(json &jo, const CreateRoomJob::Invite3pid &pod)
Definition: create_room.hpp:304
static void to_json(json &jo, const CreateRoomJob::StateEvent &pod)
Definition: create_room.hpp:341
static void from_json(const json &jo, CreateRoomJob::StateEvent &result)
Definition: create_room.hpp:354