libkazv
client_event_without_room_id.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 {
12 struct UnsignedData
13 {
14 
16  std::optional<std::int_fast64_t> age;
17 
20 
24  std::optional<std::string> transactionId;
25 
30 };
31 
32 }
33 namespace nlohmann
34 {
35 using namespace Kazv;
36 using namespace Kazv::Api;
37 template<>
38 struct adl_serializer<UnsignedData> {
39  static void to_json(json& jo, const UnsignedData &pod)
40  {
41  if (! jo.is_object()) { jo = json::object(); }
42 
43 
44 
45  addToJsonIfNeeded(jo, "age"s, pod.age);
46 
47  addToJsonIfNeeded(jo, "redacted_because"s, pod.redactedBecause);
48 
49  addToJsonIfNeeded(jo, "transaction_id"s, pod.transactionId);
50 
51  addToJsonIfNeeded(jo, "prev_content"s, pod.prevContent);
52  }
53  static void from_json(const json &jo, UnsignedData& result)
54  {
55 
56  if (jo.contains("age"s)) {
57  result.age = jo.at("age"s);
58  }
59  if (jo.contains("redacted_because"s)) {
60  result.redactedBecause = jo.at("redacted_because"s);
61  }
62  if (jo.contains("transaction_id"s)) {
63  result.transactionId = jo.at("transaction_id"s);
64  }
65  if (jo.contains("prev_content"s)) {
66  result.prevContent = jo.at("prev_content"s);
67  }
68 
69  }
70 };
71  }
72 
73  namespace Kazv::Api
74  {
79 {
80 
82  std::string eventId;
83 
85  std::string type;
86 
88  std::string sender;
89 
92  std::int_fast64_t originServerTs;
93 
96 
104  std::optional<std::string> stateKey;
105 
107  std::optional<UnsignedData> unsignedData;
108 };
109 
110 }
111 namespace nlohmann
112 {
113 using namespace Kazv;
114 using namespace Kazv::Api;
115 template<>
116 struct adl_serializer<ClientEventWithoutRoomID> {
117  static void to_json(json& jo, const ClientEventWithoutRoomID &pod)
118  {
119  if (! jo.is_object()) { jo = json::object(); }
120 
121 
122  jo["event_id"s] = pod.eventId;
123 
124  jo["type"s] = pod.type;
125 
126  jo["sender"s] = pod.sender;
127 
128  jo["origin_server_ts"s] = pod.originServerTs;
129 
130  jo["content"s] = pod.content;
131 
132 
133  addToJsonIfNeeded(jo, "state_key"s, pod.stateKey);
134 
135  addToJsonIfNeeded(jo, "unsigned"s, pod.unsignedData);
136  }
137  static void from_json(const json &jo, ClientEventWithoutRoomID& result)
138  {
139 
140  if (jo.contains("event_id"s)) {
141  result.eventId = jo.at("event_id"s);
142  }
143  if (jo.contains("type"s)) {
144  result.type = jo.at("type"s);
145  }
146  if (jo.contains("sender"s)) {
147  result.sender = jo.at("sender"s);
148  }
149  if (jo.contains("origin_server_ts"s)) {
150  result.originServerTs = jo.at("origin_server_ts"s);
151  }
152  if (jo.contains("content"s)) {
153  result.content = jo.at("content"s);
154  }
155  if (jo.contains("state_key"s)) {
156  result.stateKey = jo.at("state_key"s);
157  }
158  if (jo.contains("unsigned"s)) {
159  result.unsignedData = jo.at("unsigned"s);
160  }
161 
162  }
163 };
164  }
165 
166  namespace Kazv::Api
167  {
168 } // namespace Kazv::Api
nlohmann::adl_serializer< UnsignedData >::from_json
static void from_json(const json &jo, UnsignedData &result)
Definition: client_event_without_room_id.hpp:53
Kazv::Api::UnsignedData::age
std::optional< std::int_fast64_t > age
The time in milliseconds that has elapsed since the event was sent. This field is generated by the lo...
Definition: client_event_without_room_id.hpp:20
nlohmann::adl_serializer< UnsignedData >::to_json
static void to_json(json &jo, const UnsignedData &pod)
Definition: client_event_without_room_id.hpp:39
types.hpp
nlohmann
Definition: location.hpp:26
Kazv::Api::ClientEventWithoutRoomID::content
JsonWrap content
The body of this event, as created by the client which sent it.
Definition: client_event_without_room_id.hpp:95
Kazv
Definition: location.hpp:10
Kazv::Api::ClientEventWithoutRoomID::sender
std::string sender
Contains the fully-qualified ID of the user who sent this event.
Definition: client_event_without_room_id.hpp:88
nlohmann::adl_serializer< ClientEventWithoutRoomID >::from_json
static void from_json(const json &jo, ClientEventWithoutRoomID &result)
Definition: client_event_without_room_id.hpp:137
Kazv::Api::ClientEventWithoutRoomID
The format used for events when they are returned from API endpoints such as /sync,...
Definition: client_event_without_room_id.hpp:78
Kazv::Api::ClientEventWithoutRoomID::eventId
std::string eventId
The globally unique identifier for this event.
Definition: client_event_without_room_id.hpp:82
Kazv::json
nlohmann::json json
Definition: jsonwrap.hpp:20
Kazv::Api::UnsignedData::redactedBecause
JsonWrap redactedBecause
The event that redacted this event, if any.
Definition: client_event_without_room_id.hpp:23
Kazv::Api
Definition: location.hpp:10
Kazv::Api::UnsignedData::transactionId
std::optional< std::string > transactionId
The client-supplied transaction ID, for example, provided via PUT /_matrix/client/v3/rooms/{roomId}/s...
Definition: client_event_without_room_id.hpp:28
Kazv::Api::ClientEventWithoutRoomID::stateKey
std::optional< std::string > stateKey
Present if, and only if, this event is a state event.
Definition: client_event_without_room_id.hpp:104
Kazv::Api::UnsignedData
Contains optional extra information about the event.
Definition: client_event_without_room_id.hpp:14
Kazv::addToJsonIfNeeded
void addToJsonIfNeeded(json &j, std::string name, T &&arg)
Definition: types.hpp:80
Kazv::JsonWrap
Definition: jsonwrap.hpp:22
Kazv::Api::UnsignedData::prevContent
JsonWrap prevContent
The previous content for this event.
Definition: client_event_without_room_id.hpp:33
Kazv::Api::ClientEventWithoutRoomID::originServerTs
std::int_fast64_t originServerTs
Timestamp (in milliseconds since the unix epoch) on originating homeserver when this event was sent.
Definition: client_event_without_room_id.hpp:92
nlohmann::adl_serializer< ClientEventWithoutRoomID >::to_json
static void to_json(json &jo, const ClientEventWithoutRoomID &pod)
Definition: client_event_without_room_id.hpp:117
Kazv::Api::ClientEventWithoutRoomID::type
std::string type
The type of the event.
Definition: client_event_without_room_id.hpp:85
Kazv::Api::ClientEventWithoutRoomID::unsignedData
std::optional< UnsignedData > unsignedData
Contains optional extra information about the event.
Definition: client_event_without_room_id.hpp:107