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  };
295  using CreateRoomResponse = CreateRoomJob::JobResponse;
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
Kazv::Api::CreateRoomJob::Invite3pid::address
std::string address
The invitee's third party identifier.
Definition: create_room.hpp:118
Kazv::Api::CreateRoomJob::StateEvent::type
std::string type
The type of event to send.
Definition: create_room.hpp:164
Kazv::Api::CreateRoomJob::JobResponse::roomId
std::string roomId() const
The created room's ID.
Definition: create_room.cpp:111
nlohmann::adl_serializer< CreateRoomJob::Invite3pid >::from_json
static void from_json(const json &jo, CreateRoomJob::Invite3pid &result)
Definition: create_room.hpp:319
Kazv::Api::CreateRoomJob::CreateRoomJob
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:63
nlohmann
Definition: location.hpp:26
Kazv::Api::CreateRoomJob::Invite3pid::medium
std::string medium
The kind of address being passed in the address field, for example email.
Definition: create_room.hpp:116
Kazv
Definition: location.hpp:10
Kazv::Api::CreateRoomJob::Invite3pid
Create a new room with various configuration options.
Definition: create_room.hpp:105
nlohmann::adl_serializer< CreateRoomJob::StateEvent >::from_json
static void from_json(const json &jo, CreateRoomJob::StateEvent &result)
Definition: create_room.hpp:354
Kazv::Api::CreateRoomJob::buildQuery
static BaseJob::Query buildQuery()
Definition: create_room.cpp:15
Kazv::Api::CreateRoomJob::StateEvent::stateKey
std::optional< std::string > stateKey
The state_key of the state event. Defaults to an empty string.
Definition: create_room.hpp:168
Kazv::Api::CreateRoomJob::JobResponse::success
bool success() const
Definition: create_room.cpp:100
Kazv::Api::CreateRoomJob::JobResponse
Definition: create_room.hpp:174
Kazv::Api::CreateRoomJob::JobResponse::JobResponse
JobResponse(Response r)
Definition: create_room.cpp:97
Kazv::Api::CreateRoomJob::Invite3pid::idAccessToken
std::string idAccessToken
An access token previously registered with the identity server.
Definition: create_room.hpp:114
Kazv::json
nlohmann::json json
Definition: jsonwrap.hpp:20
Kazv::Api
Definition: location.hpp:10
Kazv::Api::CreateRoomJob::buildBody
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:23
Kazv::Api::CreateRoomJob::withData
CreateRoomJob withData(JsonWrap j) &&
Definition: create_room.cpp:83
Kazv::Api::CreateRoomJob::StateEvent::content
JsonWrap content
The content of the event.
Definition: create_room.hpp:166
Kazv::addToJsonIfNeeded
void addToJsonIfNeeded(json &j, std::string name, T &&arg)
Definition: types.hpp:69
basejob.hpp
Kazv::JsonWrap
Definition: jsonwrap.hpp:22
Kazv::Api::CreateRoomJob::Invite3pid::idServer
std::string idServer
The hostname+port of the identity server which should be used for third party identifier lookups.
Definition: create_room.hpp:110
Kazv::BaseJob::Body
::Kazv::Body Body
Definition: basejob.hpp:100
nlohmann::adl_serializer< CreateRoomJob::StateEvent >::to_json
static void to_json(json &jo, const CreateRoomJob::StateEvent &pod)
Definition: create_room.hpp:341
Kazv::Api::CreateRoomJob::needsAuth
static constexpr auto needsAuth()
Definition: create_room.hpp:190
Kazv::Api::CreateRoomJob
Create a new room.
Definition: create_room.hpp:58
nlohmann::adl_serializer< CreateRoomJob::Invite3pid >::to_json
static void to_json(json &jo, const CreateRoomJob::Invite3pid &pod)
Definition: create_room.hpp:304
Kazv::Response
Definition: basejob.hpp:50
Kazv::Api::CreateRoomJob::StateEvent
Create a new room with various configuration options.
Definition: create_room.hpp:161
Kazv::Api::CreateRoomResponse
CreateRoomJob::JobResponse CreateRoomResponse
Definition: create_room.hpp:297