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 
26  struct PaginationChunk
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
Kazv::Api::RoomInitialSyncJob::buildQuery
static BaseJob::Query buildQuery()
Definition: room_initial_sync.cpp:15
nlohmann::adl_serializer< RoomInitialSyncJob::PaginationChunk >::to_json
static void to_json(json &jo, const RoomInitialSyncJob::PaginationChunk &pod)
Definition: room_initial_sync.hpp:131
Kazv::Api::RoomInitialSyncJob::JobResponse::visibility
std::optional< std::string > visibility() const
Whether this room is visible to the /publicRooms API or not.
Definition: room_initial_sync.cpp:127
Kazv::Api::RoomInitialSyncJob::PaginationChunk::end
std::string end
A token which correlates to the end of chunk.
Definition: room_initial_sync.hpp:37
nlohmann
Definition: location.hpp:26
Kazv::Api::RoomInitialSyncJob::JobResponse::state
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:116
Kazv::Api::RoomInitialSyncJob::RoomInitialSyncJob
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:35
Kazv::Api::RoomInitialSyncJob::JobResponse::membership
std::optional< std::string > membership() const
The user's membership state in this room.
Definition: room_initial_sync.cpp:94
Kazv
Definition: location.hpp:10
Kazv::Api::RoomInitialSyncJob::JobResponse::accountData
EventList accountData() const
The private data that this user has attached to this room.
Definition: room_initial_sync.cpp:138
Kazv::BaseJob::Query
Definition: basejob.hpp:90
Kazv::Api::RoomInitialSyncJob::PaginationChunk
The pagination chunk for this room.
Definition: room_initial_sync.hpp:30
nlohmann::adl_serializer< RoomInitialSyncJob::PaginationChunk >::from_json
static void from_json(const json &jo, RoomInitialSyncJob::PaginationChunk &result)
Definition: room_initial_sync.hpp:144
Kazv::Api::RoomInitialSyncJob::buildBody
static BaseJob::Body buildBody(std::string roomId)
Definition: room_initial_sync.cpp:23
Kazv::Api::RoomInitialSyncJob::PaginationChunk::chunk
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:43
Kazv::Api::RoomInitialSyncJob::JobResponse::success
bool success() const
Definition: room_initial_sync.cpp:72
Kazv::Api::RoomInitialSyncJob::JobResponse::JobResponse
JobResponse(Response r)
Definition: room_initial_sync.cpp:69
Kazv::json
nlohmann::json json
Definition: jsonwrap.hpp:20
Kazv::Api
Definition: location.hpp:10
Kazv::Api::RoomInitialSyncJob::JobResponse::roomId
std::string roomId() const
The ID of this room.
Definition: room_initial_sync.cpp:83
Kazv::Api::RoomInitialSyncJob::withData
RoomInitialSyncJob withData(JsonWrap j) &&
Definition: room_initial_sync.cpp:55
Kazv::addToJsonIfNeeded
void addToJsonIfNeeded(json &j, std::string name, T &&arg)
Definition: types.hpp:80
basejob.hpp
Kazv::Api::RoomInitialSyncJob::PaginationChunk::start
std::optional< std::string > start
A token which correlates to the start of chunk.
Definition: room_initial_sync.hpp:50
Kazv::JsonWrap
Definition: jsonwrap.hpp:22
Kazv::Api::RoomInitialSyncJob
Snapshot the current state of a room and its most recent messages.
Definition: room_initial_sync.hpp:23
Kazv::Api::RoomInitialSyncJob::JobResponse
Definition: room_initial_sync.hpp:54
Kazv::BaseJob::Body
::Kazv::Body Body
Definition: basejob.hpp:100
Kazv::Api::RoomInitialSyncJob::needsAuth
static constexpr auto needsAuth()
Definition: room_initial_sync.hpp:94
Kazv::EventList
immer::flex_vector< Event > EventList
Definition: types.hpp:107
Kazv::Response
Definition: basejob.hpp:50
Kazv::Api::RoomInitialSyncJob::JobResponse::messages
std::optional< PaginationChunk > messages() const
The pagination chunk for this room.
Definition: room_initial_sync.cpp:105