libkazv
public_rooms_response.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 "types.hpp"
8 
9 
10 namespace Kazv::Api {
11 
13 {
14 
17 
19  std::string roomId;
20 
23 
28 
30  std::optional<std::string> canonicalAlias;
31 
33  std::optional<std::string> name;
34 
36  std::optional<std::string> topic;
37 
39  std::optional<std::string> avatarUrl;
40 
45  std::optional<std::string> joinRule;
46 };
47 
48 }
49 namespace nlohmann
50 {
51 using namespace Kazv;
52 using namespace Kazv::Api;
53 template<>
54 struct adl_serializer<PublicRoomsChunk> {
55  static void to_json(json& jo, const PublicRoomsChunk &pod)
56  {
57  if (! jo.is_object()) { jo = json::object(); }
58 
59 
60  jo["num_joined_members"s] = pod.numJoinedMembers;
61 
62  jo["room_id"s] = pod.roomId;
63 
64  jo["world_readable"s] = pod.worldReadable;
65 
66  jo["guest_can_join"s] = pod.guestCanJoin;
67 
68 
69  addToJsonIfNeeded(jo, "canonical_alias"s, pod.canonicalAlias);
70 
71  addToJsonIfNeeded(jo, "name"s, pod.name);
72 
73  addToJsonIfNeeded(jo, "topic"s, pod.topic);
74 
75  addToJsonIfNeeded(jo, "avatar_url"s, pod.avatarUrl);
76 
77  addToJsonIfNeeded(jo, "join_rule"s, pod.joinRule);
78  }
79  static void from_json(const json &jo, PublicRoomsChunk& result)
80  {
81 
82  if (jo.contains("num_joined_members"s)) {
83  result.numJoinedMembers = jo.at("num_joined_members"s);
84  }
85  if (jo.contains("room_id"s)) {
86  result.roomId = jo.at("room_id"s);
87  }
88  if (jo.contains("world_readable"s)) {
89  result.worldReadable = jo.at("world_readable"s);
90  }
91  if (jo.contains("guest_can_join"s)) {
92  result.guestCanJoin = jo.at("guest_can_join"s);
93  }
94  if (jo.contains("canonical_alias"s)) {
95  result.canonicalAlias = jo.at("canonical_alias"s);
96  }
97  if (jo.contains("name"s)) {
98  result.name = jo.at("name"s);
99  }
100  if (jo.contains("topic"s)) {
101  result.topic = jo.at("topic"s);
102  }
103  if (jo.contains("avatar_url"s)) {
104  result.avatarUrl = jo.at("avatar_url"s);
105  }
106  if (jo.contains("join_rule"s)) {
107  result.joinRule = jo.at("join_rule"s);
108  }
109 
110  }
111 };
112  }
113 
114  namespace Kazv::Api
115  {
116 } // namespace Kazv::Api
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
Definition: public_rooms_response.hpp:13
std::optional< std::string > avatarUrl
The URL for the room's avatar, if one is set.
Definition: public_rooms_response.hpp:39
std::optional< std::string > name
The name of the room, if any.
Definition: public_rooms_response.hpp:33
bool worldReadable
Whether the room may be viewed by guest users without joining.
Definition: public_rooms_response.hpp:22
int numJoinedMembers
The number of members joined to the room.
Definition: public_rooms_response.hpp:16
std::optional< std::string > joinRule
The room's join rule.
Definition: public_rooms_response.hpp:45
bool guestCanJoin
Whether guest users may join the room and participate in it.
Definition: public_rooms_response.hpp:27
std::optional< std::string > topic
The topic of the room, if any.
Definition: public_rooms_response.hpp:36
std::optional< std::string > canonicalAlias
The canonical alias of the room, if any.
Definition: public_rooms_response.hpp:30
std::string roomId
The ID of the room.
Definition: public_rooms_response.hpp:19
static void from_json(const json &jo, PublicRoomsChunk &result)
Definition: public_rooms_response.hpp:79
static void to_json(json &jo, const PublicRoomsChunk &pod)
Definition: public_rooms_response.hpp:55