libkazv
room_initial_sync.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 
21 class RoomInitialSyncJob : public BaseJob {
22 public:
23  // Inner data structures
24 
27  {
31  std::string end;
44  std::optional<std::string> start;
45 
46  };
47 
48 
49 
50 class JobResponse : public Response
51 {
52 
53 public:
55  bool success() const;
56 
57  // Result properties
58 
59 
60 
61 
63 std::string roomId() const;
64 
65 
67 std::optional<std::string> membership() const;
68 
69 
71 std::optional<PaginationChunk> messages() const;
72 
73 
78 EventList state() const;
79 
80 
83 std::optional<std::string> visibility() const;
84 
85 
87 EventList accountData() const;
88 
89 };
90  static constexpr auto needsAuth() {
91  return true
92  ;
93  }
94 
95 
96 // Construction/destruction
97 
103  explicit RoomInitialSyncJob(std::string serverUrl
104  , std::string _accessToken
105  ,
106  std::string roomId
107  );
108 
109 
110  static BaseJob::Query buildQuery(
111  );
112 
113  static BaseJob::Body buildBody(std::string roomId);
114 
115 
116 
117 
118 
121  };
123  }
124  namespace nlohmann
125  {
126  using namespace Kazv;
127  using namespace Kazv::Api;
128  template<>
129  struct adl_serializer<RoomInitialSyncJob::PaginationChunk> {
130 
131  static void to_json(json& jo, const RoomInitialSyncJob::PaginationChunk &pod)
132  {
133  if (! jo.is_object()) { jo = json::object(); }
134 
135 
136  jo["end"s] = pod.end;
137 
138  jo["chunk"s] = pod.chunk;
139 
140 
141  addToJsonIfNeeded(jo, "start"s, pod.start);
142  }
143 
144  static void from_json(const json &jo, RoomInitialSyncJob::PaginationChunk& result)
145  {
146 
147  if (jo.contains("end"s)) {
148  result.end = jo.at("end"s);
149  }
150  if (jo.contains("chunk"s)) {
151  result.chunk = jo.at("chunk"s);
152  }
153  if (jo.contains("start"s)) {
154  result.start = jo.at("start"s);
155  }
156 
157  }
158 
159 };
160  }
161 
162  namespace Kazv::Api
163  {
164 
165 } // namespace Kazv::Api
Definition: room_initial_sync.hpp:51
EventList accountData() const
The private data that this user has attached to this room.
Definition: room_initial_sync.cpp:136
std::optional< PaginationChunk > messages() const
The pagination chunk for this room.
Definition: room_initial_sync.cpp:103
EventList state() const
If the user is a member of the room this will be the current state of the room as a list of events.
Definition: room_initial_sync.cpp:114
bool success() const
Definition: room_initial_sync.cpp:70
JobResponse(Response r)
Definition: room_initial_sync.cpp:67
std::optional< std::string > visibility() const
Whether this room is visible to the /publicRooms API or not.
Definition: room_initial_sync.cpp:125
std::optional< std::string > membership() const
The user's membership state in this room.
Definition: room_initial_sync.cpp:92
std::string roomId() const
The ID of this room.
Definition: room_initial_sync.cpp:81
Snapshot the current state of a room and its most recent messages.
Definition: room_initial_sync.hpp:21
static constexpr auto needsAuth()
Definition: room_initial_sync.hpp:90
static BaseJob::Query buildQuery()
Definition: room_initial_sync.cpp:13
static BaseJob::Body buildBody(std::string roomId)
Definition: room_initial_sync.cpp:21
RoomInitialSyncJob(std::string serverUrl, std::string _accessToken, std::string roomId)
Snapshot the current state of a room and its most recent messages.
Definition: room_initial_sync.cpp:33
RoomInitialSyncJob withData(JsonWrap j) &&
Definition: room_initial_sync.cpp:53
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
nlohmann::json json
Definition: jsonwrap.hpp:20
immer::flex_vector< Event > EventList
Definition: types.hpp:107
Definition: location.hpp:27
The pagination chunk for this room.
Definition: room_initial_sync.hpp:27
EventList chunk
If the user is a member of the room this will be a list of the most recent messages for this room.
Definition: room_initial_sync.hpp:37
std::optional< std::string > start
A token which correlates to the start of chunk.
Definition: room_initial_sync.hpp:44
std::string end
A token which correlates to the end of chunk.
Definition: room_initial_sync.hpp:31
Definition: basejob.hpp:50
static void to_json(json &jo, const RoomInitialSyncJob::PaginationChunk &pod)
Definition: room_initial_sync.hpp:131
static void from_json(const json &jo, RoomInitialSyncJob::PaginationChunk &result)
Definition: room_initial_sync.hpp:144