libkazv
capabilities.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 
17 class GetCapabilitiesJob : public BaseJob {
18 public:
19  // Inner data structures
20 
23  {
25  bool enabled;
26 
27  };
28 
31  {
33  std::string defaultVersion;
35  immer::map<std::string, std::string> available;
36 
37  };
38 
41  struct Capabilities
42  {
44  std::optional<ChangePasswordCapability> changePassword;
46  std::optional<RoomVersionsCapability> roomVersions;
49  immer::map<std::string, JsonWrap> additionalProperties;
50  };
51 
52 
53 
54 class JobResponse : public Response
55 {
56 
57 public:
59  bool success() const;
60 
61  // Result properties
62 
63 
64 
65 
69 
70 };
71  static constexpr auto needsAuth() {
72  return true
73  ;
74  }
75 
76 
77 // Construction/destruction
78 
80  explicit GetCapabilitiesJob(std::string serverUrl
81  , std::string _accessToken
82 
83 
84  );
85 
86 
88  );
89 
90  static BaseJob::Body buildBody();
91 
92 
93 
94 
95 
98  };
100  }
101  namespace nlohmann
102  {
103  using namespace Kazv;
104  using namespace Kazv::Api;
105  template<>
106  struct adl_serializer<GetCapabilitiesJob::ChangePasswordCapability> {
107 
109  {
110  if (! jo.is_object()) { jo = json::object(); }
111 
112 
113  jo["enabled"s] = pod.enabled;
114 
115  }
116 
118  {
119 
120  if (jo.contains("enabled"s)) {
121  result.enabled = jo.at("enabled"s);
122  }
123 
124  }
125 
126 };
127  template<>
128  struct adl_serializer<GetCapabilitiesJob::RoomVersionsCapability> {
129 
131  {
132  if (! jo.is_object()) { jo = json::object(); }
133 
134 
135  jo["default"s] = pod.defaultVersion;
136 
137  jo["available"s] = pod.available;
138 
139  }
140 
142  {
143 
144  if (jo.contains("default"s)) {
145  result.defaultVersion = jo.at("default"s);
146  }
147  if (jo.contains("available"s)) {
148  result.available = jo.at("available"s);
149  }
150 
151  }
152 
153 };
154  template<>
155  struct adl_serializer<GetCapabilitiesJob::Capabilities> {
156 
157  static void to_json(json& jo, const GetCapabilitiesJob::Capabilities &pod)
158  {
159  if (! jo.is_object()) { jo = json::object(); }
160 
162 
163  addToJsonIfNeeded(jo, "m.change_password"s, pod.changePassword);
164 
165  addToJsonIfNeeded(jo, "m.room_versions"s, pod.roomVersions);
166  }
167 
168  static void from_json(const json &jo, GetCapabilitiesJob::Capabilities& result)
169  {
170 
171  if (jo.contains("m.change_password"s)) {
172  result.changePassword = jo.at("m.change_password"s);
173  }
174  if (jo.contains("m.room_versions"s)) {
175  result.roomVersions = jo.at("m.room_versions"s);
176  }
177  result.additionalProperties = jo;
178  }
179 
180 };
181  }
182 
183  namespace Kazv::Api
184  {
185 
186 } // namespace Kazv::Api
Definition: capabilities.hpp:55
JobResponse(Response r)
Definition: capabilities.cpp:67
bool success() const
Definition: capabilities.cpp:70
Capabilities capabilities() const
The custom capabilities the server supports, using the Java package naming convention.
Definition: capabilities.cpp:81
Gets information about the server's capabilities.
Definition: capabilities.hpp:17
GetCapabilitiesJob withData(JsonWrap j) &&
Definition: capabilities.cpp:53
GetCapabilitiesJob(std::string serverUrl, std::string _accessToken)
Gets information about the server's capabilities.
Definition: capabilities.cpp:33
static BaseJob::Body buildBody()
Definition: capabilities.cpp:21
static constexpr auto needsAuth()
Definition: capabilities.hpp:71
static BaseJob::Query buildQuery()
Definition: capabilities.cpp:13
Definition: basejob.hpp:91
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
void addPropertyMapToJson(json &j, MapT &&arg)
Definition: types.hpp:91
nlohmann::json json
Definition: jsonwrap.hpp:20
Definition: location.hpp:27
The custom capabilities the server supports, using the Java package naming convention.
Definition: capabilities.hpp:42
immer::map< std::string, JsonWrap > additionalProperties
The custom capabilities the server supports, using the Java package naming convention.
Definition: capabilities.hpp:49
std::optional< ChangePasswordCapability > changePassword
Capability to indicate if the user can change their password.
Definition: capabilities.hpp:44
std::optional< RoomVersionsCapability > roomVersions
The room versions the server supports.
Definition: capabilities.hpp:46
Capability to indicate if the user can change their password.
Definition: capabilities.hpp:23
bool enabled
True if the user can change their password, false otherwise.
Definition: capabilities.hpp:25
The room versions the server supports.
Definition: capabilities.hpp:31
immer::map< std::string, std::string > available
A detailed description of the room versions the server supports.
Definition: capabilities.hpp:35
std::string defaultVersion
The default room version the server is using for new rooms.
Definition: capabilities.hpp:33
Definition: basejob.hpp:50
static void from_json(const json &jo, GetCapabilitiesJob::Capabilities &result)
Definition: capabilities.hpp:168
static void to_json(json &jo, const GetCapabilitiesJob::Capabilities &pod)
Definition: capabilities.hpp:157
static void to_json(json &jo, const GetCapabilitiesJob::ChangePasswordCapability &pod)
Definition: capabilities.hpp:108
static void from_json(const json &jo, GetCapabilitiesJob::ChangePasswordCapability &result)
Definition: capabilities.hpp:117
static void to_json(json &jo, const GetCapabilitiesJob::RoomVersionsCapability &pod)
Definition: capabilities.hpp:130
static void from_json(const json &jo, GetCapabilitiesJob::RoomVersionsCapability &result)
Definition: capabilities.hpp:141