1 | /****************************************************************************** |
2 | * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN |
3 | */ |
4 | |
5 | #pragma once |
6 | |
7 | #include <Quotient/csapi/definitions/public_rooms_response.h> |
8 | |
9 | #include <Quotient/jobs/basejob.h> |
10 | |
11 | namespace Quotient { |
12 | |
13 | /*! \brief Gets the visibility of a room in the directory |
14 | * |
15 | * Gets the visibility of a given room on the server's public room directory. |
16 | */ |
17 | class QUOTIENT_API GetRoomVisibilityOnDirectoryJob : public BaseJob { |
18 | public: |
19 | /*! \brief Gets the visibility of a room in the directory |
20 | * |
21 | * \param roomId |
22 | * The room ID. |
23 | */ |
24 | explicit GetRoomVisibilityOnDirectoryJob(const QString& roomId); |
25 | |
26 | /*! \brief Construct a URL without creating a full-fledged job object |
27 | * |
28 | * This function can be used when a URL for GetRoomVisibilityOnDirectoryJob |
29 | * is necessary but the job itself isn't. |
30 | */ |
31 | static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); |
32 | |
33 | // Result properties |
34 | |
35 | /// The visibility of the room in the directory. |
36 | QString visibility() const |
37 | { |
38 | return loadFromJson<QString>(keyName: "visibility"_ls ); |
39 | } |
40 | }; |
41 | |
42 | /*! \brief Sets the visibility of a room in the room directory |
43 | * |
44 | * Sets the visibility of a given room in the server's public room |
45 | * directory. |
46 | * |
47 | * Servers may choose to implement additional access control checks |
48 | * here, for instance that room visibility can only be changed by |
49 | * the room creator or a server administrator. |
50 | */ |
51 | class QUOTIENT_API SetRoomVisibilityOnDirectoryJob : public BaseJob { |
52 | public: |
53 | /*! \brief Sets the visibility of a room in the room directory |
54 | * |
55 | * \param roomId |
56 | * The room ID. |
57 | * |
58 | * \param visibility |
59 | * The new visibility setting for the room. |
60 | * Defaults to 'public'. |
61 | */ |
62 | explicit SetRoomVisibilityOnDirectoryJob(const QString& roomId, |
63 | const QString& visibility = {}); |
64 | }; |
65 | |
66 | /*! \brief Lists the public rooms on the server. |
67 | * |
68 | * Lists the public rooms on the server. |
69 | * |
70 | * This API returns paginated responses. The rooms are ordered by the number |
71 | * of joined members, with the largest rooms first. |
72 | */ |
73 | class QUOTIENT_API GetPublicRoomsJob : public BaseJob { |
74 | public: |
75 | /*! \brief Lists the public rooms on the server. |
76 | * |
77 | * \param limit |
78 | * Limit the number of results returned. |
79 | * |
80 | * \param since |
81 | * A pagination token from a previous request, allowing clients to |
82 | * get the next (or previous) batch of rooms. |
83 | * The direction of pagination is specified solely by which token |
84 | * is supplied, rather than via an explicit flag. |
85 | * |
86 | * \param server |
87 | * The server to fetch the public room lists from. Defaults to the |
88 | * local server. |
89 | */ |
90 | explicit GetPublicRoomsJob(Omittable<int> limit = none, |
91 | const QString& since = {}, |
92 | const QString& server = {}); |
93 | |
94 | /*! \brief Construct a URL without creating a full-fledged job object |
95 | * |
96 | * This function can be used when a URL for GetPublicRoomsJob |
97 | * is necessary but the job itself isn't. |
98 | */ |
99 | static QUrl makeRequestUrl(QUrl baseUrl, Omittable<int> limit = none, |
100 | const QString& since = {}, |
101 | const QString& server = {}); |
102 | |
103 | // Result properties |
104 | |
105 | /// A paginated chunk of public rooms. |
106 | QVector<PublicRoomsChunk> chunk() const |
107 | { |
108 | return loadFromJson<QVector<PublicRoomsChunk>>(keyName: "chunk"_ls ); |
109 | } |
110 | |
111 | /// A pagination token for the response. The absence of this token |
112 | /// means there are no more results to fetch and the client should |
113 | /// stop paginating. |
114 | QString nextBatch() const { return loadFromJson<QString>(keyName: "next_batch"_ls ); } |
115 | |
116 | /// A pagination token that allows fetching previous results. The |
117 | /// absence of this token means there are no results before this |
118 | /// batch, i.e. this is the first batch. |
119 | QString prevBatch() const { return loadFromJson<QString>(keyName: "prev_batch"_ls ); } |
120 | |
121 | /// An estimate on the total number of public rooms, if the |
122 | /// server has an estimate. |
123 | Omittable<int> totalRoomCountEstimate() const |
124 | { |
125 | return loadFromJson<Omittable<int>>(keyName: "total_room_count_estimate"_ls ); |
126 | } |
127 | }; |
128 | |
129 | /*! \brief Lists the public rooms on the server with optional filter. |
130 | * |
131 | * Lists the public rooms on the server, with optional filter. |
132 | * |
133 | * This API returns paginated responses. The rooms are ordered by the number |
134 | * of joined members, with the largest rooms first. |
135 | */ |
136 | class QUOTIENT_API QueryPublicRoomsJob : public BaseJob { |
137 | public: |
138 | // Inner data structures |
139 | |
140 | /// Filter to apply to the results. |
141 | struct Filter { |
142 | /// An optional string to search for in the room metadata, e.g. name, |
143 | /// topic, canonical alias, etc. |
144 | QString genericSearchTerm{}; |
145 | /// An optional list of [room types](/client-server-api/#types) to |
146 | /// search for. To include rooms without a room type, specify `null` |
147 | /// within this list. When not specified, all applicable rooms |
148 | /// (regardless of type) are returned. |
149 | QStringList roomTypes{}; |
150 | }; |
151 | |
152 | // Construction/destruction |
153 | |
154 | /*! \brief Lists the public rooms on the server with optional filter. |
155 | * |
156 | * \param server |
157 | * The server to fetch the public room lists from. Defaults to the |
158 | * local server. |
159 | * |
160 | * \param limit |
161 | * Limit the number of results returned. |
162 | * |
163 | * \param since |
164 | * A pagination token from a previous request, allowing clients |
165 | * to get the next (or previous) batch of rooms. The direction |
166 | * of pagination is specified solely by which token is supplied, |
167 | * rather than via an explicit flag. |
168 | * |
169 | * \param filter |
170 | * Filter to apply to the results. |
171 | * |
172 | * \param includeAllNetworks |
173 | * Whether or not to include all known networks/protocols from |
174 | * application services on the homeserver. Defaults to false. |
175 | * |
176 | * \param thirdPartyInstanceId |
177 | * The specific third-party network/protocol to request from the |
178 | * homeserver. Can only be used if `include_all_networks` is false. |
179 | */ |
180 | explicit QueryPublicRoomsJob(const QString& server = {}, |
181 | Omittable<int> limit = none, |
182 | const QString& since = {}, |
183 | const Omittable<Filter>& filter = none, |
184 | Omittable<bool> includeAllNetworks = none, |
185 | const QString& thirdPartyInstanceId = {}); |
186 | |
187 | // Result properties |
188 | |
189 | /// A paginated chunk of public rooms. |
190 | QVector<PublicRoomsChunk> chunk() const |
191 | { |
192 | return loadFromJson<QVector<PublicRoomsChunk>>(keyName: "chunk"_ls ); |
193 | } |
194 | |
195 | /// A pagination token for the response. The absence of this token |
196 | /// means there are no more results to fetch and the client should |
197 | /// stop paginating. |
198 | QString nextBatch() const { return loadFromJson<QString>(keyName: "next_batch"_ls ); } |
199 | |
200 | /// A pagination token that allows fetching previous results. The |
201 | /// absence of this token means there are no results before this |
202 | /// batch, i.e. this is the first batch. |
203 | QString prevBatch() const { return loadFromJson<QString>(keyName: "prev_batch"_ls ); } |
204 | |
205 | /// An estimate on the total number of public rooms, if the |
206 | /// server has an estimate. |
207 | Omittable<int> totalRoomCountEstimate() const |
208 | { |
209 | return loadFromJson<Omittable<int>>(keyName: "total_room_count_estimate"_ls ); |
210 | } |
211 | }; |
212 | |
213 | template <> |
214 | struct JsonObjectConverter<QueryPublicRoomsJob::Filter> { |
215 | static void dumpTo(QJsonObject& jo, const QueryPublicRoomsJob::Filter& pod) |
216 | { |
217 | addParam<IfNotEmpty>(container&: jo, QStringLiteral("generic_search_term" ), |
218 | value: pod.genericSearchTerm); |
219 | addParam<IfNotEmpty>(container&: jo, QStringLiteral("room_types" ), value: pod.roomTypes); |
220 | } |
221 | }; |
222 | |
223 | } // namespace Quotient |
224 | |