1/******************************************************************************
2 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
3 */
4
5#pragma once
6
7#include <Quotient/jobs/basejob.h>
8
9namespace Quotient {
10
11/*! \brief Gets information about the server's capabilities.
12 *
13 * Gets information about the server's supported feature set
14 * and other relevant capabilities.
15 */
16class QUOTIENT_API GetCapabilitiesJob : public BaseJob {
17public:
18 // Inner data structures
19
20 /// Capability to indicate if the user can change their password.
21 struct ChangePasswordCapability {
22 /// True if the user can change their password, false otherwise.
23 bool enabled;
24 };
25
26 /// The room versions the server supports.
27 struct RoomVersionsCapability {
28 /// The default room version the server is using for new rooms.
29 QString defaultVersion;
30 /// A detailed description of the room versions the server supports.
31 QHash<QString, QString> available;
32 };
33
34 /// The custom capabilities the server supports, using the
35 /// Java package naming convention.
36 struct Capabilities {
37 /// Capability to indicate if the user can change their password.
38 Omittable<ChangePasswordCapability> changePassword{};
39 /// The room versions the server supports.
40 Omittable<RoomVersionsCapability> roomVersions{};
41 /// The custom capabilities the server supports, using the
42 /// Java package naming convention.
43 QHash<QString, QJsonObject> additionalProperties{};
44 };
45
46 // Construction/destruction
47
48 /// Gets information about the server's capabilities.
49 explicit GetCapabilitiesJob();
50
51 /*! \brief Construct a URL without creating a full-fledged job object
52 *
53 * This function can be used when a URL for GetCapabilitiesJob
54 * is necessary but the job itself isn't.
55 */
56 static QUrl makeRequestUrl(QUrl baseUrl);
57
58 // Result properties
59
60 /// The custom capabilities the server supports, using the
61 /// Java package naming convention.
62 Capabilities capabilities() const
63 {
64 return loadFromJson<Capabilities>(keyName: "capabilities"_ls);
65 }
66};
67
68template <>
69struct JsonObjectConverter<GetCapabilitiesJob::ChangePasswordCapability> {
70 static void fillFrom(const QJsonObject& jo,
71 GetCapabilitiesJob::ChangePasswordCapability& result)
72 {
73 fillFromJson(jv: jo.value(key: "enabled"_ls), pod&: result.enabled);
74 }
75};
76
77template <>
78struct JsonObjectConverter<GetCapabilitiesJob::RoomVersionsCapability> {
79 static void fillFrom(const QJsonObject& jo,
80 GetCapabilitiesJob::RoomVersionsCapability& result)
81 {
82 fillFromJson(jv: jo.value(key: "default"_ls), pod&: result.defaultVersion);
83 fillFromJson(jv: jo.value(key: "available"_ls), pod&: result.available);
84 }
85};
86
87template <>
88struct JsonObjectConverter<GetCapabilitiesJob::Capabilities> {
89 static void fillFrom(QJsonObject jo,
90 GetCapabilitiesJob::Capabilities& result)
91 {
92 fillFromJson(jv: jo.take(key: "m.change_password"_ls), pod&: result.changePassword);
93 fillFromJson(jv: jo.take(key: "m.room_versions"_ls), pod&: result.roomVersions);
94 fromJson(json: jo, pod&: result.additionalProperties);
95 }
96};
97
98} // namespace Quotient
99