Page MenuHomePhorge

No OneTemporary

Authored By
Unknown
Size
536 KB
Referenced Files
None
Subscribers
None
This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/gtad/data.hpp.mustache b/gtad/data.hpp.mustache
index 6e933e9..c4885d9 100644
--- a/gtad/data.hpp.mustache
+++ b/gtad/data.hpp.mustache
@@ -1,57 +1,66 @@
{{>preamble}}
#pragma once
#include "types.hpp"
{{#imports}}
#include {{_}}{{/imports}}
namespace Kazv {
{{#models}}
{{#model}}
{{>docCommentShort}}
struct {{name}}{{#parents?}} : {{#parents}}{{name}}{{>cjoin}}{{/parents}}{{/parents?}}
{ {{#vars}}
{{>docCommentShort}}
{{>maybeOmittableType}} {{nameCamelCase}};
{{/vars}}{{#propertyMap}}
{{>docCommentShort}}
{{>maybeOmittableType}} {{nameCamelCase}};
{{/propertyMap}}
};
-
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<{{qualifiedName}}> {
{{#in?}}
- inline void to_json(json& jo, const {{qualifiedName}} &pod)
+ static void to_json(json& jo, const {{qualifiedName}} &pod)
{
{{#parents}}{{!assume no more one parent}}
- nlohmann::to_json(jo, static_cast<const {{name}} &>(pod));
+ jo = static_cast<const {{name}} &>(pod);
{{/parents}}
{{#propertyMap}}
addPropertyMapToJson(jo, pod.{{nameCamelCase}});
{{/propertyMap}}
{{#vars}}
{{#required?}}jo["{{baseName}}"s] = pod.{{nameCamelCase}};{{/required?}}
{{^required?}}addToJsonIfNeeded(jo, "{{baseName}}"s, pod.{{nameCamelCase}});{{/required?}}
{{/vars}}
}
{{/in?}}
{{#out?}}
- inline void from_json({{>maybeCrefJsonObject}} jo, {{qualifiedName}}& result)
+ static void from_json(const json &jo, {{qualifiedName}}& result)
{
{{#parents}}
- nlohmann::from_json(static_cast<const {{name}} &{{!of the parent!}}>(result), result);
+ static_cast<{{name}} &{{!of the parent!}}>(result) = jo;
{{/parents}}
{{#vars}}
result.{{nameCamelCase}} = jo.at("{{baseName}}"s);
{{/vars}}
{{#propertyMap}}
- from_json(jo, result.{{nameCamelCase}});
+ result.{{nameCamelCase}} = jo;
{{/propertyMap}}
}
{{/out?}}
+};
+ }
+ namespace Kazv
+ {
{{/model}}
{{/models}}
-} // namespace Quotient
+} // namespace Kazv
diff --git a/gtad/gtad.yaml b/gtad/gtad.yaml
index 3a4c482..4d86399 100644
--- a/gtad/gtad.yaml
+++ b/gtad/gtad.yaml
@@ -1,197 +1,206 @@
analyzer:
subst:
"%CLIENT_RELEASE_LABEL%": r0
"%CLIENT_MAJOR_VERSION%": r0
identifiers:
signed: signedData
unsigned: unsignedData
PushRule/default: isDefault
default: defaultVersion # getCapabilities/RoomVersionsCapability
m.upload.size: uploadSize
m.homeserver: homeserver
m.identity_server: identityServer
m.change_password: changePassword
m.room_versions: roomVersions
AuthenticationData/additionalProperties: authInfo
/^/(Location|Protocol|User)$/: 'ThirdParty$1'
# These parameters are deprecated and unused in Quotient; so drop them
login>/user: ""
login>/medium: ""
login>/address: ""
# Structure inside `types`:
# - swaggerType: <targetTypeSpec>
# OR
# - swaggerType:
# - swaggerFormat: <targetTypeSpec>
# - /swaggerFormatRegEx/: <targetTypeSpec>
# - //: <targetTypeSpec> # default, if the format doesn't mach anything above
# WHERE
# targetTypeSpec = targetType OR
# { type: targetType, imports: <filename OR [ filenames... ]>, <other attributes...> }
# swaggerType can be +set/+on pair; attributes from the map under +set
# are added to each type from the sequence under +on.
types:
- +set: &UseOmittable
useOmittable:
omittedValue: 'std::nullopt' # Quotient::none in lib/util.h
+on:
- integer:
- int64: std::int_fast64_t
- int32: std::int_fast32_t
- //: int
- number:
- float: float
- //: double
- boolean: bool
- string:
- byte: &ByteStream
type: Bytes
imports: "types.hpp"
- binary: *ByteStream
- date:
type: boost::date
initializer: boost::from_string("{{defaultValue}}")
imports: "boost/date_time/gregorian/gregorian_types.hpp"
- dateTime:
type: boost::ptime
initializer: boost::time_from_string("{{defaultValue}}")
imports: "boost/date_time/posix_time/posix_time_types.hpp"
- //: &String
type: std::string
initializer: std::string("{{defaultValue}}")
isString:
- file: *ByteStream
- - object: &Json { type: JsonWrap }
+ - object: &Json { type: JsonWrap, initializer: json::object() }
- $ref:
- - /state_event.yaml$/:
- { type: StateEvent, imports: "events/eventloader.h" }
- - /room_event.yaml$/:
- { type: RoomEvent, imports: "events/eventloader.h" }
- - /event.yaml$/:
- { type: Event, imports: "events/eventloader.h" }
- - /m\.room\.member$/: void # Skip resolving; see EventsArray<> below
+ - /event.yaml$/: *Json
+ - /timeline_batch.yaml/:
+ title: Timeline
+# type: JsonWrap
+# - /state_event.yaml$/:
+# { type: StateEvent, imports: "events/eventloader.h" }
+# - /room_event.yaml$/:
+# { type: RoomEvent, imports: "events/eventloader.h" }
+# - /event.yaml$/:
+# { type: Event, imports: "events/eventloader.h" }
+# - /m\.room\.member$/: void # Skip resolving; see EventsArray<> below
- '/^(\./)?definitions/request_email_validation.yaml$/':
title: EmailValidationData
- '/^(\./)?definitions/request_msisdn_validation.yaml$/':
title: MsisdnValidationData
- /_filter.yaml$/: # Event/RoomEventFilters do NOT need Omittable<>
- /public_rooms_response.yaml$/: { _inline: true }
- //: *UseOmittable # Also apply "avoidCopy" to all other ref'ed types
- schema:
- getTurnServer<: *Json # It's used as an opaque JSON object
- PublicRoomResponse: { _inline: true }
- defineFilter>: &Filter # Force folding into a structure
# type: Filter
# imports: "csapi/definitions/sync_filter.h"
# - getFilter<: *Filter
- RoomFilter: # A structure inside Filter, same story as with *_filter.yaml
- //: *UseOmittable
- array:
- string: immer::array<std::string>
- /^Notification|Result$/:
type: "immer::array<{{1}}>"
- imports: "events/eventloader.h"
- - /m\.room\.member$/: # Only used in an array (see also above)
- type: "immer::array<RoomMemberEvent>"
- imports: "events/roommemberevent.h"
- - /state_event.yaml$/: StateEvents
- - /room_event.yaml$/: RoomEvents
- - /event.yaml$/: Events
+# imports: "events/eventloader.h"
+# - /m\.room\.member$/: # Only used in an array (see also above)
+# type: "immer::array<RoomMemberEvent>"
+# imports: "events/roommemberevent.h"
+# - /state_event.yaml$/: StateEvents
+# - /room_event.yaml$/: RoomEvents
+ - /event.yaml$/: EventList
- //: "immer::array<{{1}}>"
- map: # `additionalProperties` in OpenAPI
- RoomState:
type: "immer::map<std::string, {{1}}>"
- /.+/: "immer::map<std::string, {{1}}>"
- - //: immer::map<std::string, Variant>
+ - //: *Json # `additionalProperties: true` in OpenAPI
+# type: "immer::map<std::string, std::variant<{{#types}}{{name}}{{#_join}}, {{/_join}}{{/types}}>>"
+# imports: <variant>
- variant: # A sequence `type` (multitype) in OpenAPI
- - /^string,null|null,string$/: *String
+# - /^string,null|null,string$/:
+# type: "std::variant<std::string, std::nullptr_t>"
+# imports: <variant>
- //:
- type: "std::variant<{{#types}}{{_}}{{#_join}}, {{/_join}}{{/types}}>"
- imports: <variant>Variant
+ type: Variant
+# type: "std::variant<{{#types}}{{name}}{{#_join}}, {{/_join}}{{/types}}>"
+# imports: <variant>
#operations:
mustache:
constants:
# Syntax elements used by GTAD
# _quote: '"' # Common quote for left and right
# _leftQuote: '"'
# _rightQuote: '"'
# _joinChar: ',' # The character used by {{_join}} - not working yet
_comment: '//'
copyrightName: Kitsune Ral
copyrightEmail: <kitsune-ral@users.sf.net>
partials:
_typeRenderer: "{{#scope}}{{scopeCamelCase}}Job::{{/scope}}{{>name}}"
omittedValue: '{}' # default value to initialize omitted parameters with
initializer: '{{defaultValue}}'
cjoin: '{{#hasMore}}, {{/hasMore}}'
openOmittable:
"{{^required?}}{{#useOmittable}}\
{{^defaultValue}}std::optional<{{/defaultValue}}\
{{/useOmittable}}{{/required?}}"
closeOmittable:
"{{^required?}}{{#useOmittable}}\
{{^defaultValue}}>{{/defaultValue}}\
{{/useOmittable}}{{/required?}}"
maybeOmittableType: "{{>openOmittable}}{{dataType.name}}{{>closeOmittable}}"
qualifiedMaybeOmittableType:
"{{>openOmittable}}{{dataType.qualifiedName}}{{>closeOmittable}}"
ref: ""
maybeCrefType:
"{{#avoidCopy}}const {{/avoidCopy}}{{>maybeOmittableType}}{{>ref}}"
qualifiedMaybeCrefType:
"{{#avoidCopy}}const {{/avoidCopy}}{{>qualifiedMaybeOmittableType}}{{>ref}}"
maybeCrefJsonObject:
"{{^propertyMap}}JsonWrap{{/propertyMap}}\
{{#propertyMap}}JsonWrap{{/propertyMap}}"
takeOrValue:
"{{#propertyMap}}take{{/propertyMap}}{{^propertyMap}}value{{/propertyMap}}"
takeOrLoad: "{{#moveOnly}}take{{/moveOnly}}{{^moveOnly}}load{{/moveOnly}}"
initializeDefaultValue:
"{{#defaultValue}}{{>initializer}}{{/defaultValue}}\
{{^defaultValue}}{{>omittedValue}}{{/defaultValue}}"
# No inner indents in folded values!
joinedParamDecl: >-
{{>maybeCrefType}} {{paramName}}
{{^required?}} = {{>initializeDefaultValue}}{{/required?}}{{>cjoin}}
joinedParamDef: "{{>maybeCrefType}} {{paramName}}{{>cjoin}}"
passPathAndMaybeQuery: >-
std::string("{{basePathWithoutHost}}")
{{#pathParts}} + {{_}}{{/pathParts}}{{#queryParams?}},
queryTo{{camelCaseOperationId}}(
{{#queryParams}}{{paramName}}{{>cjoin}}{{/queryParams}}){{/queryParams?}}
nonInlineResponseSignature: |-
{{>docCommentShort}}
static {{>maybeOmittableType}} {{paramName}}(Response r)
# Doc-comment blocks. Comment indent is managed by clang-format
# (without clang-format there'd have to be a separate partial definition
# for each indent...) but we take care of line breaks to maintain
# some sanity even before clang-format
# This is for structures that don't expect a summary (e.g., JSON schema)
docCommentShort: |-
{{#description}}
/// {{_}}{{/description}}
# For structures with the summary, a common partial for summary is here;
# the main part is different in different places
docCommentSummary: |-
{{#summary}} \brief {{summary}}
*{{/summary}}
templates:
data:
.hpp: "{{>data.hpp.mustache}}"
api:
.hpp: "{{>operation.hpp.mustache}}"
.cpp: "{{>operation.cpp.mustache}}"
diff --git a/gtad/operation.cpp.mustache b/gtad/operation.cpp.mustache
index 0653a75..f7cd800 100644
--- a/gtad/operation.cpp.mustache
+++ b/gtad/operation.cpp.mustache
@@ -1,78 +1,102 @@
{{>preamble}}
#include "{{filenameBase}}.hpp"
namespace Kazv
{
{{#operations}}{{#operation}}
{{#queryParams?}}
-inline BaseJob::Query build{{camelCaseOperationId}}JobQuery(
+BaseJob::Query {{camelCaseOperationId}}Job::buildQuery(
{{#queryParams}}{{>joinedParamDef}}{{/queryParams}})
{
BaseJob::Query _q;
{{#queryParams}}
{{#required?}}
- _q = std::move(_q).set("{{baseName}}"s, {{paramName}})
+ addToQuery(_q, "{{baseName}}"s, {{paramName}});
{{/required?}}
{{^required?}}
- _q = addToQueryIfNeeded(std::move(_q), "{{baseName}}"s, {{paramName}});
+ addToQueryIfNeeded(_q, "{{baseName}}"s, {{paramName}});
{{/required?}}
{{/queryParams}}
-return std::move(_q);
+return _q;
}
{{/queryParams?}}
- inline BaseJob::Body build{{camelCaseOperationId}}JobBody({{#allParams}}{{>joinedParamDef}}{{/allParams}})
+ BaseJob::Body {{camelCaseOperationId}}Job::buildBody({{#allParams}}{{>joinedParamDef}}{{/allParams}})
{
+ // ignore unused param
+ {{#allParams}}(void)({{paramName}});{{/allParams}}
{{#inlineBody}}{{^propertyMap}}{{^bodyParams?}}
return {{#consumesNonJson?}}BaseJob::BytesBody({{nameCamelCase}}){{/consumesNonJson?}}
- {{^consumesNonJson?}}BaseJob::JsonBody(json({{nameCamelCase}})){{/consumesNonJson?}};
+ {{^consumesNonJson?}}BaseJob::JsonBody({{nameCamelCase}}){{/consumesNonJson?}};
{{/bodyParams?}}{{/propertyMap}}{{/inlineBody}}
{{#bodyParams?}}
json _data
{{#inlineBody}}
({{paramName}})
{{/inlineBody}};
{{#propertyMap}}
addPropertyMapToJson(_data, {{nameCamelCase}});
{{/propertyMap}}
{{#bodyParams}}
{{#required?}}
_data["{{baseName}}"s] = {{paramName}};
{{/required?}}
{{^required?}}
addToJsonIfNeeded(_data, "{{baseName}}"s, {{paramName}});
{{/required?}}
{{/bodyParams}}
return BaseJob::JsonBody(_data);
{{/bodyParams?}}
-
+ {{^bodyParams?}}
+ {{^inlineBody}}
+ {{^propertyMap?}}
+ return BaseJob::EmptyBody{};
+ {{/propertyMap?}}
+ {{/inlineBody}}
+ {{/bodyParams?}}
};
{{camelCaseOperationId}}Job::{{camelCaseOperationId}}Job(
std::string serverUrl
- {{^skipAuth?}}, std::string token{{/skipAuth?}}
+ {{^skipAuth}}, std::string _accessToken{{/skipAuth}}
{{#allParams?}},{{/allParams?}}
{{#allParams}}{{>joinedParamDef}}{{/allParams}})
: BaseJob(std::move(serverUrl),
std::string("{{basePathWithoutHost}}"){{#pathParts}} + {{_}}{{/pathParts}},
{{#_toupper}}{{httpMethod}}{{/_toupper}},
- {{^skipAuth?}}token{{/skipAuth?}}{{#skipAuth?}} {} {{/skipAuth?}},
+ {{^skipAuth}}_accessToken{{/skipAuth}}{{#skipAuth}} {} {{/skipAuth}},
ReturnType::{{^producesNonJson?}}Json{{/producesNonJson?}}{{#producesNonJson?}}Byte{{/producesNonJson?}},
- build{{camelCaseOperationId}}JobBody({{#allParams}}{{paramName}}{{>cjoin}}{{/allParams}})
- {{#queryParams?}}, build{{camelCaseOperationId}}JobQuery({{#queryParams}}{{paramName}}{{>cjoin}}{{/queryParams}}){{/queryParams?}})
+ buildBody({{#allParams}}{{paramName}}{{>cjoin}}{{/allParams}})
+ {{#queryParams?}}, buildQuery({{#queryParams}}{{paramName}}{{>cjoin}}{{/queryParams}}){{/queryParams?}})
{
{{#headerParams}}
//setRequestHeader("{{baseName}}", {{paramName}}.toLatin1());
{{/headerParams}}
{{#producesNonJson?}}
//setExpectedContentTypes({ {{#produces}}"{{_}}"{{>cjoin}}{{/produces}} });
{{/producesNonJson?}}
{{^producesNonJson?}}{{#responses}}{{#normalResponse?}}{{#properties}}{{#required?}}
//addExpectedKey("{{baseName}}");
{{/required?}}{{/properties}}{{/normalResponse?}}{{/responses
- }}{{/producesNonJson?}}
-}
+ }}{{/producesNonJson?}}
+ }
+
+ {{#responses}}{{#normalResponse?}}
+ {{#properties}}
+
+ {{!there's nothing in #properties if the response is inline}}
+ {{>qualifiedMaybeOmittableType}} {{camelCaseOperationId}}Job::{{paramName}}(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("{{baseName}}"s)) {
+ return
+ jsonBody(r).get()["{{baseName}}"s]
+ /*.get<{{dataType.name}}>()*/;}
+ else { return {{>maybeOmittableType}}( {{defaultValue}} );}
+ }
+ {{/properties}}{{/normalResponse?}}{{/responses}}
+
{{/operation}}{{/operations}}
}
diff --git a/gtad/operation.hpp.mustache b/gtad/operation.hpp.mustache
index 7a67569..13caf55 100644
--- a/gtad/operation.hpp.mustache
+++ b/gtad/operation.hpp.mustache
@@ -1,130 +1,144 @@
{{>preamble}}
#pragma once
#include "basejob.hpp"
{{#imports}}
#include {{_}}{{/imports}}
namespace Kazv {
{{#operations.operation}}
/*!{{>docCommentSummary}}{{#description}}
* {{_}}{{/description}}
*/
class {{camelCaseOperationId}}Job : public BaseJob {
public:
{{#models}}
// Inner data structures
{{#model}}
{{>docCommentShort}}
struct {{name}}{{#parents?}} :
{{#parents}}{{name}}{{>cjoin}}{{/parents}}{{/parents?}}
{
{{#vars}}
{{>docCommentShort}}
{{>maybeOmittableType}} {{nameCamelCase}};
{{/vars}}
{{#propertyMap}}
{{>docCommentShort}}
{{>maybeOmittableType}} {{nameCamelCase}};
{{/propertyMap}}
};
{{/model}}
{{/models}}
// Construction/destruction
{{#allParams?}}
/*!{{>docCommentSummary}}
{{#allParams}}
* \param {{nameCamelCase}}{{#description}}
* {{_}}{{/description}}{{#_join}}
* {{/_join}}
{{/allParams}}
*/
{{/allParams?}}{{^allParams?}}
{{#summary}}
/// {{summary}}
{{/summary}}
{{/allParams?}}
- explicit {{camelCaseOperationId}}Job(std::string serverUrl{{#allParams?}},{{/allParams?}}
+ explicit {{camelCaseOperationId}}Job(std::string serverUrl
+ {{^skipAuth}}, std::string _accessToken{{/skipAuth}}
+ {{#allParams?}},{{/allParams?}}
{{#allParams}}{{>joinedParamDecl}}{{/allParams}});
{{^hasBody?}}
{{/hasBody?}}
{{#responses}}{{#normalResponse?}}{{#allProperties?}}
// Result properties
{{#headers}}
/*
{{>nonInlineResponseSignature}}
{
return reply()->rawHeader("{{baseName}}");
}
*/ {{/headers}}
{{#inlineResponse}}
{{>docCommentShort}}
static {{dataType.name}} {{paramName}}(Response r)
{
return
{{#producesNonJson?}}
- r
+ std::get<Bytes>(r.body)
{{/producesNonJson?}}
{{^producesNonJson?}}
std::move(jsonBody(r).get()).get<{{dataType.name}}>()
{{/producesNonJson?}}
;
}
{{/inlineResponse}}
{{#properties}}
{{!there's nothing in #properties if the response is inline}}
- {{>nonInlineResponseSignature}}
- {
- return jsonBody(r).get()
- .contains("{{baseName}}"s) ?
- jsonBody(r).get()["{{baseName}}"s]
- .get<{{dataType.name}}>() : {{defaultValue}};
- }
+ {{>nonInlineResponseSignature}};
{{/properties}}
{{/allProperties?}}{{/normalResponse?}}{{/responses}}
-};
- {{#models.model}}
+ {{#queryParams?}}
+ static BaseJob::Query buildQuery(
+ {{#queryParams}}{{>joinedParamDef}}{{/queryParams}});{{/queryParams?}}
+
+ static BaseJob::Body buildBody({{#allParams}}{{>joinedParamDef}}{{/allParams}});
+ };
+
+ } {{! namespace Kazv}}
+ namespace nlohmann
+ {
+ using namespace Kazv;
+ {{#models.model}}
+ template<>
+ struct adl_serializer<{{qualifiedName}}> {
{{#in?}}
- inline void to_json(json& jo, const {{qualifiedName}} &pod)
+ static void to_json(json& jo, const {{qualifiedName}} &pod)
{
{{#parents}}{{!assume no more one parent}}
- nlohmann::to_json(jo, static_cast<const {{name}} &>(pod));
+ jo = static_cast<const {{name}} &>(pod);
+ //nlohmann::to_json(jo, static_cast<const {{name}} &>(pod));
{{/parents}}
{{#propertyMap}}
addPropertyMapToJson(jo, pod.{{nameCamelCase}});
{{/propertyMap}}
{{#vars}}
{{#required?}}jo["{{baseName}}"s] = pod.{{nameCamelCase}};{{/required?}}
{{^required?}}addToJsonIfNeeded(jo, "{{baseName}}"s, pod.{{nameCamelCase}});{{/required?}}
{{/vars}}
}
{{/in?}}
{{#out?}}
- inline void from_json({{>maybeCrefJsonObject}} jo, {{qualifiedName}}& result)
+ static void from_json(const json &jo, {{qualifiedName}}& result)
{
{{#parents}}
- nlohmann::from_json(static_cast<const {{name}} &{{!of the parent!}}>(result), result);
+ static_cast<{{name}} &{{!of the parent!}}>(result) = jo;
+ //nlohmann::from_json(jo, static_cast<const {{name}} &{{!of the parent!}}>(result));
{{/parents}}
{{#vars}}
result.{{nameCamelCase}} = jo.at("{{baseName}}"s);
{{/vars}}
{{#propertyMap}}
- from_json(jo, result.{{nameCamelCase}});
+ result.{{nameCamelCase}} = jo;
{{/propertyMap}}
}
{{/out?}}
-
+};
{{/models.model}}
+ }
+
+ namespace Kazv
+ {
{{/operations.operation}}
} // namespace Kazv
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0e708ef..f50b9fd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,54 +1,56 @@
-include_directories(api .)
-
+include_directories(api . csapi)
+set(FULL_CSAPI_DIR csapi)
+file(GLOB_RECURSE api_SRCS ${FULL_CSAPI_DIR}/*.cpp)
set(libkazv_SRCS
# api/wellknown.cpp
+ ${api_SRCS}
debug.cpp
api/basejob.cpp
- api/login.cpp
+ #api/login.cpp
client/client.cpp
)
add_library(kazv ${libkazv_SRCS})
add_library(libkazv::kazv ALIAS kazv)
target_link_libraries(kazv
PUBLIC cpr::cpr
PUBLIC nlohmann_json::nlohmann_json
PUBLIC immer
PUBLIC zug
PUBLIC lager)
target_include_directories(kazv
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/kazv>
)
install(
TARGETS kazv
LIBRARY
)
if(libkazv_INSTALL_HEADERS)
install(
DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/kazv"
FILES_MATCHING PATTERN "*.hpp"
PATTERN "tests" EXCLUDE
)
endif()
# export(TARGETS kazv)
if(libkazv_BUILD_TESTS)
add_subdirectory(tests)
endif()
if(libkazv_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
diff --git a/src/api/basejob.cpp b/src/api/basejob.cpp
index c3e7bb0..aa1197a 100644
--- a/src/api/basejob.cpp
+++ b/src/api/basejob.cpp
@@ -1,132 +1,146 @@
#include <cpr/cpr.h>
#include <cpr/util.h>
#include <lager/util.hpp>
+#include <vector>
+#include <tuple>
#include "basejob.hpp"
namespace Kazv
{
BaseJob::Get BaseJob::GET{};
BaseJob::Post BaseJob::POST{};
BaseJob::Put BaseJob::PUT{};
BaseJob::Delete BaseJob::DELETE{};
+ struct BaseJob::Query::Private
+ {
+ std::vector<std::pair<std::string, std::string>> params;
+ };
+
+ BaseJob::Query::Query() = default;
+
+ void BaseJob::Query::add(std::string k, std::string v)
+ {
+ m_d->params.push_back({k, v});
+ };
+
struct BaseJob::Private
{
Private(std::string serverUrl,
std::string requestUrl,
Method method,
std::string token,
ReturnType returnType,
Body body,
Query query);
std::string fullRequestUrl;
Method method;
ReturnType returnType;
cpr::Header header;
BytesBody body;
cpr::Parameters params;
};
BaseJob::Private::Private(std::string serverUrl,
std::string requestUrl,
Method method,
std::string token,
ReturnType returnType,
Body body,
Query query)
: fullRequestUrl(serverUrl + requestUrl)
, method(std::move(method))
, returnType(returnType)
, header()
, body()
, params()
{
if (token.size()) {
header["Authorization"] = "Bearer " + token;
}
if (isBodyJson(body)) {
JsonBody j = std::get<JsonBody>(std::move(body));
header["Content-Type"] = "application/json";
this->body = j.get().dump();
} else if (std::holds_alternative<BytesBody>(body)) {
BytesBody b = std::get<BytesBody>(std::move(body));
this->body = b;
}
- if (! query.empty()) {
+ if (! query.m_d->params.empty()) {
// from cpr/parameters.cpp
cpr::CurlHolder holder;
- for (const auto kv : query) {
+ for (const auto kv : query.m_d->params) {
std::string key = kv.first;
std::string value = kv.second;
params.AddParameter(cpr::Parameter(std::move(key), std::move(value)), holder);
}
}
}
BaseJob::BaseJob(std::string serverUrl,
std::string requestUrl,
Method method,
std::string token,
ReturnType returnType,
Body body,
Query query)
: m_d(std::move(Private(serverUrl, requestUrl, method, token, returnType, body, query)))
{
}
auto BaseJob::fetch() const -> std::future<Response>
{
cpr::Url url{m_d->fullRequestUrl};
cpr::Body body(m_d->body);
cpr::Header header{m_d->header};
cpr::Parameters params(m_d->params);
auto callback = [returnType = m_d->returnType](cpr::Response r) -> Response {
Body body = r.text;
if (returnType == ReturnType::Json) {
try {
body = JsonBody(std::move(json::parse(r.text)));
} catch (const json::exception &) {
// the response is not valid json
}
}
return { r.status_code, body };
};
return std::visit(lager::visitor{
[=](Get) {
return cpr::GetCallback(callback, url, header, body, params);
},
[=](Post) {
return cpr::PostCallback(callback, url, header, body, params);
},
[=](Put) {
return cpr::PutCallback(callback, url, header, body, params);
},
[=](Delete) {
return cpr::DeleteCallback(callback, url, header, body, params);
}
}, m_d->method);
}
bool BaseJob::shouldReturnJson() const
{
return m_d->returnType == ReturnType::Json;
};
std::string BaseJob::url() const
{
return m_d->fullRequestUrl;
};
JsonWrap jsonBody(const BaseJob::Response &res)
{
return std::get<JsonWrap>(res.body);
}
}
diff --git a/src/api/basejob.hpp b/src/api/basejob.hpp
index 210d3cc..fce62bf 100644
--- a/src/api/basejob.hpp
+++ b/src/api/basejob.hpp
@@ -1,103 +1,184 @@
#pragma once
#include <variant>
#include <tuple>
#include <functional>
#include <string>
#include <immer/map.hpp>
#include <immer/array.hpp>
#include <future>
#include "types.hpp"
#include "descendent.hpp"
namespace Kazv
{
class BaseJob
{
public:
struct Get {};
struct Post {};
struct Put {};
struct Delete {};
using Method = std::variant<Get, Post, Put, Delete>;
static Get GET;
static Post POST;
static Put PUT;
static Delete DELETE;
- using Query = immer::map<std::string, std::string>;
+ class Query
+ {
+ public:
+ Query();
+
+ void add(std::string k, std::string v);
+ private:
+ struct Private;
+ Descendent<Private> m_d;
+ friend class BaseJob;
+ };
using BytesBody = Bytes;
using JsonBody = JsonWrap;
struct EmptyBody {};
using Body = std::variant<EmptyBody, JsonBody, BytesBody>;
static constexpr bool isBodyJson(const Body &body) {
return std::holds_alternative<JsonBody>(body);
};
using StatusCode = int;
struct Response {
StatusCode statusCode;
Body body;
};
constexpr bool success(const Response &res) const {
return res.statusCode < 300 && (!shouldReturnJson() || isBodyJson(res.body));
}
enum ReturnType {
Json,
Byte,
};
BaseJob(std::string serverUrl,
std::string requestUrl,
Method method,
std::string token = {},
ReturnType returnType = ReturnType::Json,
Body body = EmptyBody{},
Query query = {});
std::future<Response> fetch() const;
bool shouldReturnJson() const;
std::string url() const;
private:
struct Private;
Descendent<Private> m_d;
};
JsonWrap jsonBody(const BaseJob::Response &res);
- template<class T,
- std::enable_if_t<std::is_same_v<decltype(std::declval<T>().empty()), bool>,
- int> = 0>
- inline BaseJob::Query addToQueryIfNeeded(BaseJob::Query &&q, std::string name, T &&arg)
+
+
+ namespace detail
{
- if (! arg.empty()) {
- return std::move(q).set(name, std::forward<T>(arg));
- }
- return std::move(q);
- };
+ template<class T>
+ struct AddToQueryT
+ {
+ template<class U>
+ static void call(BaseJob::Query &q, std::string name, U &&arg) {
+ q.add(name, std::to_string(std::forward<U>(arg)));
+ }
+ };
+
+ template<>
+ struct AddToQueryT<std::string>
+ {
+ template<class U>
+ static void call(BaseJob::Query &q, std::string name, U &&arg) {
+ q.add(name, std::forward<U>(arg));
+ }
+ };
+
+ template<>
+ struct AddToQueryT<bool>
+ {
+ template<class U>
+ static void call(BaseJob::Query &q, std::string name, U &&arg) {
+ q.add(name, std::forward<U>(arg) ? "true"s : "false"s);
+ }
+ };
+
+ template<class T>
+ struct AddToQueryT<immer::array<T>>
+ {
+ template<class U>
+ static void call(BaseJob::Query &q, std::string name, U &&arg) {
+ for (auto v : std::forward<U>(arg)) {
+ q.add(name, v);
+ }
+ }
+ };
+
+ template<>
+ struct AddToQueryT<json>
+ {
+ // https://github.com/nlohmann/json/issues/2040
+ static void call(BaseJob::Query &q, std::string /* name */, const json &arg) {
+ // assume v is string type
+ for (auto [k, v] : arg.items()) {
+ q.add(k, v);
+ }
+ }
+ };
+ }
template<class T>
- inline BaseJob::Query addToQueryIfNeeded(BaseJob::Query &&q, std::string name, T &&arg)
+ inline void addToQuery(BaseJob::Query &q, std::string name, T &&arg)
{
- return std::move(q).set(name, std::forward<T>(arg));
- };
+ detail::AddToQueryT<std::decay_t<T>>::call(q, name, std::forward<T>(arg));
+ }
+
+ namespace detail
+ {
+ template<class T>
+ struct AddToQueryIfNeededT
+ {
+ template<class U>
+ static void call(BaseJob::Query &q, std::string name, U &&arg) {
+ if constexpr (detail::hasEmptyMethod(arg)) {
+ if (! arg.empty()) {
+ addToQuery(q, name, std::forward<U>(arg));
+ }
+ } else {
+ addToQuery(q, name, std::forward<U>(arg));
+ }
+ }
+ };
+
+ template<class T>
+ struct AddToQueryIfNeededT<std::optional<T>>
+ {
+ template<class U>
+ static void call(BaseJob::Query &q, std::string name, U &&arg) {
+ if (arg.has_value()) {
+ addToQuery(q, name, std::forward<U>(arg).value());
+ }
+ }
+ };
+ }
template<class T>
- inline BaseJob::Query addToQueryIfNeeded(BaseJob::Query &&q, std::string name, std::optional<T> &&arg)
+ inline void addToQueryIfNeeded(BaseJob::Query &q, std::string name, T &&arg)
{
- if (arg.has_value()) {
- return std::move(q).set(name, std::forward<T>(arg).value());
- }
- return std::move(q);
- };
+ detail::AddToQueryIfNeededT<std::decay_t<T>>::call(q, name, std::forward<T>(arg));
+ }
+
}
diff --git a/src/api/definitions/event_filter.hpp b/src/api/definitions/event_filter.hpp
new file mode 100644
index 0000000..16a30fd
--- /dev/null
+++ b/src/api/definitions/event_filter.hpp
@@ -0,0 +1,17 @@
+
+#pragma once
+#include <string>
+#include <immer/array.hpp>
+
+
+namespace Kazv
+{
+ struct EventFilter
+ {
+ int limit;
+ immer::array<std::string> notSenders;
+ immer::array<std::string> notTypes;
+ immer::array<std::string> senders;
+ immer::array<std::string> types;
+ };
+}
diff --git a/src/api/definitions/room_event_filter.hpp b/src/api/definitions/room_event_filter.hpp
new file mode 100644
index 0000000..98e4146
--- /dev/null
+++ b/src/api/definitions/room_event_filter.hpp
@@ -0,0 +1,15 @@
+
+#pragma once
+#include "event_filter.hpp"
+
+namespace Kazv
+{
+ struct RoomEventFilter : public EventFilter
+ {
+ bool lazyLoadMembers;
+ bool includeRedundantMembers;
+ immer::array<std::string> notRooms;
+ immer::array<std::string> rooms;
+ bool containsUrl;
+ };
+}
diff --git a/src/api/definitions/sync_filter.hpp b/src/api/definitions/sync_filter.hpp
new file mode 100644
index 0000000..b222726
--- /dev/null
+++ b/src/api/definitions/sync_filter.hpp
@@ -0,0 +1,42 @@
+
+#pragma once
+#include <string>
+#include <immer/array.hpp>
+#include <descendent.hpp>
+
+#include "types.hpp"
+#include "event_filter.hpp"
+#include "room_event_filter.hpp"
+
+namespace Kazv
+{
+ struct RoomFilter;
+
+ struct Filter
+ {
+ immer::array<std::string> eventFields;
+ // eventFormat ignored
+ EventFilter presence;
+ EventFilter accountData;
+ RoomFilter room;
+
+ json toJson() const {
+ json j = json::object();
+ if (eventFields)
+ j["event_fields"] =
+ };
+ };
+
+ using StateFilter = RoomEventFilter;
+
+ struct RoomFilter
+ {
+ immer::array<std::string> notRooms;
+ immer::array<std::string> rooms;
+ RoomEventFilter ephemeral;
+ bool includeLeave;
+ StateFilter state;
+ RoomEventFilter timeline;
+ RoomEventFilter accountData;
+ };
+}
diff --git a/src/application-service/definitions/location.hpp b/src/application-service/definitions/location.hpp
new file mode 100644
index 0000000..b780193
--- /dev/null
+++ b/src/application-service/definitions/location.hpp
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+
+struct ThirdPartyLocation
+{
+
+/// An alias for a matrix room.
+ std::string alias;
+
+/// The protocol ID that the third party location is a part of.
+ std::string protocol;
+
+/// Information used to identify this third party location.
+ JsonWrap fields;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<ThirdPartyLocation> {
+ static void to_json(json& jo, const ThirdPartyLocation &pod)
+ {
+
+
+ jo["alias"s] = pod.alias;
+
+ jo["protocol"s] = pod.protocol;
+
+ jo["fields"s] = pod.fields;
+
+ }
+ static void from_json(const json &jo, ThirdPartyLocation& result)
+ {
+
+ result.alias = jo.at("alias"s);
+ result.protocol = jo.at("protocol"s);
+ result.fields = jo.at("fields"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/application-service/definitions/protocol.hpp b/src/application-service/definitions/protocol.hpp
new file mode 100644
index 0000000..105f25c
--- /dev/null
+++ b/src/application-service/definitions/protocol.hpp
@@ -0,0 +1,170 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+/// Definition of valid values for a field.
+struct FieldType
+{
+
+/// A regular expression for validation of a field's value. This may be relatively
+/// coarse to verify the value as the application service providing this protocol
+/// may apply additional validation or filtering.
+ std::string regexp;
+
+/// An placeholder serving as a valid example of the field value.
+ std::string placeholder;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<FieldType> {
+ static void to_json(json& jo, const FieldType &pod)
+ {
+
+
+ jo["regexp"s] = pod.regexp;
+
+ jo["placeholder"s] = pod.placeholder;
+
+ }
+ static void from_json(const json &jo, FieldType& result)
+ {
+
+ result.regexp = jo.at("regexp"s);
+ result.placeholder = jo.at("placeholder"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+
+struct ProtocolInstance
+{
+
+/// A human-readable description for the protocol, such as the name.
+ std::string desc;
+
+/// An optional content URI representing the protocol. Overrides the one provided
+/// at the higher level Protocol object.
+ std::string icon;
+
+/// Preset values for ``fields`` the client may use to search by.
+ JsonWrap fields;
+
+/// A unique identifier across all instances.
+ std::string networkId;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<ProtocolInstance> {
+ static void to_json(json& jo, const ProtocolInstance &pod)
+ {
+
+
+ jo["desc"s] = pod.desc;
+
+
+ addToJsonIfNeeded(jo, "icon"s, pod.icon);
+ jo["fields"s] = pod.fields;
+
+ jo["network_id"s] = pod.networkId;
+
+ }
+ static void from_json(const json &jo, ProtocolInstance& result)
+ {
+
+ result.desc = jo.at("desc"s);
+ result.icon = jo.at("icon"s);
+ result.fields = jo.at("fields"s);
+ result.networkId = jo.at("network_id"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+
+struct ThirdPartyProtocol
+{
+
+/// Fields which may be used to identify a third party user. These should be
+/// ordered to suggest the way that entities may be grouped, where higher
+/// groupings are ordered first. For example, the name of a network should be
+/// searched before the nickname of a user.
+ immer::array<std::string> userFields;
+
+/// Fields which may be used to identify a third party location. These should be
+/// ordered to suggest the way that entities may be grouped, where higher
+/// groupings are ordered first. For example, the name of a network should be
+/// searched before the name of a channel.
+ immer::array<std::string> locationFields;
+
+/// A content URI representing an icon for the third party protocol.
+ std::string icon;
+
+/// The type definitions for the fields defined in the ``user_fields`` and
+/// ``location_fields``. Each entry in those arrays MUST have an entry here. The
+/// ``string`` key for this object is field name itself.
+///
+/// May be an empty object if no fields are defined.
+ immer::map<std::string, FieldType> fieldTypes;
+
+/// A list of objects representing independent instances of configuration.
+/// For example, multiple networks on IRC if multiple are provided by the
+/// same application service.
+ immer::array<ProtocolInstance> instances;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<ThirdPartyProtocol> {
+ static void to_json(json& jo, const ThirdPartyProtocol &pod)
+ {
+
+
+ jo["user_fields"s] = pod.userFields;
+
+ jo["location_fields"s] = pod.locationFields;
+
+ jo["icon"s] = pod.icon;
+
+ jo["field_types"s] = pod.fieldTypes;
+
+ jo["instances"s] = pod.instances;
+
+ }
+ static void from_json(const json &jo, ThirdPartyProtocol& result)
+ {
+
+ result.userFields = jo.at("user_fields"s);
+ result.locationFields = jo.at("location_fields"s);
+ result.icon = jo.at("icon"s);
+ result.fieldTypes = jo.at("field_types"s);
+ result.instances = jo.at("instances"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/application-service/definitions/user.hpp b/src/application-service/definitions/user.hpp
new file mode 100644
index 0000000..893e531
--- /dev/null
+++ b/src/application-service/definitions/user.hpp
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+
+struct ThirdPartyUser
+{
+
+/// A Matrix User ID represting a third party user.
+ std::string userid;
+
+/// The protocol ID that the third party location is a part of.
+ std::string protocol;
+
+/// Information used to identify this third party location.
+ JsonWrap fields;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<ThirdPartyUser> {
+ static void to_json(json& jo, const ThirdPartyUser &pod)
+ {
+
+
+ jo["userid"s] = pod.userid;
+
+ jo["protocol"s] = pod.protocol;
+
+ jo["fields"s] = pod.fields;
+
+ }
+ static void from_json(const json &jo, ThirdPartyUser& result)
+ {
+
+ result.userid = jo.at("userid"s);
+ result.protocol = jo.at("protocol"s);
+ result.fields = jo.at("fields"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/client/client.cpp b/src/client/client.cpp
index 4089b90..3fa537a 100644
--- a/src/client/client.cpp
+++ b/src/client/client.cpp
@@ -1,93 +1,96 @@
#include <lager/util.hpp>
#include <lager/context.hpp>
#include <functional>
#include "client.hpp"
-#include "api/login.hpp"
+#include "csapi/login.hpp"
#include "types.hpp"
#include "debug.hpp"
namespace Kazv
{
lager::effect<Client::Action> loginEffect(Client::LoginAction a)
{
return
[=](auto &&ctx) {
LoginJob job(a.serverUrl,
- a.username,
+ "m.login.password"s, // type
+ UserIdentifier{ "m.id.user"s, json{{"user", a.username}} }, // identifier
a.password,
- a.deviceName);
+ {}, // token, not used
+ {}, // device id, not used
+ a.deviceName.value_or("libkazv"));
auto res = job.fetch();
dbgClient << "Result validity: " << res.valid() << std::endl;
auto r = res.get();
if (job.success(r)) {
dbgClient << "Job success" << std::endl;
const json &j = jsonBody(r).get();
try {
std::string serverUrl = j.contains("well_known")
? j.at("well_known").at("m.homeserver").at("base_url").get<std::string>()
: a.serverUrl;
ctx.dispatch(Client::LoadUserInfoAction{
serverUrl,
j.at("user_id"),
j.at("access_token"),
j.at("device_id"),
/* loggedIn = */ true
});
} catch (const json::out_of_range &e) {
dbgClient << "Json error: " << e.what() << std::endl;
ctx.dispatch(Error::SetErrorAction{e.what()});
}
}
};
}
lager::effect<Client::Action> logoutEffect(Client::LogoutAction a)
{
return
[=](auto &&ctx) {
ctx.dispatch(Client::LoadUserInfoAction{
""s,
""s,
""s,
""s,
/* loggedIn = */ true
});
};
}
auto Client::update(Client m, Action a) -> Result
{
dbgClient << "Client::update()" << std::endl;
return
std::visit(lager::visitor{
[=](Error::Action a) mutable -> Result {
m.error = Error::update(m.error, a);
return {std::move(m), lager::noop};
},
[=](LoginAction a) mutable -> Result {
return {std::move(m), loginEffect(std::move(a))};
},
[=](LogoutAction a) mutable -> Result {
return {std::move(m), logoutEffect(std::move(a))};
},
[=](LoadUserInfoAction a) mutable -> Result {
dbgClient << "LoadUserInfoAction: " << a.userId << std::endl;
m.serverUrl = a.serverUrl;
m.userId = a.userId;
m.token = a.token;
m.deviceId = a.deviceId;
m.loggedIn = a.loggedIn;
return { std::move(m),
[](auto &&ctx) {
ctx.dispatch(Error::SetErrorAction{Error::NoError{}});
}
};
},
}, std::move(a));
}
}
diff --git a/src/csapi/account-data.cpp b/src/csapi/account-data.cpp
new file mode 100644
index 0000000..70d43ce
--- /dev/null
+++ b/src/csapi/account-data.cpp
@@ -0,0 +1,131 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "account-data.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body SetAccountDataJob::buildBody(std::string userId, std::string type, JsonWrap content)
+ {
+ // ignore unused param
+ (void)(userId);(void)(type);(void)(content);
+ return
+ BaseJob::JsonBody(content);
+
+
+
+ };
+
+SetAccountDataJob::SetAccountDataJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId, std::string type, JsonWrap content)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/user/" + userId + "/account_data/" + type,
+ PUT,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(userId, type, content)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body GetAccountDataJob::buildBody(std::string userId, std::string type)
+ {
+ // ignore unused param
+ (void)(userId);(void)(type);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetAccountDataJob::GetAccountDataJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId, std::string type)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/user/" + userId + "/account_data/" + type,
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(userId, type)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body SetAccountDataPerRoomJob::buildBody(std::string userId, std::string roomId, std::string type, JsonWrap content)
+ {
+ // ignore unused param
+ (void)(userId);(void)(roomId);(void)(type);(void)(content);
+ return
+ BaseJob::JsonBody(content);
+
+
+
+ };
+
+SetAccountDataPerRoomJob::SetAccountDataPerRoomJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId, std::string roomId, std::string type, JsonWrap content)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/user/" + userId + "/rooms/" + roomId + "/account_data/" + type,
+ PUT,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(userId, roomId, type, content)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body GetAccountDataPerRoomJob::buildBody(std::string userId, std::string roomId, std::string type)
+ {
+ // ignore unused param
+ (void)(userId);(void)(roomId);(void)(type);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetAccountDataPerRoomJob::GetAccountDataPerRoomJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId, std::string roomId, std::string type)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/user/" + userId + "/rooms/" + roomId + "/account_data/" + type,
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(userId, roomId, type)
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/account-data.hpp b/src/csapi/account-data.hpp
new file mode 100644
index 0000000..8185fab
--- /dev/null
+++ b/src/csapi/account-data.hpp
@@ -0,0 +1,194 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Set some account_data for the user.
+ *
+ * Set some account_data for the client. This config is only visible to the user
+ * that set the account_data. The config will be synced to clients in the
+ * top-level ``account_data``.
+ */
+class SetAccountDataJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Set some account_data for the user.
+ *
+ * \param userId
+ * The ID of the user to set account_data for. The access token must be
+ * authorized to make requests for this user ID.
+ *
+ * \param type
+ * The event type of the account_data to set. Custom types should be
+ * namespaced to avoid clashes.
+ *
+ * \param content
+ * The content of the account_data
+ */
+ explicit SetAccountDataJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId , std::string type , JsonWrap content = {});
+
+
+
+
+ static BaseJob::Body buildBody(std::string userId, std::string type, JsonWrap content);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Get some account_data for the user.
+ *
+ * Get some account_data for the client. This config is only visible to the user
+ * that set the account_data.
+ */
+class GetAccountDataJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Get some account_data for the user.
+ *
+ * \param userId
+ * The ID of the user to get account_data for. The access token must be
+ * authorized to make requests for this user ID.
+ *
+ * \param type
+ * The event type of the account_data to get. Custom types should be
+ * namespaced to avoid clashes.
+ */
+ explicit GetAccountDataJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId , std::string type );
+
+
+
+
+ static BaseJob::Body buildBody(std::string userId, std::string type);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Set some account_data for the user.
+ *
+ * Set some account_data for the client on a given room. This config is only
+ * visible to the user that set the account_data. The config will be synced to
+ * clients in the per-room ``account_data``.
+ */
+class SetAccountDataPerRoomJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Set some account_data for the user.
+ *
+ * \param userId
+ * The ID of the user to set account_data for. The access token must be
+ * authorized to make requests for this user ID.
+ *
+ * \param roomId
+ * The ID of the room to set account_data on.
+ *
+ * \param type
+ * The event type of the account_data to set. Custom types should be
+ * namespaced to avoid clashes.
+ *
+ * \param content
+ * The content of the account_data
+ */
+ explicit SetAccountDataPerRoomJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId , std::string roomId , std::string type , JsonWrap content = {});
+
+
+
+
+ static BaseJob::Body buildBody(std::string userId, std::string roomId, std::string type, JsonWrap content);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Get some account_data for the user.
+ *
+ * Get some account_data for the client on a given room. This config is only
+ * visible to the user that set the account_data.
+ */
+class GetAccountDataPerRoomJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Get some account_data for the user.
+ *
+ * \param userId
+ * The ID of the user to set account_data for. The access token must be
+ * authorized to make requests for this user ID.
+ *
+ * \param roomId
+ * The ID of the room to get account_data for.
+ *
+ * \param type
+ * The event type of the account_data to get. Custom types should be
+ * namespaced to avoid clashes.
+ */
+ explicit GetAccountDataPerRoomJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId , std::string roomId , std::string type );
+
+
+
+
+ static BaseJob::Body buildBody(std::string userId, std::string roomId, std::string type);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/admin.cpp b/src/csapi/admin.cpp
new file mode 100644
index 0000000..aabce9b
--- /dev/null
+++ b/src/csapi/admin.cpp
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "admin.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body GetWhoIsJob::buildBody(std::string userId)
+ {
+ // ignore unused param
+ (void)(userId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetWhoIsJob::GetWhoIsJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/admin/whois/" + userId,
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(userId)
+ )
+ {
+
+
+ }
+
+
+
+ std::string GetWhoIsJob::userId(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("user_id"s)) {
+ return
+ jsonBody(r).get()["user_id"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ immer::map<std::string, GetWhoIsJob::DeviceInfo> GetWhoIsJob::devices(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("devices"s)) {
+ return
+ jsonBody(r).get()["devices"s]
+ /*.get<immer::map<std::string, DeviceInfo>>()*/;}
+ else { return immer::map<std::string, DeviceInfo>( );}
+ }
+
+}
diff --git a/src/csapi/admin.hpp b/src/csapi/admin.hpp
new file mode 100644
index 0000000..50ee7d8
--- /dev/null
+++ b/src/csapi/admin.hpp
@@ -0,0 +1,136 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Gets information about a particular user.
+ *
+ * Gets information about a particular user.
+ *
+ * This API may be restricted to only be called by the user being looked
+ * up, or by a server admin. Server-local administrator privileges are not
+ * specified in this document.
+ */
+class GetWhoIsJob : public BaseJob {
+public:
+ // Inner data structures
+
+/// Gets information about a particular user.
+///
+/// This API may be restricted to only be called by the user being looked
+/// up, or by a server admin. Server-local administrator privileges are not
+/// specified in this document.
+ struct ConnectionInfo
+ {
+/// Most recently seen IP address of the session.
+ std::string ip;
+/// Unix timestamp that the session was last active.
+ std::optional<std::int_fast64_t> lastSeen;
+/// User agent string last seen in the session.
+ std::string userAgent;
+
+ };
+
+/// Gets information about a particular user.
+///
+/// This API may be restricted to only be called by the user being looked
+/// up, or by a server admin. Server-local administrator privileges are not
+/// specified in this document.
+ struct SessionInfo
+ {
+/// Information particular connections in the session.
+ immer::array<ConnectionInfo> connections;
+
+ };
+
+/// Gets information about a particular user.
+///
+/// This API may be restricted to only be called by the user being looked
+/// up, or by a server admin. Server-local administrator privileges are not
+/// specified in this document.
+ struct DeviceInfo
+ {
+/// A user's sessions (i.e. what they did with an access token from one login).
+ immer::array<SessionInfo> sessions;
+
+ };
+
+
+// Construction/destruction
+
+ /*! \brief Gets information about a particular user.
+ *
+ * \param userId
+ * The user to look up.
+ */
+ explicit GetWhoIsJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId );
+
+
+ // Result properties
+
+
+
+
+/// The Matrix user ID of the user.
+static std::string userId(Response r);
+
+
+/// Each key is an identifier for one of the user's devices.
+static immer::map<std::string, DeviceInfo> devices(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string userId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+ template<>
+ struct adl_serializer<GetWhoIsJob::ConnectionInfo> {
+
+ static void from_json(const json &jo, GetWhoIsJob::ConnectionInfo& result)
+ {
+
+ result.ip = jo.at("ip"s);
+ result.lastSeen = jo.at("last_seen"s);
+ result.userAgent = jo.at("user_agent"s);
+
+ }
+};
+ template<>
+ struct adl_serializer<GetWhoIsJob::SessionInfo> {
+
+ static void from_json(const json &jo, GetWhoIsJob::SessionInfo& result)
+ {
+
+ result.connections = jo.at("connections"s);
+
+ }
+};
+ template<>
+ struct adl_serializer<GetWhoIsJob::DeviceInfo> {
+
+ static void from_json(const json &jo, GetWhoIsJob::DeviceInfo& result)
+ {
+
+ result.sessions = jo.at("sessions"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/administrative_contact.cpp b/src/csapi/administrative_contact.cpp
new file mode 100644
index 0000000..66369ce
--- /dev/null
+++ b/src/csapi/administrative_contact.cpp
@@ -0,0 +1,329 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "administrative_contact.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body GetAccount3PIDsJob::buildBody()
+ {
+ // ignore unused param
+
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetAccount3PIDsJob::GetAccount3PIDsJob(
+ std::string serverUrl
+ , std::string _accessToken
+
+ )
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/account/3pid",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody()
+ )
+ {
+
+
+ }
+
+
+
+ immer::array<GetAccount3PIDsJob::ThirdPartyIdentifier> GetAccount3PIDsJob::threepids(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("threepids"s)) {
+ return
+ jsonBody(r).get()["threepids"s]
+ /*.get<immer::array<ThirdPartyIdentifier>>()*/;}
+ else { return immer::array<ThirdPartyIdentifier>( );}
+ }
+
+
+
+ BaseJob::Body Post3PIDsJob::buildBody(ThreePidCredentials threePidCreds)
+ {
+ // ignore unused param
+ (void)(threePidCreds);
+
+ json _data
+ ;
+
+ _data["three_pid_creds"s] = threePidCreds;
+
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+Post3PIDsJob::Post3PIDsJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ ThreePidCredentials threePidCreds)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/account/3pid",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(threePidCreds)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body Add3PIDJob::buildBody(std::string clientSecret, std::string sid, std::optional<AuthenticationData> auth)
+ {
+ // ignore unused param
+ (void)(clientSecret);(void)(sid);(void)(auth);
+
+ json _data
+ ;
+
+
+ addToJsonIfNeeded(_data, "auth"s, auth);
+ _data["client_secret"s] = clientSecret;
+
+ _data["sid"s] = sid;
+
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+Add3PIDJob::Add3PIDJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string clientSecret, std::string sid, std::optional<AuthenticationData> auth)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/account/3pid/add",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(clientSecret, sid, auth)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body Bind3PIDJob::buildBody(std::string clientSecret, std::string idServer, std::string idAccessToken, std::string sid)
+ {
+ // ignore unused param
+ (void)(clientSecret);(void)(idServer);(void)(idAccessToken);(void)(sid);
+
+ json _data
+ ;
+
+ _data["client_secret"s] = clientSecret;
+
+ _data["id_server"s] = idServer;
+
+ _data["id_access_token"s] = idAccessToken;
+
+ _data["sid"s] = sid;
+
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+Bind3PIDJob::Bind3PIDJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string clientSecret, std::string idServer, std::string idAccessToken, std::string sid)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/account/3pid/bind",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(clientSecret, idServer, idAccessToken, sid)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body Delete3pidFromAccountJob::buildBody(std::string medium, std::string address, std::string idServer)
+ {
+ // ignore unused param
+ (void)(medium);(void)(address);(void)(idServer);
+
+ json _data
+ ;
+
+
+ addToJsonIfNeeded(_data, "id_server"s, idServer);
+ _data["medium"s] = medium;
+
+ _data["address"s] = address;
+
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+Delete3pidFromAccountJob::Delete3pidFromAccountJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string medium, std::string address, std::string idServer)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/account/3pid/delete",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(medium, address, idServer)
+ )
+ {
+
+
+ //addExpectedKey("id_server_unbind_result");
+ }
+
+
+
+ std::string Delete3pidFromAccountJob::idServerUnbindResult(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("id_server_unbind_result"s)) {
+ return
+ jsonBody(r).get()["id_server_unbind_result"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+
+ BaseJob::Body Unbind3pidFromAccountJob::buildBody(std::string medium, std::string address, std::string idServer)
+ {
+ // ignore unused param
+ (void)(medium);(void)(address);(void)(idServer);
+
+ json _data
+ ;
+
+
+ addToJsonIfNeeded(_data, "id_server"s, idServer);
+ _data["medium"s] = medium;
+
+ _data["address"s] = address;
+
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+Unbind3pidFromAccountJob::Unbind3pidFromAccountJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string medium, std::string address, std::string idServer)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/account/3pid/unbind",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(medium, address, idServer)
+ )
+ {
+
+
+ //addExpectedKey("id_server_unbind_result");
+ }
+
+
+
+ std::string Unbind3pidFromAccountJob::idServerUnbindResult(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("id_server_unbind_result"s)) {
+ return
+ jsonBody(r).get()["id_server_unbind_result"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+
+ BaseJob::Body RequestTokenTo3PIDEmailJob::buildBody(EmailValidationData body)
+ {
+ // ignore unused param
+ (void)(body);
+ return
+ BaseJob::JsonBody(body);
+
+
+
+ };
+
+RequestTokenTo3PIDEmailJob::RequestTokenTo3PIDEmailJob(
+ std::string serverUrl
+
+ ,
+ EmailValidationData body)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/account/3pid/email/requestToken",
+ POST,
+ {} ,
+ ReturnType::Json,
+ buildBody(body)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body RequestTokenTo3PIDMSISDNJob::buildBody(MsisdnValidationData body)
+ {
+ // ignore unused param
+ (void)(body);
+ return
+ BaseJob::JsonBody(body);
+
+
+
+ };
+
+RequestTokenTo3PIDMSISDNJob::RequestTokenTo3PIDMSISDNJob(
+ std::string serverUrl
+
+ ,
+ MsisdnValidationData body)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/account/3pid/msisdn/requestToken",
+ POST,
+ {} ,
+ ReturnType::Json,
+ buildBody(body)
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/administrative_contact.hpp b/src/csapi/administrative_contact.hpp
new file mode 100644
index 0000000..e117093
--- /dev/null
+++ b/src/csapi/administrative_contact.hpp
@@ -0,0 +1,531 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+#include "csapi/definitions/request_msisdn_validation.hpp"
+#include "csapi/definitions/request_token_response.hpp"
+#include "csapi/definitions/request_email_validation.hpp"
+#include "csapi/definitions/auth_data.hpp"
+
+namespace Kazv {
+
+/*! \brief Gets a list of a user's third party identifiers.
+ *
+ * Gets a list of the third party identifiers that the homeserver has
+ * associated with the user's account.
+ *
+ * This is *not* the same as the list of third party identifiers bound to
+ * the user's Matrix ID in identity servers.
+ *
+ * Identifiers in this list may be used by the homeserver as, for example,
+ * identifiers that it will accept to reset the user's account password.
+ */
+class GetAccount3PIDsJob : public BaseJob {
+public:
+ // Inner data structures
+
+/// Gets a list of the third party identifiers that the homeserver has
+/// associated with the user's account.
+///
+/// This is *not* the same as the list of third party identifiers bound to
+/// the user's Matrix ID in identity servers.
+///
+/// Identifiers in this list may be used by the homeserver as, for example,
+/// identifiers that it will accept to reset the user's account password.
+ struct ThirdPartyIdentifier
+ {
+/// The medium of the third party identifier.
+ std::string medium;
+/// The third party identifier address.
+ std::string address;
+/// The timestamp, in milliseconds, when the identifier was
+/// validated by the identity server.
+ std::int_fast64_t validatedAt;
+/// The timestamp, in milliseconds, when the homeserver associated the third party identifier with the user.
+ std::int_fast64_t addedAt;
+
+ };
+
+
+// Construction/destruction
+
+ /// Gets a list of a user's third party identifiers.
+ explicit GetAccount3PIDsJob(std::string serverUrl
+ , std::string _accessToken
+
+ );
+
+
+ // Result properties
+
+
+
+
+/// Gets a list of the third party identifiers that the homeserver has
+/// associated with the user's account.
+///
+/// This is *not* the same as the list of third party identifiers bound to
+/// the user's Matrix ID in identity servers.
+///
+/// Identifiers in this list may be used by the homeserver as, for example,
+/// identifiers that it will accept to reset the user's account password.
+static immer::array<ThirdPartyIdentifier> threepids(Response r);
+
+
+
+ static BaseJob::Body buildBody();
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+ template<>
+ struct adl_serializer<GetAccount3PIDsJob::ThirdPartyIdentifier> {
+
+ static void from_json(const json &jo, GetAccount3PIDsJob::ThirdPartyIdentifier& result)
+ {
+
+ result.medium = jo.at("medium"s);
+ result.address = jo.at("address"s);
+ result.validatedAt = jo.at("validated_at"s);
+ result.addedAt = jo.at("added_at"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Adds contact information to the user's account.
+ *
+ * Adds contact information to the user's account.
+ *
+ * This endpoint is deprecated in favour of the more specific ``/3pid/add``
+ * and ``/3pid/bind`` endpoints.
+ *
+ * .. Note::
+ * Previously this endpoint supported a ``bind`` parameter. This parameter
+ * has been removed, making this endpoint behave as though it was ``false``.
+ * This results in this endpoint being an equivalent to ``/3pid/bind`` rather
+ * than dual-purpose.
+ */
+class Post3PIDsJob : public BaseJob {
+public:
+ // Inner data structures
+
+/// The third party credentials to associate with the account.
+ struct ThreePidCredentials
+ {
+/// The client secret used in the session with the identity server.
+ std::string clientSecret;
+/// The identity server to use.
+ std::string idServer;
+/// An access token previously registered with the identity server. Servers
+/// can treat this as optional to distinguish between r0.5-compatible clients
+/// and this specification version.
+ std::string idAccessToken;
+/// The session identifier given by the identity server.
+ std::string sid;
+
+ };
+
+
+// Construction/destruction
+
+ /*! \brief Adds contact information to the user's account.
+ *
+ * \param threePidCreds
+ * The third party credentials to associate with the account.
+ */
+ explicit Post3PIDsJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ ThreePidCredentials threePidCreds );
+
+
+
+
+ static BaseJob::Body buildBody(ThreePidCredentials threePidCreds);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+ template<>
+ struct adl_serializer<Post3PIDsJob::ThreePidCredentials> {
+ static void to_json(json& jo, const Post3PIDsJob::ThreePidCredentials &pod)
+ {
+
+
+ jo["client_secret"s] = pod.clientSecret;
+
+ jo["id_server"s] = pod.idServer;
+
+ jo["id_access_token"s] = pod.idAccessToken;
+
+ jo["sid"s] = pod.sid;
+
+ }
+
+};
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Adds contact information to the user's account.
+ *
+ * This API endpoint uses the `User-Interactive Authentication API`_.
+ *
+ * Adds contact information to the user's account. Homeservers should use 3PIDs added
+ * through this endpoint for password resets instead of relying on the identity server.
+ *
+ * Homeservers should prevent the caller from adding a 3PID to their account if it has
+ * already been added to another user's account on the homeserver.
+ */
+class Add3PIDJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Adds contact information to the user's account.
+ *
+ * \param clientSecret
+ * The client secret used in the session with the homeserver.
+ *
+ * \param sid
+ * The session identifier given by the homeserver.
+ *
+ * \param auth
+ * Additional authentication information for the
+ * user-interactive authentication API.
+ */
+ explicit Add3PIDJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string clientSecret , std::string sid , std::optional<AuthenticationData> auth = std::nullopt);
+
+
+
+
+ static BaseJob::Body buildBody(std::string clientSecret, std::string sid, std::optional<AuthenticationData> auth);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Binds a 3PID to the user's account through an Identity Service.
+ *
+ * Binds a 3PID to the user's account through the specified identity server.
+ *
+ * Homeservers should not prevent this request from succeeding if another user
+ * has bound the 3PID. Homeservers should simply proxy any errors received by
+ * the identity server to the caller.
+ *
+ * Homeservers should track successful binds so they can be unbound later.
+ */
+class Bind3PIDJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Binds a 3PID to the user's account through an Identity Service.
+ *
+ * \param clientSecret
+ * The client secret used in the session with the identity server.
+ *
+ * \param idServer
+ * The identity server to use.
+ *
+ * \param idAccessToken
+ * An access token previously registered with the identity server.
+ *
+ * \param sid
+ * The session identifier given by the identity server.
+ */
+ explicit Bind3PIDJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string clientSecret , std::string idServer , std::string idAccessToken , std::string sid );
+
+
+
+
+ static BaseJob::Body buildBody(std::string clientSecret, std::string idServer, std::string idAccessToken, std::string sid);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Deletes a third party identifier from the user's account
+ *
+ * Removes a third party identifier from the user's account. This might not
+ * cause an unbind of the identifier from the identity server.
+ *
+ * Unlike other endpoints, this endpoint does not take an ``id_access_token``
+ * parameter because the homeserver is expected to sign the request to the
+ * identity server instead.
+ */
+class Delete3pidFromAccountJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Deletes a third party identifier from the user's account
+ *
+ * \param medium
+ * The medium of the third party identifier being removed.
+ *
+ * \param address
+ * The third party address being removed.
+ *
+ * \param idServer
+ * The identity server to unbind from. If not provided, the homeserver
+ * MUST use the ``id_server`` the identifier was added through. If the
+ * homeserver does not know the original ``id_server``, it MUST return
+ * a ``id_server_unbind_result`` of ``no-support``.
+ */
+ explicit Delete3pidFromAccountJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string medium , std::string address , std::string idServer = {});
+
+
+ // Result properties
+
+
+
+
+/// An indicator as to whether or not the homeserver was able to unbind
+/// the 3PID from the identity server. ``success`` indicates that the
+/// indentity server has unbound the identifier whereas ``no-support``
+/// indicates that the identity server refuses to support the request
+/// or the homeserver was not able to determine an identity server to
+/// unbind from.
+static std::string idServerUnbindResult(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string medium, std::string address, std::string idServer);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Removes a user's third party identifier from an identity server.
+ *
+ * Removes a user's third party identifier from the provided identity server
+ * without removing it from the homeserver.
+ *
+ * Unlike other endpoints, this endpoint does not take an ``id_access_token``
+ * parameter because the homeserver is expected to sign the request to the
+ * identity server instead.
+ */
+class Unbind3pidFromAccountJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Removes a user's third party identifier from an identity server.
+ *
+ * \param medium
+ * The medium of the third party identifier being removed.
+ *
+ * \param address
+ * The third party address being removed.
+ *
+ * \param idServer
+ * The identity server to unbind from. If not provided, the homeserver
+ * MUST use the ``id_server`` the identifier was added through. If the
+ * homeserver does not know the original ``id_server``, it MUST return
+ * a ``id_server_unbind_result`` of ``no-support``.
+ */
+ explicit Unbind3pidFromAccountJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string medium , std::string address , std::string idServer = {});
+
+
+ // Result properties
+
+
+
+
+/// An indicator as to whether or not the identity server was able to unbind
+/// the 3PID. ``success`` indicates that the identity server has unbound the
+/// identifier whereas ``no-support`` indicates that the identity server
+/// refuses to support the request or the homeserver was not able to determine
+/// an identity server to unbind from.
+static std::string idServerUnbindResult(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string medium, std::string address, std::string idServer);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Begins the validation process for an email address for association with the user's account.
+ *
+ * The homeserver must check that the given email address is **not**
+ * already associated with an account on this homeserver. This API should
+ * be used to request validation tokens when adding an email address to an
+ * account. This API's parameters and response are identical to that of
+ * the |/register/email/requestToken|_ endpoint. The homeserver should validate
+ * the email itself, either by sending a validation email itself or by using
+ * a service it has control over.
+ */
+class RequestTokenTo3PIDEmailJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Begins the validation process for an email address for association with the user's account.
+ *
+ * \param body
+ * The homeserver must check that the given email address is **not**
+ * already associated with an account on this homeserver. This API should
+ * be used to request validation tokens when adding an email address to an
+ * account. This API's parameters and response are identical to that of
+ * the |/register/email/requestToken|_ endpoint. The homeserver should validate
+ * the email itself, either by sending a validation email itself or by using
+ * a service it has control over.
+ */
+ explicit RequestTokenTo3PIDEmailJob(std::string serverUrl
+
+ ,
+ EmailValidationData body );
+
+
+ // Result properties
+
+
+/// An email was sent to the given address. Note that this may be an
+/// email containing the validation token or it may be informing the
+/// user of an error.
+ static RequestTokenResponse data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<RequestTokenResponse>()
+ ;
+ }
+
+
+
+
+ static BaseJob::Body buildBody(EmailValidationData body);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Begins the validation process for a phone number for association with the user's account.
+ *
+ * The homeserver must check that the given phone number is **not**
+ * already associated with an account on this homeserver. This API should
+ * be used to request validation tokens when adding a phone number to an
+ * account. This API's parameters and response are identical to that of
+ * the |/register/msisdn/requestToken|_ endpoint. The homeserver should validate
+ * the phone number itself, either by sending a validation message itself or by using
+ * a service it has control over.
+ */
+class RequestTokenTo3PIDMSISDNJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Begins the validation process for a phone number for association with the user's account.
+ *
+ * \param body
+ * The homeserver must check that the given phone number is **not**
+ * already associated with an account on this homeserver. This API should
+ * be used to request validation tokens when adding a phone number to an
+ * account. This API's parameters and response are identical to that of
+ * the |/register/msisdn/requestToken|_ endpoint. The homeserver should validate
+ * the phone number itself, either by sending a validation message itself or by using
+ * a service it has control over.
+ */
+ explicit RequestTokenTo3PIDMSISDNJob(std::string serverUrl
+
+ ,
+ MsisdnValidationData body );
+
+
+ // Result properties
+
+
+/// An SMS message was sent to the given phone number.
+ static RequestTokenResponse data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<RequestTokenResponse>()
+ ;
+ }
+
+
+
+
+ static BaseJob::Body buildBody(MsisdnValidationData body);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/appservice_room_directory.cpp b/src/csapi/appservice_room_directory.cpp
new file mode 100644
index 0000000..4579cd4
--- /dev/null
+++ b/src/csapi/appservice_room_directory.cpp
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "appservice_room_directory.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body UpdateAppserviceRoomDirectoryVsibilityJob::buildBody(std::string networkId, std::string roomId, std::string visibility)
+ {
+ // ignore unused param
+ (void)(networkId);(void)(roomId);(void)(visibility);
+
+ json _data
+ ;
+
+ _data["visibility"s] = visibility;
+
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+UpdateAppserviceRoomDirectoryVsibilityJob::UpdateAppserviceRoomDirectoryVsibilityJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string networkId, std::string roomId, std::string visibility)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/directory/list/appservice/" + networkId + "/" + roomId,
+ PUT,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(networkId, roomId, visibility)
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/appservice_room_directory.hpp b/src/csapi/appservice_room_directory.hpp
new file mode 100644
index 0000000..a44523d
--- /dev/null
+++ b/src/csapi/appservice_room_directory.hpp
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Updates a room's visibility in the application service's room directory.
+ *
+ * Updates the visibility of a given room on the application service's room
+ * directory.
+ *
+ * This API is similar to the room directory visibility API used by clients
+ * to update the homeserver's more general room directory.
+ *
+ * This API requires the use of an application service access token (``as_token``)
+ * instead of a typical client's access_token. This API cannot be invoked by
+ * users who are not identified as application services.
+ */
+class UpdateAppserviceRoomDirectoryVsibilityJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Updates a room's visibility in the application service's room directory.
+ *
+ * \param networkId
+ * The protocol (network) ID to update the room list for. This would
+ * have been provided by the application service as being listed as
+ * a supported protocol.
+ *
+ * \param roomId
+ * The room ID to add to the directory.
+ *
+ * \param visibility
+ * Whether the room should be visible (public) in the directory
+ * or not (private).
+ */
+ explicit UpdateAppserviceRoomDirectoryVsibilityJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string networkId , std::string roomId , std::string visibility );
+
+
+
+
+ static BaseJob::Body buildBody(std::string networkId, std::string roomId, std::string visibility);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/banning.cpp b/src/csapi/banning.cpp
new file mode 100644
index 0000000..e681ae9
--- /dev/null
+++ b/src/csapi/banning.cpp
@@ -0,0 +1,81 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "banning.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body BanJob::buildBody(std::string roomId, std::string userId, std::string reason)
+ {
+ // ignore unused param
+ (void)(roomId);(void)(userId);(void)(reason);
+
+ json _data
+ ;
+
+ _data["user_id"s] = userId;
+
+
+ addToJsonIfNeeded(_data, "reason"s, reason);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+BanJob::BanJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId, std::string userId, std::string reason)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/ban",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId, userId, reason)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body UnbanJob::buildBody(std::string roomId, std::string userId)
+ {
+ // ignore unused param
+ (void)(roomId);(void)(userId);
+
+ json _data
+ ;
+
+ _data["user_id"s] = userId;
+
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+UnbanJob::UnbanJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId, std::string userId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/unban",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId, userId)
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/banning.hpp b/src/csapi/banning.hpp
new file mode 100644
index 0000000..1f59d24
--- /dev/null
+++ b/src/csapi/banning.hpp
@@ -0,0 +1,100 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Ban a user in the room.
+ *
+ * Ban a user in the room. If the user is currently in the room, also kick them.
+ *
+ * When a user is banned from a room, they may not join it or be invited to it until they are unbanned.
+ *
+ * The caller must have the required power level in order to perform this operation.
+ */
+class BanJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Ban a user in the room.
+ *
+ * \param roomId
+ * The room identifier (not alias) from which the user should be banned.
+ *
+ * \param userId
+ * The fully qualified user ID of the user being banned.
+ *
+ * \param reason
+ * The reason the user has been banned. This will be supplied as the ``reason`` on the target's updated `m.room.member`_ event.
+ */
+ explicit BanJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId , std::string userId , std::string reason = {});
+
+
+
+
+ static BaseJob::Body buildBody(std::string roomId, std::string userId, std::string reason);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Unban a user from the room.
+ *
+ * Unban a user from the room. This allows them to be invited to the room,
+ * and join if they would otherwise be allowed to join according to its join rules.
+ *
+ * The caller must have the required power level in order to perform this operation.
+ */
+class UnbanJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Unban a user from the room.
+ *
+ * \param roomId
+ * The room identifier (not alias) from which the user should be unbanned.
+ *
+ * \param userId
+ * The fully qualified user ID of the user being unbanned.
+ */
+ explicit UnbanJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId , std::string userId );
+
+
+
+
+ static BaseJob::Body buildBody(std::string roomId, std::string userId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/capabilities.cpp b/src/csapi/capabilities.cpp
new file mode 100644
index 0000000..aeff241
--- /dev/null
+++ b/src/csapi/capabilities.cpp
@@ -0,0 +1,51 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "capabilities.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body GetCapabilitiesJob::buildBody()
+ {
+ // ignore unused param
+
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetCapabilitiesJob::GetCapabilitiesJob(
+ std::string serverUrl
+ , std::string _accessToken
+
+ )
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/capabilities",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody()
+ )
+ {
+
+
+ //addExpectedKey("capabilities");
+ }
+
+
+
+ GetCapabilitiesJob::Capabilities GetCapabilitiesJob::capabilities(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("capabilities"s)) {
+ return
+ jsonBody(r).get()["capabilities"s]
+ /*.get<Capabilities>()*/;}
+ else { return Capabilities( );}
+ }
+
+}
diff --git a/src/csapi/capabilities.hpp b/src/csapi/capabilities.hpp
new file mode 100644
index 0000000..4888f2c
--- /dev/null
+++ b/src/csapi/capabilities.hpp
@@ -0,0 +1,117 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Gets information about the server's capabilities.
+ *
+ * Gets information about the server's supported feature set
+ * and other relevant capabilities.
+ */
+class GetCapabilitiesJob : public BaseJob {
+public:
+ // Inner data structures
+
+/// Capability to indicate if the user can change their password.
+ struct ChangePasswordCapability
+ {
+/// True if the user can change their password, false otherwise.
+ bool enabled;
+
+ };
+
+/// The room versions the server supports.
+ struct RoomVersionsCapability
+ {
+/// The default room version the server is using for new rooms.
+ std::string defaultVersion;
+/// A detailed description of the room versions the server supports.
+ immer::map<std::string, std::string> available;
+
+ };
+
+/// The custom capabilities the server supports, using the
+/// Java package naming convention.
+ struct Capabilities
+ {
+/// Capability to indicate if the user can change their password.
+ std::optional<ChangePasswordCapability> changePassword;
+/// The room versions the server supports.
+ std::optional<RoomVersionsCapability> roomVersions;
+/// The custom capabilities the server supports, using the
+/// Java package naming convention.
+ immer::map<std::string, JsonWrap> additionalProperties;
+ };
+
+
+// Construction/destruction
+
+ /// Gets information about the server's capabilities.
+ explicit GetCapabilitiesJob(std::string serverUrl
+ , std::string _accessToken
+
+ );
+
+
+ // Result properties
+
+
+
+
+/// The custom capabilities the server supports, using the
+/// Java package naming convention.
+static Capabilities capabilities(Response r);
+
+
+
+ static BaseJob::Body buildBody();
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+ template<>
+ struct adl_serializer<GetCapabilitiesJob::ChangePasswordCapability> {
+
+ static void from_json(const json &jo, GetCapabilitiesJob::ChangePasswordCapability& result)
+ {
+
+ result.enabled = jo.at("enabled"s);
+
+ }
+};
+ template<>
+ struct adl_serializer<GetCapabilitiesJob::RoomVersionsCapability> {
+
+ static void from_json(const json &jo, GetCapabilitiesJob::RoomVersionsCapability& result)
+ {
+
+ result.defaultVersion = jo.at("default"s);
+ result.available = jo.at("available"s);
+
+ }
+};
+ template<>
+ struct adl_serializer<GetCapabilitiesJob::Capabilities> {
+
+ static void from_json(const json &jo, GetCapabilitiesJob::Capabilities& result)
+ {
+
+ result.changePassword = jo.at("m.change_password"s);
+ result.roomVersions = jo.at("m.room_versions"s);
+ result.additionalProperties = jo;
+ }
+};
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/content-repo.cpp b/src/csapi/content-repo.cpp
new file mode 100644
index 0000000..4ab847b
--- /dev/null
+++ b/src/csapi/content-repo.cpp
@@ -0,0 +1,286 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "content-repo.hpp"
+
+namespace Kazv
+{
+
+BaseJob::Query UploadContentJob::buildQuery(
+std::string filename)
+{
+BaseJob::Query _q;
+
+ addToQueryIfNeeded(_q, "filename"s, filename);
+return _q;
+}
+
+ BaseJob::Body UploadContentJob::buildBody(Bytes content, std::string filename, std::string contentType)
+ {
+ // ignore unused param
+ (void)(content);(void)(filename);(void)(contentType);
+ return BaseJob::BytesBody(content)
+ ;
+
+
+
+ };
+
+UploadContentJob::UploadContentJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ Bytes content, std::string filename, std::string contentType)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/media/r0") + "/upload",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(content, filename, contentType)
+ , buildQuery(filename))
+ {
+ //setRequestHeader("Content-Type", contentType.toLatin1());
+
+ //addExpectedKey("content_uri");
+ }
+
+
+
+ std::string UploadContentJob::contentUri(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("content_uri"s)) {
+ return
+ jsonBody(r).get()["content_uri"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+BaseJob::Query GetContentJob::buildQuery(
+bool allowRemote)
+{
+BaseJob::Query _q;
+
+ addToQueryIfNeeded(_q, "allow_remote"s, allowRemote);
+return _q;
+}
+
+ BaseJob::Body GetContentJob::buildBody(std::string serverName, std::string mediaId, bool allowRemote)
+ {
+ // ignore unused param
+ (void)(serverName);(void)(mediaId);(void)(allowRemote);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetContentJob::GetContentJob(
+ std::string serverUrl
+
+ ,
+ std::string serverName, std::string mediaId, bool allowRemote)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/media/r0") + "/download/" + serverName + "/" + mediaId,
+ GET,
+ {} ,
+ ReturnType::Byte,
+ buildBody(serverName, mediaId, allowRemote)
+ , buildQuery(allowRemote))
+ {
+
+ //setExpectedContentTypes({ "*/*" });
+
+ }
+
+
+
+BaseJob::Query GetContentOverrideNameJob::buildQuery(
+bool allowRemote)
+{
+BaseJob::Query _q;
+
+ addToQueryIfNeeded(_q, "allow_remote"s, allowRemote);
+return _q;
+}
+
+ BaseJob::Body GetContentOverrideNameJob::buildBody(std::string serverName, std::string mediaId, std::string fileName, bool allowRemote)
+ {
+ // ignore unused param
+ (void)(serverName);(void)(mediaId);(void)(fileName);(void)(allowRemote);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetContentOverrideNameJob::GetContentOverrideNameJob(
+ std::string serverUrl
+
+ ,
+ std::string serverName, std::string mediaId, std::string fileName, bool allowRemote)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/media/r0") + "/download/" + serverName + "/" + mediaId + "/" + fileName,
+ GET,
+ {} ,
+ ReturnType::Byte,
+ buildBody(serverName, mediaId, fileName, allowRemote)
+ , buildQuery(allowRemote))
+ {
+
+ //setExpectedContentTypes({ "*/*" });
+
+ }
+
+
+
+BaseJob::Query GetContentThumbnailJob::buildQuery(
+int width, int height, std::string method, bool allowRemote)
+{
+BaseJob::Query _q;
+ addToQuery(_q, "width"s, width);
+
+ addToQuery(_q, "height"s, height);
+
+
+ addToQueryIfNeeded(_q, "method"s, method);
+
+ addToQueryIfNeeded(_q, "allow_remote"s, allowRemote);
+return _q;
+}
+
+ BaseJob::Body GetContentThumbnailJob::buildBody(std::string serverName, std::string mediaId, int width, int height, std::string method, bool allowRemote)
+ {
+ // ignore unused param
+ (void)(serverName);(void)(mediaId);(void)(width);(void)(height);(void)(method);(void)(allowRemote);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetContentThumbnailJob::GetContentThumbnailJob(
+ std::string serverUrl
+
+ ,
+ std::string serverName, std::string mediaId, int width, int height, std::string method, bool allowRemote)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/media/r0") + "/thumbnail/" + serverName + "/" + mediaId,
+ GET,
+ {} ,
+ ReturnType::Byte,
+ buildBody(serverName, mediaId, width, height, method, allowRemote)
+ , buildQuery(width, height, method, allowRemote))
+ {
+
+ //setExpectedContentTypes({ "image/jpeg", "image/png" });
+
+ }
+
+
+
+BaseJob::Query GetUrlPreviewJob::buildQuery(
+std::string url, std::optional<std::int_fast64_t> ts)
+{
+BaseJob::Query _q;
+ addToQuery(_q, "url"s, url);
+
+
+ addToQueryIfNeeded(_q, "ts"s, ts);
+return _q;
+}
+
+ BaseJob::Body GetUrlPreviewJob::buildBody(std::string url, std::optional<std::int_fast64_t> ts)
+ {
+ // ignore unused param
+ (void)(url);(void)(ts);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetUrlPreviewJob::GetUrlPreviewJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string url, std::optional<std::int_fast64_t> ts)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/media/r0") + "/preview_url",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(url, ts)
+ , buildQuery(url, ts))
+ {
+
+
+ }
+
+
+
+ std::optional<std::int_fast64_t> GetUrlPreviewJob::matrixImageSize(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("matrix:image:size"s)) {
+ return
+ jsonBody(r).get()["matrix:image:size"s]
+ /*.get<std::int_fast64_t>()*/;}
+ else { return std::optional<std::int_fast64_t>( );}
+ }
+
+
+ std::string GetUrlPreviewJob::ogImage(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("og:image"s)) {
+ return
+ jsonBody(r).get()["og:image"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+
+ BaseJob::Body GetConfigJob::buildBody()
+ {
+ // ignore unused param
+
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetConfigJob::GetConfigJob(
+ std::string serverUrl
+ , std::string _accessToken
+
+ )
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/media/r0") + "/config",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody()
+ )
+ {
+
+
+ }
+
+
+
+ std::optional<std::int_fast64_t> GetConfigJob::uploadSize(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("m.upload.size"s)) {
+ return
+ jsonBody(r).get()["m.upload.size"s]
+ /*.get<std::int_fast64_t>()*/;}
+ else { return std::optional<std::int_fast64_t>( );}
+ }
+
+}
diff --git a/src/csapi/content-repo.hpp b/src/csapi/content-repo.hpp
new file mode 100644
index 0000000..36016b7
--- /dev/null
+++ b/src/csapi/content-repo.hpp
@@ -0,0 +1,398 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+#include "types.hpp"
+
+namespace Kazv {
+
+/*! \brief Upload some content to the content repository.
+ *
+ */
+class UploadContentJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Upload some content to the content repository.
+ *
+ * \param content
+ * The content to be uploaded.
+ *
+ * \param filename
+ * The name of the file being uploaded
+ *
+ * \param contentType
+ * The content type of the file being uploaded
+ */
+ explicit UploadContentJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ Bytes content , std::string filename = {}, std::string contentType = {});
+
+
+ // Result properties
+
+
+
+
+/// The `MXC URI`_ to the uploaded content.
+static std::string contentUri(Response r);
+
+ static BaseJob::Query buildQuery(
+ std::string filename);
+
+ static BaseJob::Body buildBody(Bytes content, std::string filename, std::string contentType);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Download content from the content repository.
+ *
+ */
+class GetContentJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Download content from the content repository.
+ *
+ * \param serverName
+ * The server name from the ``mxc://`` URI (the authoritory component)
+ *
+ * \param mediaId
+ * The media ID from the ``mxc://`` URI (the path component)
+ *
+ * \param allowRemote
+ * Indicates to the server that it should not attempt to fetch the media if it is deemed
+ * remote. This is to prevent routing loops where the server contacts itself. Defaults to
+ * true if not provided.
+ */
+ explicit GetContentJob(std::string serverUrl
+
+ ,
+ std::string serverName , std::string mediaId , bool allowRemote = true);
+
+
+ // Result properties
+/*
+/// The content type of the file that was previously uploaded.
+static std::string contentType(Response r)
+ {
+ return reply()->rawHeader("Content-Type");
+ }
+*/
+/*
+/// The name of the file that was previously uploaded, if set.
+static std::string contentDisposition(Response r)
+ {
+ return reply()->rawHeader("Content-Disposition");
+ }
+*/
+
+/// The content that was previously uploaded.
+ static Bytes data(Response r)
+ {
+ return
+ std::get<Bytes>(r.body)
+
+ ;
+ }
+
+
+ static BaseJob::Query buildQuery(
+ bool allowRemote);
+
+ static BaseJob::Body buildBody(std::string serverName, std::string mediaId, bool allowRemote);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Download content from the content repository overriding the file name
+ *
+ * This will download content from the content repository (same as
+ * the previous endpoint) but replace the target file name with the one
+ * provided by the caller.
+ */
+class GetContentOverrideNameJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Download content from the content repository overriding the file name
+ *
+ * \param serverName
+ * The server name from the ``mxc://`` URI (the authoritory component)
+ *
+ * \param mediaId
+ * The media ID from the ``mxc://`` URI (the path component)
+ *
+ * \param fileName
+ * A filename to give in the ``Content-Disposition`` header.
+ *
+ * \param allowRemote
+ * Indicates to the server that it should not attempt to fetch the media if it is deemed
+ * remote. This is to prevent routing loops where the server contacts itself. Defaults to
+ * true if not provided.
+ */
+ explicit GetContentOverrideNameJob(std::string serverUrl
+
+ ,
+ std::string serverName , std::string mediaId , std::string fileName , bool allowRemote = true);
+
+
+ // Result properties
+/*
+/// The content type of the file that was previously uploaded.
+static std::string contentType(Response r)
+ {
+ return reply()->rawHeader("Content-Type");
+ }
+*/
+/*
+/// The ``fileName`` requested or the name of the file that was previously
+/// uploaded, if set.
+static std::string contentDisposition(Response r)
+ {
+ return reply()->rawHeader("Content-Disposition");
+ }
+*/
+
+/// The content that was previously uploaded.
+ static Bytes data(Response r)
+ {
+ return
+ std::get<Bytes>(r.body)
+
+ ;
+ }
+
+
+ static BaseJob::Query buildQuery(
+ bool allowRemote);
+
+ static BaseJob::Body buildBody(std::string serverName, std::string mediaId, std::string fileName, bool allowRemote);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Download a thumbnail of content from the content repository
+ *
+ * Download a thumbnail of content from the content repository.
+ * See the `thumbnailing <#thumbnails>`_ section for more information.
+ */
+class GetContentThumbnailJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Download a thumbnail of content from the content repository
+ *
+ * \param serverName
+ * The server name from the ``mxc://`` URI (the authoritory component)
+ *
+ * \param mediaId
+ * The media ID from the ``mxc://`` URI (the path component)
+ *
+ * \param width
+ * The *desired* width of the thumbnail. The actual thumbnail may be
+ * larger than the size specified.
+ *
+ * \param height
+ * The *desired* height of the thumbnail. The actual thumbnail may be
+ * larger than the size specified.
+ *
+ * \param method
+ * The desired resizing method. See the `thumbnailing <#thumbnails>`_
+ * section for more information.
+ *
+ * \param allowRemote
+ * Indicates to the server that it should not attempt to fetch
+ * the media if it is deemed remote. This is to prevent routing loops
+ * where the server contacts itself. Defaults to true if not provided.
+ */
+ explicit GetContentThumbnailJob(std::string serverUrl
+
+ ,
+ std::string serverName , std::string mediaId , int width , int height , std::string method = {}, bool allowRemote = true);
+
+
+ // Result properties
+/*
+/// The content type of the thumbnail.
+static std::string contentType(Response r)
+ {
+ return reply()->rawHeader("Content-Type");
+ }
+*/
+
+/// A thumbnail of the requested content.
+ static Bytes data(Response r)
+ {
+ return
+ std::get<Bytes>(r.body)
+
+ ;
+ }
+
+
+ static BaseJob::Query buildQuery(
+ int width, int height, std::string method, bool allowRemote);
+
+ static BaseJob::Body buildBody(std::string serverName, std::string mediaId, int width, int height, std::string method, bool allowRemote);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Get information about a URL for a client
+ *
+ * Get information about a URL for the client. Typically this is called when a
+ * client sees a URL in a message and wants to render a preview for the user.
+ *
+ * .. Note::
+ * Clients should consider avoiding this endpoint for URLs posted in encrypted
+ * rooms. Encrypted rooms often contain more sensitive information the users
+ * do not want to share with the homeserver, and this can mean that the URLs
+ * being shared should also not be shared with the homeserver.
+ */
+class GetUrlPreviewJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Get information about a URL for a client
+ *
+ * \param url
+ * The URL to get a preview of.
+ *
+ * \param ts
+ * The preferred point in time to return a preview for. The server may
+ * return a newer version if it does not have the requested version
+ * available.
+ */
+ explicit GetUrlPreviewJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string url , std::optional<std::int_fast64_t> ts = std::nullopt);
+
+
+ // Result properties
+
+
+
+
+/// The byte-size of the image. Omitted if there is no image attached.
+static std::optional<std::int_fast64_t> matrixImageSize(Response r);
+
+
+/// An `MXC URI`_ to the image. Omitted if there is no image.
+static std::string ogImage(Response r);
+
+ static BaseJob::Query buildQuery(
+ std::string url, std::optional<std::int_fast64_t> ts);
+
+ static BaseJob::Body buildBody(std::string url, std::optional<std::int_fast64_t> ts);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Get the configuration for the content repository.
+ *
+ * This endpoint allows clients to retrieve the configuration of the content
+ * repository, such as upload limitations.
+ * Clients SHOULD use this as a guide when using content repository endpoints.
+ * All values are intentionally left optional. Clients SHOULD follow
+ * the advice given in the field description when the field is not available.
+ *
+ * **NOTE:** Both clients and server administrators should be aware that proxies
+ * between the client and the server may affect the apparent behaviour of content
+ * repository APIs, for example, proxies may enforce a lower upload size limit
+ * than is advertised by the server on this endpoint.
+ */
+class GetConfigJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /// Get the configuration for the content repository.
+ explicit GetConfigJob(std::string serverUrl
+ , std::string _accessToken
+
+ );
+
+
+ // Result properties
+
+
+
+
+/// The maximum size an upload can be in bytes.
+/// Clients SHOULD use this as a guide when uploading content.
+/// If not listed or null, the size limit should be treated as unknown.
+static std::optional<std::int_fast64_t> uploadSize(Response r);
+
+
+
+ static BaseJob::Body buildBody();
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/create_room.cpp b/src/csapi/create_room.cpp
new file mode 100644
index 0000000..41d46a6
--- /dev/null
+++ b/src/csapi/create_room.cpp
@@ -0,0 +1,78 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "create_room.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body CreateRoomJob::buildBody(std::string visibility, std::string roomAliasName, std::string name, std::string topic, immer::array<std::string> invite, immer::array<Invite3pid> invite3pid, std::string roomVersion, JsonWrap creationContent, immer::array<StateEvent> initialState, std::string preset, std::optional<bool> isDirect, JsonWrap powerLevelContentOverride)
+ {
+ // ignore unused param
+ (void)(visibility);(void)(roomAliasName);(void)(name);(void)(topic);(void)(invite);(void)(invite3pid);(void)(roomVersion);(void)(creationContent);(void)(initialState);(void)(preset);(void)(isDirect);(void)(powerLevelContentOverride);
+
+ json _data
+ ;
+
+
+ addToJsonIfNeeded(_data, "visibility"s, visibility);
+
+ addToJsonIfNeeded(_data, "room_alias_name"s, roomAliasName);
+
+ addToJsonIfNeeded(_data, "name"s, name);
+
+ addToJsonIfNeeded(_data, "topic"s, topic);
+
+ addToJsonIfNeeded(_data, "invite"s, invite);
+
+ addToJsonIfNeeded(_data, "invite_3pid"s, invite3pid);
+
+ addToJsonIfNeeded(_data, "room_version"s, roomVersion);
+
+ addToJsonIfNeeded(_data, "creation_content"s, creationContent);
+
+ addToJsonIfNeeded(_data, "initial_state"s, initialState);
+
+ addToJsonIfNeeded(_data, "preset"s, preset);
+
+ addToJsonIfNeeded(_data, "is_direct"s, isDirect);
+
+ addToJsonIfNeeded(_data, "power_level_content_override"s, powerLevelContentOverride);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+CreateRoomJob::CreateRoomJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string visibility, std::string roomAliasName, std::string name, std::string topic, immer::array<std::string> invite, immer::array<Invite3pid> invite3pid, std::string roomVersion, JsonWrap creationContent, immer::array<StateEvent> initialState, std::string preset, std::optional<bool> isDirect, JsonWrap powerLevelContentOverride)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/createRoom",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(visibility, roomAliasName, name, topic, invite, invite3pid, roomVersion, creationContent, initialState, preset, isDirect, powerLevelContentOverride)
+ )
+ {
+
+
+ //addExpectedKey("room_id");
+ }
+
+
+
+ std::string CreateRoomJob::roomId(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("room_id"s)) {
+ return
+ jsonBody(r).get()["room_id"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+}
diff --git a/src/csapi/create_room.hpp b/src/csapi/create_room.hpp
new file mode 100644
index 0000000..f01b11e
--- /dev/null
+++ b/src/csapi/create_room.hpp
@@ -0,0 +1,311 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Create a new room
+ *
+ * Create a new room with various configuration options.
+ *
+ * The server MUST apply the normal state resolution rules when creating
+ * the new room, including checking power levels for each event. It MUST
+ * apply the events implied by the request in the following order:
+ *
+ * 1. The ``m.room.create`` event itself. Must be the first event in the
+ * room.
+ *
+ * 2. An ``m.room.member`` event for the creator to join the room. This is
+ * needed so the remaining events can be sent.
+ *
+ * 3. A default ``m.room.power_levels`` event, giving the room creator
+ * (and not other members) permission to send state events. Overridden
+ * by the ``power_level_content_override`` parameter.
+ *
+ * 4. Events set by the ``preset``. Currently these are the ``m.room.join_rules``,
+ * ``m.room.history_visibility``, and ``m.room.guest_access`` state events.
+ *
+ * 5. Events listed in ``initial_state``, in the order that they are
+ * listed.
+ *
+ * 6. Events implied by ``name`` and ``topic`` (``m.room.name`` and ``m.room.topic``
+ * state events).
+ *
+ * 7. Invite events implied by ``invite`` and ``invite_3pid`` (``m.room.member`` with
+ * ``membership: invite`` and ``m.room.third_party_invite``).
+ *
+ * The available presets do the following with respect to room state:
+ *
+ * ======================== ============== ====================== ================ =========
+ * Preset ``join_rules`` ``history_visibility`` ``guest_access`` Other
+ * ======================== ============== ====================== ================ =========
+ * ``private_chat`` ``invite`` ``shared`` ``can_join``
+ * ``trusted_private_chat`` ``invite`` ``shared`` ``can_join`` All invitees are given the same power level as the room creator.
+ * ``public_chat`` ``public`` ``shared`` ``forbidden``
+ * ======================== ============== ====================== ================ =========
+ *
+ * The server will create a ``m.room.create`` event in the room with the
+ * requesting user as the creator, alongside other keys provided in the
+ * ``creation_content``.
+ */
+class CreateRoomJob : public BaseJob {
+public:
+ // Inner data structures
+
+/// Create a new room with various configuration options.
+///
+/// The server MUST apply the normal state resolution rules when creating
+/// the new room, including checking power levels for each event. It MUST
+/// apply the events implied by the request in the following order:
+///
+/// 1. The ``m.room.create`` event itself. Must be the first event in the
+/// room.
+///
+/// 2. An ``m.room.member`` event for the creator to join the room. This is
+/// needed so the remaining events can be sent.
+///
+/// 3. A default ``m.room.power_levels`` event, giving the room creator
+/// (and not other members) permission to send state events. Overridden
+/// by the ``power_level_content_override`` parameter.
+///
+/// 4. Events set by the ``preset``. Currently these are the ``m.room.join_rules``,
+/// ``m.room.history_visibility``, and ``m.room.guest_access`` state events.
+///
+/// 5. Events listed in ``initial_state``, in the order that they are
+/// listed.
+///
+/// 6. Events implied by ``name`` and ``topic`` (``m.room.name`` and ``m.room.topic``
+/// state events).
+///
+/// 7. Invite events implied by ``invite`` and ``invite_3pid`` (``m.room.member`` with
+/// ``membership: invite`` and ``m.room.third_party_invite``).
+///
+/// The available presets do the following with respect to room state:
+///
+/// ======================== ============== ====================== ================ =========
+/// Preset ``join_rules`` ``history_visibility`` ``guest_access`` Other
+/// ======================== ============== ====================== ================ =========
+/// ``private_chat`` ``invite`` ``shared`` ``can_join``
+/// ``trusted_private_chat`` ``invite`` ``shared`` ``can_join`` All invitees are given the same power level as the room creator.
+/// ``public_chat`` ``public`` ``shared`` ``forbidden``
+/// ======================== ============== ====================== ================ =========
+///
+/// The server will create a ``m.room.create`` event in the room with the
+/// requesting user as the creator, alongside other keys provided in the
+/// ``creation_content``.
+ struct Invite3pid
+ {
+/// The hostname+port of the identity server which should be used for third party identifier lookups.
+ std::string idServer;
+/// An access token previously registered with the identity server. Servers
+/// can treat this as optional to distinguish between r0.5-compatible clients
+/// and this specification version.
+ std::string idAccessToken;
+/// The kind of address being passed in the address field, for example ``email``.
+ std::string medium;
+/// The invitee's third party identifier.
+ std::string address;
+
+ };
+
+/// Create a new room with various configuration options.
+///
+/// The server MUST apply the normal state resolution rules when creating
+/// the new room, including checking power levels for each event. It MUST
+/// apply the events implied by the request in the following order:
+///
+/// 1. The ``m.room.create`` event itself. Must be the first event in the
+/// room.
+///
+/// 2. An ``m.room.member`` event for the creator to join the room. This is
+/// needed so the remaining events can be sent.
+///
+/// 3. A default ``m.room.power_levels`` event, giving the room creator
+/// (and not other members) permission to send state events. Overridden
+/// by the ``power_level_content_override`` parameter.
+///
+/// 4. Events set by the ``preset``. Currently these are the ``m.room.join_rules``,
+/// ``m.room.history_visibility``, and ``m.room.guest_access`` state events.
+///
+/// 5. Events listed in ``initial_state``, in the order that they are
+/// listed.
+///
+/// 6. Events implied by ``name`` and ``topic`` (``m.room.name`` and ``m.room.topic``
+/// state events).
+///
+/// 7. Invite events implied by ``invite`` and ``invite_3pid`` (``m.room.member`` with
+/// ``membership: invite`` and ``m.room.third_party_invite``).
+///
+/// The available presets do the following with respect to room state:
+///
+/// ======================== ============== ====================== ================ =========
+/// Preset ``join_rules`` ``history_visibility`` ``guest_access`` Other
+/// ======================== ============== ====================== ================ =========
+/// ``private_chat`` ``invite`` ``shared`` ``can_join``
+/// ``trusted_private_chat`` ``invite`` ``shared`` ``can_join`` All invitees are given the same power level as the room creator.
+/// ``public_chat`` ``public`` ``shared`` ``forbidden``
+/// ======================== ============== ====================== ================ =========
+///
+/// The server will create a ``m.room.create`` event in the room with the
+/// requesting user as the creator, alongside other keys provided in the
+/// ``creation_content``.
+ struct StateEvent
+ {
+/// The type of event to send.
+ std::string type;
+/// The state_key of the state event. Defaults to an empty string.
+ std::string stateKey;
+/// The content of the event.
+ JsonWrap content;
+
+ };
+
+
+// Construction/destruction
+
+ /*! \brief Create a new room
+ *
+ * \param visibility
+ * A ``public`` visibility indicates that the room will be shown
+ * in the published room list. A ``private`` visibility will hide
+ * the room from the published room list. Rooms default to
+ * ``private`` visibility if this key is not included. NB: This
+ * should not be confused with ``join_rules`` which also uses the
+ * word ``public``.
+ *
+ * \param roomAliasName
+ * The desired room alias **local part**. If this is included, a
+ * room alias will be created and mapped to the newly created
+ * room. The alias will belong on the *same* homeserver which
+ * created the room. For example, if this was set to "foo" and
+ * sent to the homeserver "example.com" the complete room alias
+ * would be ``#foo:example.com``.
+ *
+ * The complete room alias will become the canonical alias for
+ * the room.
+ *
+ * \param name
+ * If this is included, an ``m.room.name`` event will be sent
+ * into the room to indicate the name of the room. See Room
+ * Events for more information on ``m.room.name``.
+ *
+ * \param topic
+ * If this is included, an ``m.room.topic`` event will be sent
+ * into the room to indicate the topic for the room. See Room
+ * Events for more information on ``m.room.topic``.
+ *
+ * \param invite
+ * A list of user IDs to invite to the room. This will tell the
+ * server to invite everyone in the list to the newly created room.
+ *
+ * \param invite3pid
+ * A list of objects representing third party IDs to invite into
+ * the room.
+ *
+ * \param roomVersion
+ * The room version to set for the room. If not provided, the homeserver is
+ * to use its configured default. If provided, the homeserver will return a
+ * 400 error with the errcode ``M_UNSUPPORTED_ROOM_VERSION`` if it does not
+ * support the room version.
+ *
+ * \param creationContent
+ * Extra keys, such as ``m.federate``, to be added to the content
+ * of the `m.room.create`_ event. The server will clobber the following
+ * keys: ``creator``, ``room_version``. Future versions of the specification
+ * may allow the server to clobber other keys.
+ *
+ * \param initialState
+ * A list of state events to set in the new room. This allows
+ * the user to override the default state events set in the new
+ * room. The expected format of the state events are an object
+ * with type, state_key and content keys set.
+ *
+ * Takes precedence over events set by ``preset``, but gets
+ * overriden by ``name`` and ``topic`` keys.
+ *
+ * \param preset
+ * Convenience parameter for setting various default state events
+ * based on a preset.
+ *
+ * If unspecified, the server should use the ``visibility`` to determine
+ * which preset to use. A visbility of ``public`` equates to a preset of
+ * ``public_chat`` and ``private`` visibility equates to a preset of
+ * ``private_chat``.
+ *
+ * \param isDirect
+ * This flag makes the server set the ``is_direct`` flag on the
+ * ``m.room.member`` events sent to the users in ``invite`` and
+ * ``invite_3pid``. See `Direct Messaging`_ for more information.
+ *
+ * \param powerLevelContentOverride
+ * The power level content to override in the default power level
+ * event. This object is applied on top of the generated `m.room.power_levels`_
+ * event content prior to it being sent to the room. Defaults to
+ * overriding nothing.
+ */
+ explicit CreateRoomJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string visibility = {}, std::string roomAliasName = {}, std::string name = {}, std::string topic = {}, immer::array<std::string> invite = {}, immer::array<Invite3pid> invite3pid = {}, std::string roomVersion = {}, JsonWrap creationContent = {}, immer::array<StateEvent> initialState = {}, std::string preset = {}, std::optional<bool> isDirect = std::nullopt, JsonWrap powerLevelContentOverride = {});
+
+
+ // Result properties
+
+
+
+
+/// The created room's ID.
+static std::string roomId(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string visibility, std::string roomAliasName, std::string name, std::string topic, immer::array<std::string> invite, immer::array<Invite3pid> invite3pid, std::string roomVersion, JsonWrap creationContent, immer::array<StateEvent> initialState, std::string preset, std::optional<bool> isDirect, JsonWrap powerLevelContentOverride);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+ template<>
+ struct adl_serializer<CreateRoomJob::Invite3pid> {
+ static void to_json(json& jo, const CreateRoomJob::Invite3pid &pod)
+ {
+
+
+ jo["id_server"s] = pod.idServer;
+
+ jo["id_access_token"s] = pod.idAccessToken;
+
+ jo["medium"s] = pod.medium;
+
+ jo["address"s] = pod.address;
+
+ }
+
+};
+ template<>
+ struct adl_serializer<CreateRoomJob::StateEvent> {
+ static void to_json(json& jo, const CreateRoomJob::StateEvent &pod)
+ {
+
+
+ jo["type"s] = pod.type;
+
+
+ addToJsonIfNeeded(jo, "state_key"s, pod.stateKey);
+ jo["content"s] = pod.content;
+
+ }
+
+};
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/definitions/auth_data.hpp b/src/csapi/definitions/auth_data.hpp
new file mode 100644
index 0000000..9ce2396
--- /dev/null
+++ b/src/csapi/definitions/auth_data.hpp
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+/// Used by clients to submit authentication information to the interactive-authentication API
+struct AuthenticationData
+{
+
+/// The login type that the client is attempting to complete.
+ std::string type;
+
+/// The value of the session key given by the homeserver.
+ std::string session;
+
+/// Keys dependent on the login type
+ immer::map<std::string, JsonWrap> authInfo;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<AuthenticationData> {
+ static void to_json(json& jo, const AuthenticationData &pod)
+ {
+
+ addPropertyMapToJson(jo, pod.authInfo);
+ jo["type"s] = pod.type;
+
+
+ addToJsonIfNeeded(jo, "session"s, pod.session);
+ }
+ static void from_json(const json &jo, AuthenticationData& result)
+ {
+
+ result.type = jo.at("type"s);
+ result.session = jo.at("session"s);
+ result.authInfo = jo;
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/client_device.hpp b/src/csapi/definitions/client_device.hpp
new file mode 100644
index 0000000..6c0936b
--- /dev/null
+++ b/src/csapi/definitions/client_device.hpp
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+/// A client device
+struct Device
+{
+
+/// Identifier of this device.
+ std::string deviceId;
+
+/// Display name set by the user for this device. Absent if no name has been
+/// set.
+ std::string displayName;
+
+/// The IP address where this device was last seen. (May be a few minutes out
+/// of date, for efficiency reasons).
+ std::string lastSeenIp;
+
+/// The timestamp (in milliseconds since the unix epoch) when this devices
+/// was last seen. (May be a few minutes out of date, for efficiency
+/// reasons).
+ std::optional<std::int_fast64_t> lastSeenTs;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<Device> {
+ static void to_json(json& jo, const Device &pod)
+ {
+
+
+ jo["device_id"s] = pod.deviceId;
+
+
+ addToJsonIfNeeded(jo, "display_name"s, pod.displayName);
+
+ addToJsonIfNeeded(jo, "last_seen_ip"s, pod.lastSeenIp);
+
+ addToJsonIfNeeded(jo, "last_seen_ts"s, pod.lastSeenTs);
+ }
+ static void from_json(const json &jo, Device& result)
+ {
+
+ result.deviceId = jo.at("device_id"s);
+ result.displayName = jo.at("display_name"s);
+ result.lastSeenIp = jo.at("last_seen_ip"s);
+ result.lastSeenTs = jo.at("last_seen_ts"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/device_keys.hpp b/src/csapi/definitions/device_keys.hpp
new file mode 100644
index 0000000..b6e90c0
--- /dev/null
+++ b/src/csapi/definitions/device_keys.hpp
@@ -0,0 +1,75 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+/// Device identity keys
+struct DeviceKeys
+{
+
+/// The ID of the user the device belongs to. Must match the user ID used
+/// when logging in.
+ std::string userId;
+
+/// The ID of the device these keys belong to. Must match the device ID used
+/// when logging in.
+ std::string deviceId;
+
+/// The encryption algorithms supported by this device.
+ immer::array<std::string> algorithms;
+
+/// Public identity keys. The names of the properties should be in the
+/// format ``<algorithm>:<device_id>``. The keys themselves should be
+/// encoded as specified by the key algorithm.
+ immer::map<std::string, std::string> keys;
+
+/// Signatures for the device key object. A map from user ID, to a map from
+/// ``<algorithm>:<device_id>`` to the signature.
+///
+/// The signature is calculated using the process described at `Signing
+/// JSON`_.
+ immer::map<std::string, immer::map<std::string, std::string>> signatures;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<DeviceKeys> {
+ static void to_json(json& jo, const DeviceKeys &pod)
+ {
+
+
+ jo["user_id"s] = pod.userId;
+
+ jo["device_id"s] = pod.deviceId;
+
+ jo["algorithms"s] = pod.algorithms;
+
+ jo["keys"s] = pod.keys;
+
+ jo["signatures"s] = pod.signatures;
+
+ }
+ static void from_json(const json &jo, DeviceKeys& result)
+ {
+
+ result.userId = jo.at("user_id"s);
+ result.deviceId = jo.at("device_id"s);
+ result.algorithms = jo.at("algorithms"s);
+ result.keys = jo.at("keys"s);
+ result.signatures = jo.at("signatures"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/event-schemas/schema/core-event-schema/event.hpp b/src/csapi/definitions/event-schemas/schema/core-event-schema/event.hpp
new file mode 100644
index 0000000..8606ccd
--- /dev/null
+++ b/src/csapi/definitions/event-schemas/schema/core-event-schema/event.hpp
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+/// The basic set of fields all events must have.
+struct Event
+{
+
+/// The fields in this object will vary depending on the type of event. When interacting with the REST API, this is the HTTP body.
+ JsonWrap content;
+
+/// The type of event. This SHOULD be namespaced similar to Java package naming conventions e.g. 'com.example.subdomain.event.type'
+ std::string type;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<Event> {
+ static void to_json(json& jo, const Event &pod)
+ {
+
+
+ jo["content"s] = pod.content;
+
+ jo["type"s] = pod.type;
+
+ }
+ static void from_json(const json &jo, Event& result)
+ {
+
+ result.content = jo.at("content"s);
+ result.type = jo.at("type"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/event-schemas/schema/core-event-schema/room_event.hpp b/src/csapi/definitions/event-schemas/schema/core-event-schema/room_event.hpp
new file mode 100644
index 0000000..a17a6f3
--- /dev/null
+++ b/src/csapi/definitions/event-schemas/schema/core-event-schema/room_event.hpp
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+#include "csapi/definitions/event-schemas/schema/core-event-schema/sync_room_event.hpp"
+
+namespace Kazv {
+/// Room Events have the following fields.
+struct RoomEvent : SyncRoomEvent
+{
+
+/// The ID of the room associated with this event. Will not be present on events
+/// that arrive through ``/sync``, despite being required everywhere else.
+ std::string roomId;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<RoomEvent> {
+ static void to_json(json& jo, const RoomEvent &pod)
+ {
+ jo = static_cast<const SyncRoomEvent &>(pod);
+
+ jo["room_id"s] = pod.roomId;
+
+ }
+ static void from_json(const json &jo, RoomEvent& result)
+ {
+ static_cast<SyncRoomEvent &>(result) = jo;
+ result.roomId = jo.at("room_id"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/event-schemas/schema/core-event-schema/state_event.hpp b/src/csapi/definitions/event-schemas/schema/core-event-schema/state_event.hpp
new file mode 100644
index 0000000..6143318
--- /dev/null
+++ b/src/csapi/definitions/event-schemas/schema/core-event-schema/state_event.hpp
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+#include "csapi/definitions/event-schemas/schema/core-event-schema/sync_state_event.hpp"
+#include "csapi/definitions/event-schemas/schema/core-event-schema/room_event.hpp"
+
+namespace Kazv {
+/// State Events have the following fields.
+struct StateEvent : RoomEvent, SyncStateEvent
+{
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<StateEvent> {
+ static void to_json(json& jo, const StateEvent &pod)
+ {
+ jo = static_cast<const RoomEvent &>(pod);
+ jo = static_cast<const SyncStateEvent &>(pod);
+
+
+ }
+ static void from_json(const json &jo, StateEvent& result)
+ {
+ static_cast<RoomEvent &>(result) = jo;
+ static_cast<SyncStateEvent &>(result) = jo;
+
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/event-schemas/schema/core-event-schema/sync_room_event.hpp b/src/csapi/definitions/event-schemas/schema/core-event-schema/sync_room_event.hpp
new file mode 100644
index 0000000..ef1aff0
--- /dev/null
+++ b/src/csapi/definitions/event-schemas/schema/core-event-schema/sync_room_event.hpp
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+#include "csapi/definitions/event-schemas/schema/core-event-schema/unsigned_prop.hpp"
+#include "csapi/definitions/event-schemas/schema/core-event-schema/event.hpp"
+
+namespace Kazv {
+/// In addition to the Event fields, Room Events have the following additional fields.
+struct SyncRoomEvent : Event
+{
+
+/// The globally unique event identifier.
+ std::string eventId;
+
+/// Contains the fully-qualified ID of the user who sent this event.
+ std::string sender;
+
+/// Timestamp in milliseconds on originating homeserver when this event was sent.
+ std::int_fast64_t originServerTs;
+
+/// In addition to the Event fields, Room Events have the following additional fields.
+ std::optional<UnsignedData> unsignedData;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<SyncRoomEvent> {
+ static void to_json(json& jo, const SyncRoomEvent &pod)
+ {
+ jo = static_cast<const Event &>(pod);
+
+ jo["event_id"s] = pod.eventId;
+
+ jo["sender"s] = pod.sender;
+
+ jo["origin_server_ts"s] = pod.originServerTs;
+
+
+ addToJsonIfNeeded(jo, "unsigned"s, pod.unsignedData);
+ }
+ static void from_json(const json &jo, SyncRoomEvent& result)
+ {
+ static_cast<Event &>(result) = jo;
+ result.eventId = jo.at("event_id"s);
+ result.sender = jo.at("sender"s);
+ result.originServerTs = jo.at("origin_server_ts"s);
+ result.unsignedData = jo.at("unsigned"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/event-schemas/schema/core-event-schema/sync_state_event.hpp b/src/csapi/definitions/event-schemas/schema/core-event-schema/sync_state_event.hpp
new file mode 100644
index 0000000..f891bb9
--- /dev/null
+++ b/src/csapi/definitions/event-schemas/schema/core-event-schema/sync_state_event.hpp
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+#include "csapi/definitions/event-schemas/schema/core-event-schema/sync_room_event.hpp"
+
+namespace Kazv {
+/// In addition to the Room Event fields, State Events have the following additional fields.
+struct SyncStateEvent : SyncRoomEvent
+{
+
+/// Optional. The previous ``content`` for this event. If there is no previous content, this key will be missing.
+ JsonWrap prevContent;
+
+/// A unique key which defines the overwriting semantics for this piece of room state. This value is often a zero-length string. The presence of this key makes this event a State Event.
+/// State keys starting with an ``@`` are reserved for referencing user IDs, such as room members. With the exception of a few events, state events set with a given user's ID as the state key MUST only be set by that user.
+ std::string stateKey;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<SyncStateEvent> {
+ static void to_json(json& jo, const SyncStateEvent &pod)
+ {
+ jo = static_cast<const SyncRoomEvent &>(pod);
+
+
+ addToJsonIfNeeded(jo, "prev_content"s, pod.prevContent);
+ jo["state_key"s] = pod.stateKey;
+
+ }
+ static void from_json(const json &jo, SyncStateEvent& result)
+ {
+ static_cast<SyncRoomEvent &>(result) = jo;
+ result.prevContent = jo.at("prev_content"s);
+ result.stateKey = jo.at("state_key"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/event-schemas/schema/core-event-schema/unsigned_prop.hpp b/src/csapi/definitions/event-schemas/schema/core-event-schema/unsigned_prop.hpp
new file mode 100644
index 0000000..8964454
--- /dev/null
+++ b/src/csapi/definitions/event-schemas/schema/core-event-schema/unsigned_prop.hpp
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+/// Contains optional extra information about the event.
+struct UnsignedData
+{
+
+/// The time in milliseconds that has elapsed since the event was sent. This field is generated by the local homeserver, and may be incorrect if the local time on at least one of the two servers is out of sync, which can cause the age to either be negative or greater than it actually is.
+ std::optional<int> age;
+
+/// The event that redacted this event, if any.
+ JsonWrap redactedBecause;
+
+/// The client-supplied transaction ID, for example, provided via
+/// ``PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}``,
+/// if the client being given the event is the same one which sent it.
+ std::string transactionId;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<UnsignedData> {
+ static void to_json(json& jo, const UnsignedData &pod)
+ {
+
+
+
+ addToJsonIfNeeded(jo, "age"s, pod.age);
+
+ addToJsonIfNeeded(jo, "redacted_because"s, pod.redactedBecause);
+
+ addToJsonIfNeeded(jo, "transaction_id"s, pod.transactionId);
+ }
+ static void from_json(const json &jo, UnsignedData& result)
+ {
+
+ result.age = jo.at("age"s);
+ result.redactedBecause = jo.at("redacted_because"s);
+ result.transactionId = jo.at("transaction_id"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/event-schemas/schema/m.room.member.hpp b/src/csapi/definitions/event-schemas/schema/m.room.member.hpp
new file mode 100644
index 0000000..cca84f9
--- /dev/null
+++ b/src/csapi/definitions/event-schemas/schema/m.room.member.hpp
@@ -0,0 +1,362 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+#include "csapi/definitions/event-schemas/schema/stripped_state.hpp"
+#include "csapi/definitions/event-schemas/schema/core-event-schema/unsigned_prop.hpp"
+
+namespace Kazv {
+/// A block of content which has been signed, which servers can use to verify the event. Clients should ignore this.
+struct SignedData
+{
+
+/// The invited matrix user ID. Must be equal to the user_id property of the event.
+ std::string mxid;
+
+/// A single signature from the verifying server, in the format specified by the Signing Events section of the server-server API.
+ immer::map<std::string, immer::map<std::string, std::string>> signatures;
+
+/// The token property of the containing third_party_invite object.
+ std::string token;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<SignedData> {
+ static void to_json(json& jo, const SignedData &pod)
+ {
+
+
+ jo["mxid"s] = pod.mxid;
+
+ jo["signatures"s] = pod.signatures;
+
+ jo["token"s] = pod.token;
+
+ }
+ static void from_json(const json &jo, SignedData& result)
+ {
+
+ result.mxid = jo.at("mxid"s);
+ result.signatures = jo.at("signatures"s);
+ result.token = jo.at("token"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+
+struct Invite
+{
+
+/// A name which can be displayed to represent the user instead of their third party identifier
+ std::string displayName;
+
+/// A block of content which has been signed, which servers can use to verify the event. Clients should ignore this.
+ SignedData signedData;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<Invite> {
+ static void to_json(json& jo, const Invite &pod)
+ {
+
+
+ jo["display_name"s] = pod.displayName;
+
+ jo["signed"s] = pod.signedData;
+
+ }
+ static void from_json(const json &jo, Invite& result)
+ {
+
+ result.displayName = jo.at("display_name"s);
+ result.signedData = jo.at("signed"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+
+struct EventContent
+{
+
+/// The avatar URL for this user, if any.
+ std::string avatarUrl;
+
+/// The display name for this user, if any.
+ Variant displayname;
+
+/// The membership state of the user.
+ std::string membership;
+
+/// Flag indicating if the room containing this event was created with the intention of being a direct chat. See `Direct Messaging`_.
+ std::optional<bool> isDirect;
+
+
+ std::optional<Invite> thirdPartyInvite;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<EventContent> {
+ static void to_json(json& jo, const EventContent &pod)
+ {
+
+
+
+ addToJsonIfNeeded(jo, "avatar_url"s, pod.avatarUrl);
+
+ addToJsonIfNeeded(jo, "displayname"s, pod.displayname);
+ jo["membership"s] = pod.membership;
+
+
+ addToJsonIfNeeded(jo, "is_direct"s, pod.isDirect);
+
+ addToJsonIfNeeded(jo, "third_party_invite"s, pod.thirdPartyInvite);
+ }
+ static void from_json(const json &jo, EventContent& result)
+ {
+
+ result.avatarUrl = jo.at("avatar_url"s);
+ result.displayname = jo.at("displayname"s);
+ result.membership = jo.at("membership"s);
+ result.isDirect = jo.at("is_direct"s);
+ result.thirdPartyInvite = jo.at("third_party_invite"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+/// Adjusts the membership state for a user in a room. It is preferable to use the membership APIs (``/rooms/<room id>/invite`` etc) when performing membership actions rather than adjusting the state directly as there are a restricted set of valid transformations. For example, user A cannot force user B to join a room, and trying to force this state change directly will fail.
+///
+/// The following membership states are specified:
+///
+/// - ``invite`` - The user has been invited to join a room, but has not yet joined it. They may not participate in the room until they join.
+///
+/// - ``join`` - The user has joined the room (possibly after accepting an invite), and may participate in it.
+///
+/// - ``leave`` - The user was once joined to the room, but has since left (possibly by choice, or possibly by being kicked).
+///
+/// - ``ban`` - The user has been banned from the room, and is no longer allowed to join it until they are un-banned from the room (by having their membership state set to a value other than ``ban``).
+///
+/// - ``knock`` - This is a reserved word, which currently has no meaning.
+///
+/// The ``third_party_invite`` property will be set if this invite is an ``invite`` event and is the successor of an ``m.room.third_party_invite`` event, and absent otherwise.
+///
+/// This event may also include an ``invite_room_state`` key inside the event's ``unsigned`` data.
+/// If present, this contains an array of ``StrippedState`` Events. These events provide information
+/// on a subset of state events such as the room name.
+///
+/// The user for which a membership applies is represented by the ``state_key``. Under some conditions,
+/// the ``sender`` and ``state_key`` may not match - this may be interpreted as the ``sender`` affecting
+/// the membership state of the ``state_key`` user.
+///
+/// The ``membership`` for a given user can change over time. The table below represents the various changes
+/// over time and how clients and servers must interpret those changes. Previous membership can be retrieved
+/// from the ``prev_content`` object on an event. If not present, the user's previous membership must be assumed
+/// as ``leave``.
+///
+/// .. TODO: Improve how this table is written? We use a csv-table to get around vertical header restrictions.
+///
+/// .. csv-table::
+/// :header-rows: 1
+/// :stub-columns: 1
+///
+/// "","to ``invite``","to ``join``","to ``leave``","to ``ban``","to ``knock``"
+/// "from ``invite``","No change.","User joined the room.","If the ``state_key`` is the same as the ``sender``, the user rejected the invite. Otherwise, the ``state_key`` user had their invite revoked.","User was banned.","Not implemented."
+/// "from ``join``","Must never happen.","``displayname`` or ``avatar_url`` changed.","If the ``state_key`` is the same as the ``sender``, the user left. Otherwise, the ``state_key`` user was kicked.","User was kicked and banned.","Not implemented."
+/// "from ``leave``","New invitation sent.","User joined.","No change.","User was banned.","Not implemented."
+/// "from ``ban``","Must never happen.","Must never happen.","User was unbanned.","No change.","Not implemented."
+/// "from ``knock``","Not implemented.","Not implemented.","Not implemented.","Not implemented.","Not implemented."
+struct TheCurrentMembershipStateOfAUserInTheRoom : JsonWrap
+{
+
+/// Adjusts the membership state for a user in a room. It is preferable to use the membership APIs (``/rooms/<room id>/invite`` etc) when performing membership actions rather than adjusting the state directly as there are a restricted set of valid transformations. For example, user A cannot force user B to join a room, and trying to force this state change directly will fail.
+///
+/// The following membership states are specified:
+///
+/// - ``invite`` - The user has been invited to join a room, but has not yet joined it. They may not participate in the room until they join.
+///
+/// - ``join`` - The user has joined the room (possibly after accepting an invite), and may participate in it.
+///
+/// - ``leave`` - The user was once joined to the room, but has since left (possibly by choice, or possibly by being kicked).
+///
+/// - ``ban`` - The user has been banned from the room, and is no longer allowed to join it until they are un-banned from the room (by having their membership state set to a value other than ``ban``).
+///
+/// - ``knock`` - This is a reserved word, which currently has no meaning.
+///
+/// The ``third_party_invite`` property will be set if this invite is an ``invite`` event and is the successor of an ``m.room.third_party_invite`` event, and absent otherwise.
+///
+/// This event may also include an ``invite_room_state`` key inside the event's ``unsigned`` data.
+/// If present, this contains an array of ``StrippedState`` Events. These events provide information
+/// on a subset of state events such as the room name.
+///
+/// The user for which a membership applies is represented by the ``state_key``. Under some conditions,
+/// the ``sender`` and ``state_key`` may not match - this may be interpreted as the ``sender`` affecting
+/// the membership state of the ``state_key`` user.
+///
+/// The ``membership`` for a given user can change over time. The table below represents the various changes
+/// over time and how clients and servers must interpret those changes. Previous membership can be retrieved
+/// from the ``prev_content`` object on an event. If not present, the user's previous membership must be assumed
+/// as ``leave``.
+///
+/// .. TODO: Improve how this table is written? We use a csv-table to get around vertical header restrictions.
+///
+/// .. csv-table::
+/// :header-rows: 1
+/// :stub-columns: 1
+///
+/// "","to ``invite``","to ``join``","to ``leave``","to ``ban``","to ``knock``"
+/// "from ``invite``","No change.","User joined the room.","If the ``state_key`` is the same as the ``sender``, the user rejected the invite. Otherwise, the ``state_key`` user had their invite revoked.","User was banned.","Not implemented."
+/// "from ``join``","Must never happen.","``displayname`` or ``avatar_url`` changed.","If the ``state_key`` is the same as the ``sender``, the user left. Otherwise, the ``state_key`` user was kicked.","User was kicked and banned.","Not implemented."
+/// "from ``leave``","New invitation sent.","User joined.","No change.","User was banned.","Not implemented."
+/// "from ``ban``","Must never happen.","Must never happen.","User was unbanned.","No change.","Not implemented."
+/// "from ``knock``","Not implemented.","Not implemented.","Not implemented.","Not implemented.","Not implemented."
+ std::optional<EventContent> content;
+
+/// The ``user_id`` this membership event relates to. In all cases except for when ``membership`` is
+/// ``join``, the user ID sending the event does not need to match the user ID in the ``state_key``,
+/// unlike other events. Regular authorisation rules still apply.
+ std::string stateKey;
+
+/// Adjusts the membership state for a user in a room. It is preferable to use the membership APIs (``/rooms/<room id>/invite`` etc) when performing membership actions rather than adjusting the state directly as there are a restricted set of valid transformations. For example, user A cannot force user B to join a room, and trying to force this state change directly will fail.
+///
+/// The following membership states are specified:
+///
+/// - ``invite`` - The user has been invited to join a room, but has not yet joined it. They may not participate in the room until they join.
+///
+/// - ``join`` - The user has joined the room (possibly after accepting an invite), and may participate in it.
+///
+/// - ``leave`` - The user was once joined to the room, but has since left (possibly by choice, or possibly by being kicked).
+///
+/// - ``ban`` - The user has been banned from the room, and is no longer allowed to join it until they are un-banned from the room (by having their membership state set to a value other than ``ban``).
+///
+/// - ``knock`` - This is a reserved word, which currently has no meaning.
+///
+/// The ``third_party_invite`` property will be set if this invite is an ``invite`` event and is the successor of an ``m.room.third_party_invite`` event, and absent otherwise.
+///
+/// This event may also include an ``invite_room_state`` key inside the event's ``unsigned`` data.
+/// If present, this contains an array of ``StrippedState`` Events. These events provide information
+/// on a subset of state events such as the room name.
+///
+/// The user for which a membership applies is represented by the ``state_key``. Under some conditions,
+/// the ``sender`` and ``state_key`` may not match - this may be interpreted as the ``sender`` affecting
+/// the membership state of the ``state_key`` user.
+///
+/// The ``membership`` for a given user can change over time. The table below represents the various changes
+/// over time and how clients and servers must interpret those changes. Previous membership can be retrieved
+/// from the ``prev_content`` object on an event. If not present, the user's previous membership must be assumed
+/// as ``leave``.
+///
+/// .. TODO: Improve how this table is written? We use a csv-table to get around vertical header restrictions.
+///
+/// .. csv-table::
+/// :header-rows: 1
+/// :stub-columns: 1
+///
+/// "","to ``invite``","to ``join``","to ``leave``","to ``ban``","to ``knock``"
+/// "from ``invite``","No change.","User joined the room.","If the ``state_key`` is the same as the ``sender``, the user rejected the invite. Otherwise, the ``state_key`` user had their invite revoked.","User was banned.","Not implemented."
+/// "from ``join``","Must never happen.","``displayname`` or ``avatar_url`` changed.","If the ``state_key`` is the same as the ``sender``, the user left. Otherwise, the ``state_key`` user was kicked.","User was kicked and banned.","Not implemented."
+/// "from ``leave``","New invitation sent.","User joined.","No change.","User was banned.","Not implemented."
+/// "from ``ban``","Must never happen.","Must never happen.","User was unbanned.","No change.","Not implemented."
+/// "from ``knock``","Not implemented.","Not implemented.","Not implemented.","Not implemented.","Not implemented."
+ std::string type;
+
+/// Adjusts the membership state for a user in a room. It is preferable to use the membership APIs (``/rooms/<room id>/invite`` etc) when performing membership actions rather than adjusting the state directly as there are a restricted set of valid transformations. For example, user A cannot force user B to join a room, and trying to force this state change directly will fail.
+///
+/// The following membership states are specified:
+///
+/// - ``invite`` - The user has been invited to join a room, but has not yet joined it. They may not participate in the room until they join.
+///
+/// - ``join`` - The user has joined the room (possibly after accepting an invite), and may participate in it.
+///
+/// - ``leave`` - The user was once joined to the room, but has since left (possibly by choice, or possibly by being kicked).
+///
+/// - ``ban`` - The user has been banned from the room, and is no longer allowed to join it until they are un-banned from the room (by having their membership state set to a value other than ``ban``).
+///
+/// - ``knock`` - This is a reserved word, which currently has no meaning.
+///
+/// The ``third_party_invite`` property will be set if this invite is an ``invite`` event and is the successor of an ``m.room.third_party_invite`` event, and absent otherwise.
+///
+/// This event may also include an ``invite_room_state`` key inside the event's ``unsigned`` data.
+/// If present, this contains an array of ``StrippedState`` Events. These events provide information
+/// on a subset of state events such as the room name.
+///
+/// The user for which a membership applies is represented by the ``state_key``. Under some conditions,
+/// the ``sender`` and ``state_key`` may not match - this may be interpreted as the ``sender`` affecting
+/// the membership state of the ``state_key`` user.
+///
+/// The ``membership`` for a given user can change over time. The table below represents the various changes
+/// over time and how clients and servers must interpret those changes. Previous membership can be retrieved
+/// from the ``prev_content`` object on an event. If not present, the user's previous membership must be assumed
+/// as ``leave``.
+///
+/// .. TODO: Improve how this table is written? We use a csv-table to get around vertical header restrictions.
+///
+/// .. csv-table::
+/// :header-rows: 1
+/// :stub-columns: 1
+///
+/// "","to ``invite``","to ``join``","to ``leave``","to ``ban``","to ``knock``"
+/// "from ``invite``","No change.","User joined the room.","If the ``state_key`` is the same as the ``sender``, the user rejected the invite. Otherwise, the ``state_key`` user had their invite revoked.","User was banned.","Not implemented."
+/// "from ``join``","Must never happen.","``displayname`` or ``avatar_url`` changed.","If the ``state_key`` is the same as the ``sender``, the user left. Otherwise, the ``state_key`` user was kicked.","User was kicked and banned.","Not implemented."
+/// "from ``leave``","New invitation sent.","User joined.","No change.","User was banned.","Not implemented."
+/// "from ``ban``","Must never happen.","Must never happen.","User was unbanned.","No change.","Not implemented."
+/// "from ``knock``","Not implemented.","Not implemented.","Not implemented.","Not implemented.","Not implemented."
+ JsonWrap unsignedData;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<TheCurrentMembershipStateOfAUserInTheRoom> {
+ static void to_json(json& jo, const TheCurrentMembershipStateOfAUserInTheRoom &pod)
+ {
+ jo = static_cast<const JsonWrap &>(pod);
+
+
+ addToJsonIfNeeded(jo, "content"s, pod.content);
+
+ addToJsonIfNeeded(jo, "state_key"s, pod.stateKey);
+
+ addToJsonIfNeeded(jo, "type"s, pod.type);
+
+ addToJsonIfNeeded(jo, "unsigned"s, pod.unsignedData);
+ }
+ static void from_json(const json &jo, TheCurrentMembershipStateOfAUserInTheRoom& result)
+ {
+ static_cast<JsonWrap &>(result) = jo;
+ result.content = jo.at("content"s);
+ result.stateKey = jo.at("state_key"s);
+ result.type = jo.at("type"s);
+ result.unsignedData = jo.at("unsigned"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/event-schemas/schema/stripped_state.hpp b/src/csapi/definitions/event-schemas/schema/stripped_state.hpp
new file mode 100644
index 0000000..174767c
--- /dev/null
+++ b/src/csapi/definitions/event-schemas/schema/stripped_state.hpp
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+/// A stripped down state event, with only the ``type``, ``state_key``,
+/// ``sender``, and ``content`` keys.
+struct StrippedState
+{
+
+/// The ``content`` for the event.
+ JsonWrap content;
+
+/// The ``state_key`` for the event.
+ std::string stateKey;
+
+/// The ``type`` for the event.
+ std::string type;
+
+/// The ``sender`` for the event.
+ std::string sender;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<StrippedState> {
+ static void to_json(json& jo, const StrippedState &pod)
+ {
+
+
+ jo["content"s] = pod.content;
+
+ jo["state_key"s] = pod.stateKey;
+
+ jo["type"s] = pod.type;
+
+ jo["sender"s] = pod.sender;
+
+ }
+ static void from_json(const json &jo, StrippedState& result)
+ {
+
+ result.content = jo.at("content"s);
+ result.stateKey = jo.at("state_key"s);
+ result.type = jo.at("type"s);
+ result.sender = jo.at("sender"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/event.hpp b/src/csapi/definitions/event.hpp
new file mode 100644
index 0000000..c853ae1
--- /dev/null
+++ b/src/csapi/definitions/event.hpp
@@ -0,0 +1,129 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+/// Information about this event which was not sent by the originating homeserver
+struct UnsignedData
+{
+
+/// Time in milliseconds since the event was sent.
+ std::optional<std::int_fast64_t> age;
+
+/// Optional. The previous ``content`` for this state. This will be present only for state events appearing in the ``timeline``. If this is not a state event, or there is no previous content, this key will be missing.
+ JsonWrap prevContent;
+
+/// Optional. The transaction ID set when this message was sent. This key will only be present for message events sent by the device calling this API.
+ std::string transactionId;
+
+/// Optional. The event that redacted this event, if any.
+ JsonWrap redactedBecause;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<UnsignedData> {
+ static void to_json(json& jo, const UnsignedData &pod)
+ {
+
+
+
+ addToJsonIfNeeded(jo, "age"s, pod.age);
+
+ addToJsonIfNeeded(jo, "prev_content"s, pod.prevContent);
+
+ addToJsonIfNeeded(jo, "transaction_id"s, pod.transactionId);
+
+ addToJsonIfNeeded(jo, "redacted_because"s, pod.redactedBecause);
+ }
+ static void from_json(const json &jo, UnsignedData& result)
+ {
+
+ result.age = jo.at("age"s);
+ result.prevContent = jo.at("prev_content"s);
+ result.transactionId = jo.at("transaction_id"s);
+ result.redactedBecause = jo.at("redacted_because"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+
+struct Event
+{
+
+/// The ID of this event, if applicable.
+ std::string eventId;
+
+/// The content of this event. The fields in this object will vary depending on the type of event.
+ JsonWrap content;
+
+/// Timestamp in milliseconds on originating homeserver when this event was sent.
+ std::optional<std::int_fast64_t> originServerTs;
+
+/// The MXID of the user who sent this event.
+ std::string sender;
+
+/// Optional. This key will only be present for state events. A unique key which defines the overwriting semantics for this piece of room state.
+ std::string stateKey;
+
+/// The type of event.
+ std::string type;
+
+/// Information about this event which was not sent by the originating homeserver
+ std::optional<UnsignedData> unsignedData;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<Event> {
+ static void to_json(json& jo, const Event &pod)
+ {
+
+
+
+ addToJsonIfNeeded(jo, "event_id"s, pod.eventId);
+
+ addToJsonIfNeeded(jo, "content"s, pod.content);
+
+ addToJsonIfNeeded(jo, "origin_server_ts"s, pod.originServerTs);
+
+ addToJsonIfNeeded(jo, "sender"s, pod.sender);
+
+ addToJsonIfNeeded(jo, "state_key"s, pod.stateKey);
+
+ addToJsonIfNeeded(jo, "type"s, pod.type);
+
+ addToJsonIfNeeded(jo, "unsigned"s, pod.unsignedData);
+ }
+ static void from_json(const json &jo, Event& result)
+ {
+
+ result.eventId = jo.at("event_id"s);
+ result.content = jo.at("content"s);
+ result.originServerTs = jo.at("origin_server_ts"s);
+ result.sender = jo.at("sender"s);
+ result.stateKey = jo.at("state_key"s);
+ result.type = jo.at("type"s);
+ result.unsignedData = jo.at("unsigned"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/event_batch.hpp b/src/csapi/definitions/event_batch.hpp
new file mode 100644
index 0000000..2fa82fe
--- /dev/null
+++ b/src/csapi/definitions/event_batch.hpp
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+
+struct EventBatch
+{
+
+/// List of events.
+ EventList events;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<EventBatch> {
+ static void to_json(json& jo, const EventBatch &pod)
+ {
+
+
+
+ addToJsonIfNeeded(jo, "events"s, pod.events);
+ }
+ static void from_json(const json &jo, EventBatch& result)
+ {
+
+ result.events = jo.at("events"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/event_filter.hpp b/src/csapi/definitions/event_filter.hpp
new file mode 100644
index 0000000..5dac8ff
--- /dev/null
+++ b/src/csapi/definitions/event_filter.hpp
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+
+struct EventFilter
+{
+
+/// The maximum number of events to return.
+ std::optional<int> limit;
+
+/// A list of sender IDs to exclude. If this list is absent then no senders are excluded. A matching sender will be excluded even if it is listed in the ``'senders'`` filter.
+ immer::array<std::string> notSenders;
+
+/// A list of event types to exclude. If this list is absent then no event types are excluded. A matching type will be excluded even if it is listed in the ``'types'`` filter. A '*' can be used as a wildcard to match any sequence of characters.
+ immer::array<std::string> notTypes;
+
+/// A list of senders IDs to include. If this list is absent then all senders are included.
+ immer::array<std::string> senders;
+
+/// A list of event types to include. If this list is absent then all event types are included. A ``'*'`` can be used as a wildcard to match any sequence of characters.
+ immer::array<std::string> types;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<EventFilter> {
+ static void to_json(json& jo, const EventFilter &pod)
+ {
+
+
+
+ addToJsonIfNeeded(jo, "limit"s, pod.limit);
+
+ addToJsonIfNeeded(jo, "not_senders"s, pod.notSenders);
+
+ addToJsonIfNeeded(jo, "not_types"s, pod.notTypes);
+
+ addToJsonIfNeeded(jo, "senders"s, pod.senders);
+
+ addToJsonIfNeeded(jo, "types"s, pod.types);
+ }
+ static void from_json(const json &jo, EventFilter& result)
+ {
+
+ result.limit = jo.at("limit"s);
+ result.notSenders = jo.at("not_senders"s);
+ result.notTypes = jo.at("not_types"s);
+ result.senders = jo.at("senders"s);
+ result.types = jo.at("types"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/openid_token.hpp b/src/csapi/definitions/openid_token.hpp
new file mode 100644
index 0000000..bcbddba
--- /dev/null
+++ b/src/csapi/definitions/openid_token.hpp
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+
+struct OpenidToken
+{
+
+/// An access token the consumer may use to verify the identity of
+/// the person who generated the token. This is given to the federation
+/// API ``GET /openid/userinfo`` to verify the user's identity.
+ std::string accessToken;
+
+/// The string ``Bearer``.
+ std::string tokenType;
+
+/// The homeserver domain the consumer should use when attempting to
+/// verify the user's identity.
+ std::string matrixServerName;
+
+/// The number of seconds before this token expires and a new one must
+/// be generated.
+ int expiresIn;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<OpenidToken> {
+ static void to_json(json& jo, const OpenidToken &pod)
+ {
+
+
+ jo["access_token"s] = pod.accessToken;
+
+ jo["token_type"s] = pod.tokenType;
+
+ jo["matrix_server_name"s] = pod.matrixServerName;
+
+ jo["expires_in"s] = pod.expiresIn;
+
+ }
+ static void from_json(const json &jo, OpenidToken& result)
+ {
+
+ result.accessToken = jo.at("access_token"s);
+ result.tokenType = jo.at("token_type"s);
+ result.matrixServerName = jo.at("matrix_server_name"s);
+ result.expiresIn = jo.at("expires_in"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/public_rooms_response.hpp b/src/csapi/definitions/public_rooms_response.hpp
new file mode 100644
index 0000000..7e237cb
--- /dev/null
+++ b/src/csapi/definitions/public_rooms_response.hpp
@@ -0,0 +1,148 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+
+struct PublicRoomsChunk
+{
+
+/// Aliases of the room. May be empty.
+ immer::array<std::string> aliases;
+
+/// The canonical alias of the room, if any.
+ std::string canonicalAlias;
+
+/// The name of the room, if any.
+ std::string name;
+
+/// The number of members joined to the room.
+ int numJoinedMembers;
+
+/// The ID of the room.
+ std::string roomId;
+
+/// The topic of the room, if any.
+ std::string topic;
+
+/// Whether the room may be viewed by guest users without joining.
+ bool worldReadable;
+
+/// Whether guest users may join the room and participate in it.
+/// If they can, they will be subject to ordinary power level
+/// rules like any other user.
+ bool guestCanJoin;
+
+/// The URL for the room's avatar, if one is set.
+ std::string avatarUrl;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<PublicRoomsChunk> {
+ static void to_json(json& jo, const PublicRoomsChunk &pod)
+ {
+
+
+
+ addToJsonIfNeeded(jo, "aliases"s, pod.aliases);
+
+ addToJsonIfNeeded(jo, "canonical_alias"s, pod.canonicalAlias);
+
+ addToJsonIfNeeded(jo, "name"s, pod.name);
+ jo["num_joined_members"s] = pod.numJoinedMembers;
+
+ jo["room_id"s] = pod.roomId;
+
+
+ addToJsonIfNeeded(jo, "topic"s, pod.topic);
+ jo["world_readable"s] = pod.worldReadable;
+
+ jo["guest_can_join"s] = pod.guestCanJoin;
+
+
+ addToJsonIfNeeded(jo, "avatar_url"s, pod.avatarUrl);
+ }
+ static void from_json(const json &jo, PublicRoomsChunk& result)
+ {
+
+ result.aliases = jo.at("aliases"s);
+ result.canonicalAlias = jo.at("canonical_alias"s);
+ result.name = jo.at("name"s);
+ result.numJoinedMembers = jo.at("num_joined_members"s);
+ result.roomId = jo.at("room_id"s);
+ result.topic = jo.at("topic"s);
+ result.worldReadable = jo.at("world_readable"s);
+ result.guestCanJoin = jo.at("guest_can_join"s);
+ result.avatarUrl = jo.at("avatar_url"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+/// A list of the rooms on the server.
+struct PublicRoomsResponse
+{
+
+/// A paginated chunk of public rooms.
+ immer::array<PublicRoomsChunk> chunk;
+
+/// A pagination token for the response. The absence of this token
+/// means there are no more results to fetch and the client should
+/// stop paginating.
+ std::string nextBatch;
+
+/// A pagination token that allows fetching previous results. The
+/// absence of this token means there are no results before this
+/// batch, i.e. this is the first batch.
+ std::string prevBatch;
+
+/// An estimate on the total number of public rooms, if the
+/// server has an estimate.
+ std::optional<int> totalRoomCountEstimate;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<PublicRoomsResponse> {
+ static void to_json(json& jo, const PublicRoomsResponse &pod)
+ {
+
+
+ jo["chunk"s] = pod.chunk;
+
+
+ addToJsonIfNeeded(jo, "next_batch"s, pod.nextBatch);
+
+ addToJsonIfNeeded(jo, "prev_batch"s, pod.prevBatch);
+
+ addToJsonIfNeeded(jo, "total_room_count_estimate"s, pod.totalRoomCountEstimate);
+ }
+ static void from_json(const json &jo, PublicRoomsResponse& result)
+ {
+
+ result.chunk = jo.at("chunk"s);
+ result.nextBatch = jo.at("next_batch"s);
+ result.prevBatch = jo.at("prev_batch"s);
+ result.totalRoomCountEstimate = jo.at("total_room_count_estimate"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/push_condition.hpp b/src/csapi/definitions/push_condition.hpp
new file mode 100644
index 0000000..1afb7c8
--- /dev/null
+++ b/src/csapi/definitions/push_condition.hpp
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+
+struct PushCondition
+{
+
+/// The kind of condition to apply. See `conditions <#conditions>`_ for
+/// more information on the allowed kinds and how they work.
+ std::string kind;
+
+/// Required for ``event_match`` conditions. The dot-separated field of the
+/// event to match.
+///
+/// Required for ``sender_notification_permission`` conditions. The field in
+/// the power level event the user needs a minimum power level for. Fields
+/// must be specified under the ``notifications`` property in the power level
+/// event's ``content``.
+ std::string key;
+
+/// Required for ``event_match`` conditions. The glob-style pattern to
+/// match against. Patterns with no special glob characters should be
+/// treated as having asterisks prepended and appended when testing the
+/// condition.
+ std::string pattern;
+
+/// Required for ``room_member_count`` conditions. A decimal integer
+/// optionally prefixed by one of, ==, <, >, >= or <=. A prefix of < matches
+/// rooms where the member count is strictly less than the given number and
+/// so forth. If no prefix is present, this parameter defaults to ==.
+ std::string is;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<PushCondition> {
+ static void to_json(json& jo, const PushCondition &pod)
+ {
+
+
+ jo["kind"s] = pod.kind;
+
+
+ addToJsonIfNeeded(jo, "key"s, pod.key);
+
+ addToJsonIfNeeded(jo, "pattern"s, pod.pattern);
+
+ addToJsonIfNeeded(jo, "is"s, pod.is);
+ }
+ static void from_json(const json &jo, PushCondition& result)
+ {
+
+ result.kind = jo.at("kind"s);
+ result.key = jo.at("key"s);
+ result.pattern = jo.at("pattern"s);
+ result.is = jo.at("is"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/push_rule.hpp b/src/csapi/definitions/push_rule.hpp
new file mode 100644
index 0000000..1fd3928
--- /dev/null
+++ b/src/csapi/definitions/push_rule.hpp
@@ -0,0 +1,76 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+#include "csapi/definitions/push_condition.hpp"
+
+namespace Kazv {
+
+struct PushRule
+{
+
+/// The actions to perform when this rule is matched.
+ immer::array<Variant> actions;
+
+/// Whether this is a default rule, or has been set explicitly.
+ bool isDefault;
+
+/// Whether the push rule is enabled or not.
+ bool enabled;
+
+/// The ID of this rule.
+ std::string ruleId;
+
+/// The conditions that must hold true for an event in order for a rule to be
+/// applied to an event. A rule with no conditions always matches. Only
+/// applicable to ``underride`` and ``override`` rules.
+ immer::array<PushCondition> conditions;
+
+/// The glob-style pattern to match against. Only applicable to ``content``
+/// rules.
+ std::string pattern;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<PushRule> {
+ static void to_json(json& jo, const PushRule &pod)
+ {
+
+
+ jo["actions"s] = pod.actions;
+
+ jo["default"s] = pod.isDefault;
+
+ jo["enabled"s] = pod.enabled;
+
+ jo["rule_id"s] = pod.ruleId;
+
+
+ addToJsonIfNeeded(jo, "conditions"s, pod.conditions);
+
+ addToJsonIfNeeded(jo, "pattern"s, pod.pattern);
+ }
+ static void from_json(const json &jo, PushRule& result)
+ {
+
+ result.actions = jo.at("actions"s);
+ result.isDefault = jo.at("default"s);
+ result.enabled = jo.at("enabled"s);
+ result.ruleId = jo.at("rule_id"s);
+ result.conditions = jo.at("conditions"s);
+ result.pattern = jo.at("pattern"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/push_ruleset.hpp b/src/csapi/definitions/push_ruleset.hpp
new file mode 100644
index 0000000..4b1a629
--- /dev/null
+++ b/src/csapi/definitions/push_ruleset.hpp
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+#include "csapi/definitions/push_rule.hpp"
+
+namespace Kazv {
+
+struct PushRuleset
+{
+
+
+ immer::array<PushRule> content;
+
+
+ immer::array<PushRule> override;
+
+
+ immer::array<PushRule> room;
+
+
+ immer::array<PushRule> sender;
+
+
+ immer::array<PushRule> underride;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<PushRuleset> {
+ static void to_json(json& jo, const PushRuleset &pod)
+ {
+
+
+
+ addToJsonIfNeeded(jo, "content"s, pod.content);
+
+ addToJsonIfNeeded(jo, "override"s, pod.override);
+
+ addToJsonIfNeeded(jo, "room"s, pod.room);
+
+ addToJsonIfNeeded(jo, "sender"s, pod.sender);
+
+ addToJsonIfNeeded(jo, "underride"s, pod.underride);
+ }
+ static void from_json(const json &jo, PushRuleset& result)
+ {
+
+ result.content = jo.at("content"s);
+ result.override = jo.at("override"s);
+ result.room = jo.at("room"s);
+ result.sender = jo.at("sender"s);
+ result.underride = jo.at("underride"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/request_email_validation.hpp b/src/csapi/definitions/request_email_validation.hpp
new file mode 100644
index 0000000..1bd79c7
--- /dev/null
+++ b/src/csapi/definitions/request_email_validation.hpp
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+#include "csapi/definitions/../../identity/definitions/request_email_validation.hpp"
+
+namespace Kazv {
+
+struct EmailValidationData : RequestEmailValidation
+{
+
+/// The hostname of the identity server to communicate with. May optionally
+/// include a port. This parameter is ignored when the homeserver handles
+/// 3PID verification.
+///
+/// This parameter is deprecated with a plan to be removed in a future specification
+/// version for ``/account/password`` and ``/register`` requests.
+ std::string idServer;
+
+/// An access token previously registered with the identity server. Servers
+/// can treat this as optional to distinguish between r0.5-compatible clients
+/// and this specification version.
+///
+/// Required if an ``id_server`` is supplied.
+ std::string idAccessToken;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<EmailValidationData> {
+ static void to_json(json& jo, const EmailValidationData &pod)
+ {
+ jo = static_cast<const RequestEmailValidation &>(pod);
+
+
+ addToJsonIfNeeded(jo, "id_server"s, pod.idServer);
+
+ addToJsonIfNeeded(jo, "id_access_token"s, pod.idAccessToken);
+ }
+ static void from_json(const json &jo, EmailValidationData& result)
+ {
+ static_cast<RequestEmailValidation &>(result) = jo;
+ result.idServer = jo.at("id_server"s);
+ result.idAccessToken = jo.at("id_access_token"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/request_msisdn_validation.hpp b/src/csapi/definitions/request_msisdn_validation.hpp
new file mode 100644
index 0000000..6699207
--- /dev/null
+++ b/src/csapi/definitions/request_msisdn_validation.hpp
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+#include "csapi/definitions/../../identity/definitions/request_msisdn_validation.hpp"
+
+namespace Kazv {
+
+struct MsisdnValidationData : RequestMsisdnValidation
+{
+
+/// The hostname of the identity server to communicate with. May optionally
+/// include a port. This parameter is ignored when the homeserver handles
+/// 3PID verification.
+///
+/// This parameter is deprecated with a plan to be removed in a future specification
+/// version for ``/account/password`` and ``/register`` requests.
+ std::string idServer;
+
+/// An access token previously registered with the identity server. Servers
+/// can treat this as optional to distinguish between r0.5-compatible clients
+/// and this specification version.
+///
+/// Required if an ``id_server`` is supplied.
+ std::string idAccessToken;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<MsisdnValidationData> {
+ static void to_json(json& jo, const MsisdnValidationData &pod)
+ {
+ jo = static_cast<const RequestMsisdnValidation &>(pod);
+
+
+ addToJsonIfNeeded(jo, "id_server"s, pod.idServer);
+
+ addToJsonIfNeeded(jo, "id_access_token"s, pod.idAccessToken);
+ }
+ static void from_json(const json &jo, MsisdnValidationData& result)
+ {
+ static_cast<RequestMsisdnValidation &>(result) = jo;
+ result.idServer = jo.at("id_server"s);
+ result.idAccessToken = jo.at("id_access_token"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/request_token_response.hpp b/src/csapi/definitions/request_token_response.hpp
new file mode 100644
index 0000000..718ae08
--- /dev/null
+++ b/src/csapi/definitions/request_token_response.hpp
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+
+struct RequestTokenResponse
+{
+
+/// The session ID. Session IDs are opaque strings that must consist entirely
+/// of the characters ``[0-9a-zA-Z.=_-]``. Their length must not exceed 255
+/// characters and they must not be empty.
+ std::string sid;
+
+/// An optional field containing a URL where the client must submit the
+/// validation token to, with identical parameters to the Identity Service
+/// API's ``POST /validate/email/submitToken`` endpoint (without the requirement
+/// for an access token). The homeserver must send this token to the user (if
+/// applicable), who should then be prompted to provide it to the client.
+///
+/// If this field is not present, the client can assume that verification
+/// will happen without the client's involvement provided the homeserver
+/// advertises this specification version in the ``/versions`` response
+/// (ie: r0.5.0).
+ std::string submitUrl;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<RequestTokenResponse> {
+ static void to_json(json& jo, const RequestTokenResponse &pod)
+ {
+
+
+ jo["sid"s] = pod.sid;
+
+
+ addToJsonIfNeeded(jo, "submit_url"s, pod.submitUrl);
+ }
+ static void from_json(const json &jo, RequestTokenResponse& result)
+ {
+
+ result.sid = jo.at("sid"s);
+ result.submitUrl = jo.at("submit_url"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/room_event_batch.hpp b/src/csapi/definitions/room_event_batch.hpp
new file mode 100644
index 0000000..7485376
--- /dev/null
+++ b/src/csapi/definitions/room_event_batch.hpp
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+
+struct RoomEventBatch
+{
+
+/// List of events.
+ EventList events;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<RoomEventBatch> {
+ static void to_json(json& jo, const RoomEventBatch &pod)
+ {
+
+
+
+ addToJsonIfNeeded(jo, "events"s, pod.events);
+ }
+ static void from_json(const json &jo, RoomEventBatch& result)
+ {
+
+ result.events = jo.at("events"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/room_event_filter.hpp b/src/csapi/definitions/room_event_filter.hpp
new file mode 100644
index 0000000..3be3a8f
--- /dev/null
+++ b/src/csapi/definitions/room_event_filter.hpp
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+#include "csapi/definitions/event_filter.hpp"
+
+namespace Kazv {
+
+struct RoomEventFilter : EventFilter
+{
+
+/// If ``true``, enables lazy-loading of membership events. See
+/// `Lazy-loading room members <#lazy-loading-room-members>`_
+/// for more information. Defaults to ``false``.
+ std::optional<bool> lazyLoadMembers;
+
+/// If ``true``, sends all membership events for all events, even if they have already
+/// been sent to the client. Does not
+/// apply unless ``lazy_load_members`` is ``true``. See
+/// `Lazy-loading room members <#lazy-loading-room-members>`_
+/// for more information. Defaults to ``false``.
+ std::optional<bool> includeRedundantMembers;
+
+/// A list of room IDs to exclude. If this list is absent then no rooms are excluded. A matching room will be excluded even if it is listed in the ``'rooms'`` filter.
+ immer::array<std::string> notRooms;
+
+/// A list of room IDs to include. If this list is absent then all rooms are included.
+ immer::array<std::string> rooms;
+
+/// If ``true``, includes only events with a ``url`` key in their content. If ``false``, excludes those events. If omitted, ``url`` key is not considered for filtering.
+ std::optional<bool> containsUrl;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<RoomEventFilter> {
+ static void to_json(json& jo, const RoomEventFilter &pod)
+ {
+ jo = static_cast<const EventFilter &>(pod);
+
+
+ addToJsonIfNeeded(jo, "lazy_load_members"s, pod.lazyLoadMembers);
+
+ addToJsonIfNeeded(jo, "include_redundant_members"s, pod.includeRedundantMembers);
+
+ addToJsonIfNeeded(jo, "not_rooms"s, pod.notRooms);
+
+ addToJsonIfNeeded(jo, "rooms"s, pod.rooms);
+
+ addToJsonIfNeeded(jo, "contains_url"s, pod.containsUrl);
+ }
+ static void from_json(const json &jo, RoomEventFilter& result)
+ {
+ static_cast<EventFilter &>(result) = jo;
+ result.lazyLoadMembers = jo.at("lazy_load_members"s);
+ result.includeRedundantMembers = jo.at("include_redundant_members"s);
+ result.notRooms = jo.at("not_rooms"s);
+ result.rooms = jo.at("rooms"s);
+ result.containsUrl = jo.at("contains_url"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/state_event_batch.hpp b/src/csapi/definitions/state_event_batch.hpp
new file mode 100644
index 0000000..37e699f
--- /dev/null
+++ b/src/csapi/definitions/state_event_batch.hpp
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+
+struct StateEventBatch
+{
+
+/// List of events.
+ EventList events;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<StateEventBatch> {
+ static void to_json(json& jo, const StateEventBatch &pod)
+ {
+
+
+
+ addToJsonIfNeeded(jo, "events"s, pod.events);
+ }
+ static void from_json(const json &jo, StateEventBatch& result)
+ {
+
+ result.events = jo.at("events"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/sync_filter.hpp b/src/csapi/definitions/sync_filter.hpp
new file mode 100644
index 0000000..5e68e75
--- /dev/null
+++ b/src/csapi/definitions/sync_filter.hpp
@@ -0,0 +1,136 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+#include "csapi/definitions/room_event_filter.hpp"
+#include "csapi/definitions/event_filter.hpp"
+
+namespace Kazv {
+/// Filters to be applied to room data.
+struct RoomFilter
+{
+
+/// A list of room IDs to exclude. If this list is absent then no rooms are excluded. A matching room will be excluded even if it is listed in the ``'rooms'`` filter. This filter is applied before the filters in ``ephemeral``, ``state``, ``timeline`` or ``account_data``
+ immer::array<std::string> notRooms;
+
+/// A list of room IDs to include. If this list is absent then all rooms are included. This filter is applied before the filters in ``ephemeral``, ``state``, ``timeline`` or ``account_data``
+ immer::array<std::string> rooms;
+
+/// The events that aren't recorded in the room history, e.g. typing and receipts, to include for rooms.
+ RoomEventFilter ephemeral;
+
+/// Include rooms that the user has left in the sync, default false
+ std::optional<bool> includeLeave;
+
+/// The state events to include for rooms.
+ RoomEventFilter state;
+
+/// The message and state update events to include for rooms.
+ RoomEventFilter timeline;
+
+/// The per user account data to include for rooms.
+ RoomEventFilter accountData;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<RoomFilter> {
+ static void to_json(json& jo, const RoomFilter &pod)
+ {
+
+
+
+ addToJsonIfNeeded(jo, "not_rooms"s, pod.notRooms);
+
+ addToJsonIfNeeded(jo, "rooms"s, pod.rooms);
+
+ addToJsonIfNeeded(jo, "ephemeral"s, pod.ephemeral);
+
+ addToJsonIfNeeded(jo, "include_leave"s, pod.includeLeave);
+
+ addToJsonIfNeeded(jo, "state"s, pod.state);
+
+ addToJsonIfNeeded(jo, "timeline"s, pod.timeline);
+
+ addToJsonIfNeeded(jo, "account_data"s, pod.accountData);
+ }
+ static void from_json(const json &jo, RoomFilter& result)
+ {
+
+ result.notRooms = jo.at("not_rooms"s);
+ result.rooms = jo.at("rooms"s);
+ result.ephemeral = jo.at("ephemeral"s);
+ result.includeLeave = jo.at("include_leave"s);
+ result.state = jo.at("state"s);
+ result.timeline = jo.at("timeline"s);
+ result.accountData = jo.at("account_data"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+
+struct Filter
+{
+
+/// List of event fields to include. If this list is absent then all fields are included. The entries may include '.' characters to indicate sub-fields. So ['content.body'] will include the 'body' field of the 'content' object. A literal '.' character in a field name may be escaped using a '\\'. A server may include more fields than were requested.
+ immer::array<std::string> eventFields;
+
+/// The format to use for events. 'client' will return the events in a format suitable for clients. 'federation' will return the raw event as received over federation. The default is 'client'.
+ std::string eventFormat;
+
+/// The presence updates to include.
+ EventFilter presence;
+
+/// The user account data that isn't associated with rooms to include.
+ EventFilter accountData;
+
+/// Filters to be applied to room data.
+ RoomFilter room;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<Filter> {
+ static void to_json(json& jo, const Filter &pod)
+ {
+
+
+
+ addToJsonIfNeeded(jo, "event_fields"s, pod.eventFields);
+
+ addToJsonIfNeeded(jo, "event_format"s, pod.eventFormat);
+
+ addToJsonIfNeeded(jo, "presence"s, pod.presence);
+
+ addToJsonIfNeeded(jo, "account_data"s, pod.accountData);
+
+ addToJsonIfNeeded(jo, "room"s, pod.room);
+ }
+ static void from_json(const json &jo, Filter& result)
+ {
+
+ result.eventFields = jo.at("event_fields"s);
+ result.eventFormat = jo.at("event_format"s);
+ result.presence = jo.at("presence"s);
+ result.accountData = jo.at("account_data"s);
+ result.room = jo.at("room"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/third_party_signed.hpp b/src/csapi/definitions/third_party_signed.hpp
new file mode 100644
index 0000000..a7f41df
--- /dev/null
+++ b/src/csapi/definitions/third_party_signed.hpp
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+/// A signature of an ``m.third_party_invite`` token to prove that this user
+/// owns a third party identity which has been invited to the room.
+struct ThirdPartySigned
+{
+
+/// The Matrix ID of the user who issued the invite.
+ std::string sender;
+
+/// The Matrix ID of the invitee.
+ std::string mxid;
+
+/// The state key of the m.third_party_invite event.
+ std::string token;
+
+/// A signatures object containing a signature of the entire signed object.
+ immer::map<std::string, immer::map<std::string, std::string>> signatures;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<ThirdPartySigned> {
+ static void to_json(json& jo, const ThirdPartySigned &pod)
+ {
+
+
+ jo["sender"s] = pod.sender;
+
+ jo["mxid"s] = pod.mxid;
+
+ jo["token"s] = pod.token;
+
+ jo["signatures"s] = pod.signatures;
+
+ }
+ static void from_json(const json &jo, ThirdPartySigned& result)
+ {
+
+ result.sender = jo.at("sender"s);
+ result.mxid = jo.at("mxid"s);
+ result.token = jo.at("token"s);
+ result.signatures = jo.at("signatures"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/timeline_batch.hpp b/src/csapi/definitions/timeline_batch.hpp
new file mode 100644
index 0000000..9db0bfc
--- /dev/null
+++ b/src/csapi/definitions/timeline_batch.hpp
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+#include "csapi/definitions/room_event_batch.hpp"
+
+namespace Kazv {
+
+struct Timeline : RoomEventBatch
+{
+
+/// True if the number of events returned was limited by the ``limit`` on the filter.
+ std::optional<bool> limited;
+
+/// A token that can be supplied to the ``from`` parameter of the rooms/{roomId}/messages endpoint.
+ std::string prevBatch;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<Timeline> {
+ static void to_json(json& jo, const Timeline &pod)
+ {
+ jo = static_cast<const RoomEventBatch &>(pod);
+
+
+ addToJsonIfNeeded(jo, "limited"s, pod.limited);
+
+ addToJsonIfNeeded(jo, "prev_batch"s, pod.prevBatch);
+ }
+ static void from_json(const json &jo, Timeline& result)
+ {
+ static_cast<RoomEventBatch &>(result) = jo;
+ result.limited = jo.at("limited"s);
+ result.prevBatch = jo.at("prev_batch"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/user_identifier.hpp b/src/csapi/definitions/user_identifier.hpp
new file mode 100644
index 0000000..52df3d1
--- /dev/null
+++ b/src/csapi/definitions/user_identifier.hpp
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+/// Identification information for a user
+struct UserIdentifier
+{
+
+/// The type of identification. See `Identifier types`_ for supported values and additional property descriptions.
+ std::string type;
+
+/// Identification information for a user
+ JsonWrap additionalProperties;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<UserIdentifier> {
+ static void to_json(json& jo, const UserIdentifier &pod)
+ {
+
+ addPropertyMapToJson(jo, pod.additionalProperties);
+ jo["type"s] = pod.type;
+
+ }
+ static void from_json(const json &jo, UserIdentifier& result)
+ {
+
+ result.type = jo.at("type"s);
+ result.additionalProperties = jo;
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/wellknown/full.hpp b/src/csapi/definitions/wellknown/full.hpp
new file mode 100644
index 0000000..2dc7460
--- /dev/null
+++ b/src/csapi/definitions/wellknown/full.hpp
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+#include "csapi/definitions/wellknown/identity_server.hpp"
+#include "csapi/definitions/wellknown/homeserver.hpp"
+
+namespace Kazv {
+/// Used by clients to determine the homeserver, identity server, and other
+/// optional components they should be interacting with.
+struct DiscoveryInformation
+{
+
+/// Used by clients to determine the homeserver, identity server, and other
+/// optional components they should be interacting with.
+ HomeserverInformation homeserver;
+
+/// Used by clients to determine the homeserver, identity server, and other
+/// optional components they should be interacting with.
+ std::optional<IdentityServerInformation> identityServer;
+
+/// Application-dependent keys using Java package naming convention.
+ immer::map<std::string, JsonWrap> additionalProperties;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<DiscoveryInformation> {
+ static void to_json(json& jo, const DiscoveryInformation &pod)
+ {
+
+ addPropertyMapToJson(jo, pod.additionalProperties);
+ jo["m.homeserver"s] = pod.homeserver;
+
+
+ addToJsonIfNeeded(jo, "m.identity_server"s, pod.identityServer);
+ }
+ static void from_json(const json &jo, DiscoveryInformation& result)
+ {
+
+ result.homeserver = jo.at("m.homeserver"s);
+ result.identityServer = jo.at("m.identity_server"s);
+ result.additionalProperties = jo;
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/wellknown/homeserver.hpp b/src/csapi/definitions/wellknown/homeserver.hpp
new file mode 100644
index 0000000..e435770
--- /dev/null
+++ b/src/csapi/definitions/wellknown/homeserver.hpp
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+/// Used by clients to discover homeserver information.
+struct HomeserverInformation
+{
+
+/// The base URL for the homeserver for client-server connections.
+ std::string baseUrl;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<HomeserverInformation> {
+ static void to_json(json& jo, const HomeserverInformation &pod)
+ {
+
+
+ jo["base_url"s] = pod.baseUrl;
+
+ }
+ static void from_json(const json &jo, HomeserverInformation& result)
+ {
+
+ result.baseUrl = jo.at("base_url"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/definitions/wellknown/identity_server.hpp b/src/csapi/definitions/wellknown/identity_server.hpp
new file mode 100644
index 0000000..6b3bc39
--- /dev/null
+++ b/src/csapi/definitions/wellknown/identity_server.hpp
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+/// Used by clients to discover identity server information.
+struct IdentityServerInformation
+{
+
+/// The base URL for the identity server for client-server connections.
+ std::string baseUrl;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<IdentityServerInformation> {
+ static void to_json(json& jo, const IdentityServerInformation &pod)
+ {
+
+
+ jo["base_url"s] = pod.baseUrl;
+
+ }
+ static void from_json(const json &jo, IdentityServerInformation& result)
+ {
+
+ result.baseUrl = jo.at("base_url"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/csapi/device_management.cpp b/src/csapi/device_management.cpp
new file mode 100644
index 0000000..42e40dd
--- /dev/null
+++ b/src/csapi/device_management.cpp
@@ -0,0 +1,187 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "device_management.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body GetDevicesJob::buildBody()
+ {
+ // ignore unused param
+
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetDevicesJob::GetDevicesJob(
+ std::string serverUrl
+ , std::string _accessToken
+
+ )
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/devices",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody()
+ )
+ {
+
+
+ }
+
+
+
+ immer::array<Device> GetDevicesJob::devices(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("devices"s)) {
+ return
+ jsonBody(r).get()["devices"s]
+ /*.get<immer::array<Device>>()*/;}
+ else { return immer::array<Device>( );}
+ }
+
+
+
+ BaseJob::Body GetDeviceJob::buildBody(std::string deviceId)
+ {
+ // ignore unused param
+ (void)(deviceId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetDeviceJob::GetDeviceJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string deviceId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/devices/" + deviceId,
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(deviceId)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body UpdateDeviceJob::buildBody(std::string deviceId, std::string displayName)
+ {
+ // ignore unused param
+ (void)(deviceId);(void)(displayName);
+
+ json _data
+ ;
+
+
+ addToJsonIfNeeded(_data, "display_name"s, displayName);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+UpdateDeviceJob::UpdateDeviceJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string deviceId, std::string displayName)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/devices/" + deviceId,
+ PUT,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(deviceId, displayName)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body DeleteDeviceJob::buildBody(std::string deviceId, std::optional<AuthenticationData> auth)
+ {
+ // ignore unused param
+ (void)(deviceId);(void)(auth);
+
+ json _data
+ ;
+
+
+ addToJsonIfNeeded(_data, "auth"s, auth);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+DeleteDeviceJob::DeleteDeviceJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string deviceId, std::optional<AuthenticationData> auth)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/devices/" + deviceId,
+ DELETE,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(deviceId, auth)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body DeleteDevicesJob::buildBody(immer::array<std::string> devices, std::optional<AuthenticationData> auth)
+ {
+ // ignore unused param
+ (void)(devices);(void)(auth);
+
+ json _data
+ ;
+
+ _data["devices"s] = devices;
+
+
+ addToJsonIfNeeded(_data, "auth"s, auth);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+DeleteDevicesJob::DeleteDevicesJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ immer::array<std::string> devices, std::optional<AuthenticationData> auth)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/delete_devices",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(devices, auth)
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/device_management.hpp b/src/csapi/device_management.hpp
new file mode 100644
index 0000000..3a16d29
--- /dev/null
+++ b/src/csapi/device_management.hpp
@@ -0,0 +1,226 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+#include "csapi/definitions/auth_data.hpp"
+#include "csapi/definitions/client_device.hpp"
+
+namespace Kazv {
+
+/*! \brief List registered devices for the current user
+ *
+ * Gets information about all devices for the current user.
+ */
+class GetDevicesJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /// List registered devices for the current user
+ explicit GetDevicesJob(std::string serverUrl
+ , std::string _accessToken
+
+ );
+
+
+ // Result properties
+
+
+
+
+/// A list of all registered devices for this user.
+static immer::array<Device> devices(Response r);
+
+
+
+ static BaseJob::Body buildBody();
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Get a single device
+ *
+ * Gets information on a single device, by device id.
+ */
+class GetDeviceJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Get a single device
+ *
+ * \param deviceId
+ * The device to retrieve.
+ */
+ explicit GetDeviceJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string deviceId );
+
+
+ // Result properties
+
+
+/// Device information
+ static Device data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<Device>()
+ ;
+ }
+
+
+
+
+ static BaseJob::Body buildBody(std::string deviceId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Update a device
+ *
+ * Updates the metadata on the given device.
+ */
+class UpdateDeviceJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Update a device
+ *
+ * \param deviceId
+ * The device to update.
+ *
+ * \param displayName
+ * The new display name for this device. If not given, the
+ * display name is unchanged.
+ */
+ explicit UpdateDeviceJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string deviceId , std::string displayName = {});
+
+
+
+
+ static BaseJob::Body buildBody(std::string deviceId, std::string displayName);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Delete a device
+ *
+ * This API endpoint uses the `User-Interactive Authentication API`_.
+ *
+ * Deletes the given device, and invalidates any access token associated with it.
+ */
+class DeleteDeviceJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Delete a device
+ *
+ * \param deviceId
+ * The device to delete.
+ *
+ * \param auth
+ * Additional authentication information for the
+ * user-interactive authentication API.
+ */
+ explicit DeleteDeviceJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string deviceId , std::optional<AuthenticationData> auth = std::nullopt);
+
+
+
+
+ static BaseJob::Body buildBody(std::string deviceId, std::optional<AuthenticationData> auth);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Bulk deletion of devices
+ *
+ * This API endpoint uses the `User-Interactive Authentication API`_.
+ *
+ * Deletes the given devices, and invalidates any access token associated with them.
+ */
+class DeleteDevicesJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Bulk deletion of devices
+ *
+ * \param devices
+ * The list of device IDs to delete.
+ *
+ * \param auth
+ * Additional authentication information for the
+ * user-interactive authentication API.
+ */
+ explicit DeleteDevicesJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ immer::array<std::string> devices , std::optional<AuthenticationData> auth = std::nullopt);
+
+
+
+
+ static BaseJob::Body buildBody(immer::array<std::string> devices, std::optional<AuthenticationData> auth);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/directory.cpp b/src/csapi/directory.cpp
new file mode 100644
index 0000000..a748395
--- /dev/null
+++ b/src/csapi/directory.cpp
@@ -0,0 +1,168 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "directory.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body SetRoomAliasJob::buildBody(std::string roomAlias, std::string roomId)
+ {
+ // ignore unused param
+ (void)(roomAlias);(void)(roomId);
+
+ json _data
+ ;
+
+ _data["room_id"s] = roomId;
+
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+SetRoomAliasJob::SetRoomAliasJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomAlias, std::string roomId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/directory/room/" + roomAlias,
+ PUT,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomAlias, roomId)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body GetRoomIdByAliasJob::buildBody(std::string roomAlias)
+ {
+ // ignore unused param
+ (void)(roomAlias);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetRoomIdByAliasJob::GetRoomIdByAliasJob(
+ std::string serverUrl
+
+ ,
+ std::string roomAlias)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/directory/room/" + roomAlias,
+ GET,
+ {} ,
+ ReturnType::Json,
+ buildBody(roomAlias)
+ )
+ {
+
+
+ }
+
+
+
+ std::string GetRoomIdByAliasJob::roomId(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("room_id"s)) {
+ return
+ jsonBody(r).get()["room_id"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ immer::array<std::string> GetRoomIdByAliasJob::servers(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("servers"s)) {
+ return
+ jsonBody(r).get()["servers"s]
+ /*.get<immer::array<std::string>>()*/;}
+ else { return immer::array<std::string>( );}
+ }
+
+
+
+ BaseJob::Body DeleteRoomAliasJob::buildBody(std::string roomAlias)
+ {
+ // ignore unused param
+ (void)(roomAlias);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+DeleteRoomAliasJob::DeleteRoomAliasJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomAlias)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/directory/room/" + roomAlias,
+ DELETE,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomAlias)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body GetLocalAliasesJob::buildBody(std::string roomId)
+ {
+ // ignore unused param
+ (void)(roomId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetLocalAliasesJob::GetLocalAliasesJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/aliases",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId)
+ )
+ {
+
+
+ //addExpectedKey("aliases");
+ }
+
+
+
+ immer::array<std::string> GetLocalAliasesJob::aliases(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("aliases"s)) {
+ return
+ jsonBody(r).get()["aliases"s]
+ /*.get<immer::array<std::string>>()*/;}
+ else { return immer::array<std::string>( );}
+ }
+
+}
diff --git a/src/csapi/directory.hpp b/src/csapi/directory.hpp
new file mode 100644
index 0000000..fb67cf5
--- /dev/null
+++ b/src/csapi/directory.hpp
@@ -0,0 +1,207 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Create a new mapping from room alias to room ID.
+ *
+ */
+class SetRoomAliasJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Create a new mapping from room alias to room ID.
+ *
+ * \param roomAlias
+ * The room alias to set.
+ *
+ * \param roomId
+ * The room ID to set.
+ */
+ explicit SetRoomAliasJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomAlias , std::string roomId );
+
+
+
+
+ static BaseJob::Body buildBody(std::string roomAlias, std::string roomId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Get the room ID corresponding to this room alias.
+ *
+ * Requests that the server resolve a room alias to a room ID.
+ *
+ * The server will use the federation API to resolve the alias if the
+ * domain part of the alias does not correspond to the server's own
+ * domain.
+ */
+class GetRoomIdByAliasJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Get the room ID corresponding to this room alias.
+ *
+ * \param roomAlias
+ * The room alias.
+ */
+ explicit GetRoomIdByAliasJob(std::string serverUrl
+
+ ,
+ std::string roomAlias );
+
+
+ // Result properties
+
+
+
+
+/// The room ID for this room alias.
+static std::string roomId(Response r);
+
+
+/// A list of servers that are aware of this room alias.
+static immer::array<std::string> servers(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string roomAlias);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Remove a mapping of room alias to room ID.
+ *
+ * Remove a mapping of room alias to room ID.
+ *
+ * Servers may choose to implement additional access control checks here, for instance that
+ * room aliases can only be deleted by their creator or a server administrator.
+ *
+ * .. Note::
+ * Servers may choose to update the ``alt_aliases`` for the ``m.room.canonical_alias``
+ * state event in the room when an alias is removed. Servers which choose to update the
+ * canonical alias event are recommended to, in addition to their other relevant permission
+ * checks, delete the alias and return a successful response even if the user does not
+ * have permission to update the ``m.room.canonical_alias`` event.
+ */
+class DeleteRoomAliasJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Remove a mapping of room alias to room ID.
+ *
+ * \param roomAlias
+ * The room alias to remove.
+ */
+ explicit DeleteRoomAliasJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomAlias );
+
+
+
+
+ static BaseJob::Body buildBody(std::string roomAlias);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Get a list of local aliases on a given room.
+ *
+ * Get a list of aliases maintained by the local server for the
+ * given room.
+ *
+ * This endpoint can be called by users who are in the room (external
+ * users receive an ``M_FORBIDDEN`` error response). If the room's
+ * ``m.room.history_visibility`` maps to ``world_readable``, any
+ * user can call this endpoint.
+ *
+ * Servers may choose to implement additional access control checks here,
+ * such as allowing server administrators to view aliases regardless of
+ * membership.
+ *
+ * .. Note::
+ * Clients are recommended not to display this list of aliases prominently
+ * as they are not curated, unlike those listed in the ``m.room.canonical_alias``
+ * state event.
+ */
+class GetLocalAliasesJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Get a list of local aliases on a given room.
+ *
+ * \param roomId
+ * The room ID to find local aliases of.
+ */
+ explicit GetLocalAliasesJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId );
+
+
+ // Result properties
+
+
+
+
+/// The server's local aliases on the room. Can be empty.
+static immer::array<std::string> aliases(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string roomId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/event_context.cpp b/src/csapi/event_context.cpp
new file mode 100644
index 0000000..555dd6a
--- /dev/null
+++ b/src/csapi/event_context.cpp
@@ -0,0 +1,115 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "event_context.hpp"
+
+namespace Kazv
+{
+
+BaseJob::Query GetEventContextJob::buildQuery(
+std::optional<int> limit, std::string filter)
+{
+BaseJob::Query _q;
+
+ addToQueryIfNeeded(_q, "limit"s, limit);
+
+ addToQueryIfNeeded(_q, "filter"s, filter);
+return _q;
+}
+
+ BaseJob::Body GetEventContextJob::buildBody(std::string roomId, std::string eventId, std::optional<int> limit, std::string filter)
+ {
+ // ignore unused param
+ (void)(roomId);(void)(eventId);(void)(limit);(void)(filter);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetEventContextJob::GetEventContextJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId, std::string eventId, std::optional<int> limit, std::string filter)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/context/" + eventId,
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId, eventId, limit, filter)
+ , buildQuery(limit, filter))
+ {
+
+
+ }
+
+
+
+ std::string GetEventContextJob::start(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("start"s)) {
+ return
+ jsonBody(r).get()["start"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ std::string GetEventContextJob::end(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("end"s)) {
+ return
+ jsonBody(r).get()["end"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ EventList GetEventContextJob::eventsBefore(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("events_before"s)) {
+ return
+ jsonBody(r).get()["events_before"s]
+ /*.get<EventList>()*/;}
+ else { return EventList( );}
+ }
+
+
+ JsonWrap GetEventContextJob::event(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("event"s)) {
+ return
+ jsonBody(r).get()["event"s]
+ /*.get<JsonWrap>()*/;}
+ else { return JsonWrap( );}
+ }
+
+
+ EventList GetEventContextJob::eventsAfter(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("events_after"s)) {
+ return
+ jsonBody(r).get()["events_after"s]
+ /*.get<EventList>()*/;}
+ else { return EventList( );}
+ }
+
+
+ EventList GetEventContextJob::state(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("state"s)) {
+ return
+ jsonBody(r).get()["state"s]
+ /*.get<EventList>()*/;}
+ else { return EventList( );}
+ }
+
+}
diff --git a/src/csapi/event_context.hpp b/src/csapi/event_context.hpp
new file mode 100644
index 0000000..55288e9
--- /dev/null
+++ b/src/csapi/event_context.hpp
@@ -0,0 +1,99 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Get events and state around the specified event.
+ *
+ * This API returns a number of events that happened just before and
+ * after the specified event. This allows clients to get the context
+ * surrounding an event.
+ *
+ * *Note*: This endpoint supports lazy-loading of room member events. See
+ * `Lazy-loading room members <#lazy-loading-room-members>`_ for more information.
+ */
+class GetEventContextJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Get events and state around the specified event.
+ *
+ * \param roomId
+ * The room to get events from.
+ *
+ * \param eventId
+ * The event to get context around.
+ *
+ * \param limit
+ * The maximum number of events to return. Default: 10.
+ *
+ * \param filter
+ * A JSON ``RoomEventFilter`` to filter the returned events with. The
+ * filter is only applied to ``events_before``, ``events_after``, and
+ * ``state``. It is not applied to the ``event`` itself. The filter may
+ * be applied before or/and after the ``limit`` parameter - whichever the
+ * homeserver prefers.
+ *
+ * See `Filtering <#filtering>`_ for more information.
+ */
+ explicit GetEventContextJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId , std::string eventId , std::optional<int> limit = std::nullopt, std::string filter = {});
+
+
+ // Result properties
+
+
+
+
+/// A token that can be used to paginate backwards with.
+static std::string start(Response r);
+
+
+/// A token that can be used to paginate forwards with.
+static std::string end(Response r);
+
+
+/// A list of room events that happened just before the
+/// requested event, in reverse-chronological order.
+static EventList eventsBefore(Response r);
+
+
+/// Details of the requested event.
+static JsonWrap event(Response r);
+
+
+/// A list of room events that happened just after the
+/// requested event, in chronological order.
+static EventList eventsAfter(Response r);
+
+
+/// The state of the room at the last event returned.
+static EventList state(Response r);
+
+ static BaseJob::Query buildQuery(
+ std::optional<int> limit, std::string filter);
+
+ static BaseJob::Body buildBody(std::string roomId, std::string eventId, std::optional<int> limit, std::string filter);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/filter.cpp b/src/csapi/filter.cpp
new file mode 100644
index 0000000..41389ea
--- /dev/null
+++ b/src/csapi/filter.cpp
@@ -0,0 +1,82 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "filter.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body DefineFilterJob::buildBody(std::string userId, Filter filter)
+ {
+ // ignore unused param
+ (void)(userId);(void)(filter);
+ return
+ BaseJob::JsonBody(filter);
+
+
+
+ };
+
+DefineFilterJob::DefineFilterJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId, Filter filter)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/user/" + userId + "/filter",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(userId, filter)
+ )
+ {
+
+
+ //addExpectedKey("filter_id");
+ }
+
+
+
+ std::string DefineFilterJob::filterId(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("filter_id"s)) {
+ return
+ jsonBody(r).get()["filter_id"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+
+ BaseJob::Body GetFilterJob::buildBody(std::string userId, std::string filterId)
+ {
+ // ignore unused param
+ (void)(userId);(void)(filterId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetFilterJob::GetFilterJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId, std::string filterId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/user/" + userId + "/filter/" + filterId,
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(userId, filterId)
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/filter.hpp b/src/csapi/filter.hpp
new file mode 100644
index 0000000..788e157
--- /dev/null
+++ b/src/csapi/filter.hpp
@@ -0,0 +1,115 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+#include "csapi/definitions/sync_filter.hpp"
+
+namespace Kazv {
+
+/*! \brief Upload a new filter.
+ *
+ * Uploads a new filter definition to the homeserver.
+ * Returns a filter ID that may be used in future requests to
+ * restrict which events are returned to the client.
+ */
+class DefineFilterJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Upload a new filter.
+ *
+ * \param userId
+ * The id of the user uploading the filter. The access token must be authorized to make requests for this user id.
+ *
+ * \param filter
+ * The filter to upload.
+ */
+ explicit DefineFilterJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId , Filter filter );
+
+
+ // Result properties
+
+
+
+
+/// The ID of the filter that was created. Cannot start
+/// with a ``{`` as this character is used to determine
+/// if the filter provided is inline JSON or a previously
+/// declared filter by homeservers on some APIs.
+static std::string filterId(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string userId, Filter filter);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Download a filter
+ *
+ */
+class GetFilterJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Download a filter
+ *
+ * \param userId
+ * The user ID to download a filter for.
+ *
+ * \param filterId
+ * The filter ID to download.
+ */
+ explicit GetFilterJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId , std::string filterId );
+
+
+ // Result properties
+
+
+/// The filter definition.
+ static Filter data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<Filter>()
+ ;
+ }
+
+
+
+
+ static BaseJob::Body buildBody(std::string userId, std::string filterId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/inviting.cpp b/src/csapi/inviting.cpp
new file mode 100644
index 0000000..7b0e20c
--- /dev/null
+++ b/src/csapi/inviting.cpp
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "inviting.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body InviteUserJob::buildBody(std::string roomId, std::string userId)
+ {
+ // ignore unused param
+ (void)(roomId);(void)(userId);
+
+ json _data
+ ;
+
+ _data["user_id"s] = userId;
+
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+InviteUserJob::InviteUserJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId, std::string userId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/invite",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId, userId)
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/inviting.hpp b/src/csapi/inviting.hpp
new file mode 100644
index 0000000..3fcbf47
--- /dev/null
+++ b/src/csapi/inviting.hpp
@@ -0,0 +1,68 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Invite a user to participate in a particular room.
+ *
+ * .. _invite-by-user-id-endpoint:
+ *
+ * *Note that there are two forms of this API, which are documented separately.
+ * This version of the API requires that the inviter knows the Matrix
+ * identifier of the invitee. The other is documented in the*
+ * `third party invites section`_.
+ *
+ * This API invites a user to participate in a particular room.
+ * They do not start participating in the room until they actually join the
+ * room.
+ *
+ * Only users currently in a particular room can invite other users to
+ * join that room.
+ *
+ * If the user was invited to the room, the homeserver will append a
+ * ``m.room.member`` event to the room.
+ *
+ * .. _third party invites section: `invite-by-third-party-id-endpoint`_
+ */
+class InviteUserJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Invite a user to participate in a particular room.
+ *
+ * \param roomId
+ * The room identifier (not alias) to which to invite the user.
+ *
+ * \param userId
+ * The fully qualified user ID of the invitee.
+ */
+ explicit InviteUserJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId , std::string userId );
+
+
+
+
+ static BaseJob::Body buildBody(std::string roomId, std::string userId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/joining.cpp b/src/csapi/joining.cpp
new file mode 100644
index 0000000..3754fb0
--- /dev/null
+++ b/src/csapi/joining.cpp
@@ -0,0 +1,111 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "joining.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body JoinRoomByIdJob::buildBody(std::string roomId, std::optional<ThirdPartySigned> thirdPartySigned)
+ {
+ // ignore unused param
+ (void)(roomId);(void)(thirdPartySigned);
+
+ json _data
+ ;
+
+
+ addToJsonIfNeeded(_data, "third_party_signed"s, thirdPartySigned);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+JoinRoomByIdJob::JoinRoomByIdJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId, std::optional<ThirdPartySigned> thirdPartySigned)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/join",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId, thirdPartySigned)
+ )
+ {
+
+
+ //addExpectedKey("room_id");
+ }
+
+
+
+ std::string JoinRoomByIdJob::roomId(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("room_id"s)) {
+ return
+ jsonBody(r).get()["room_id"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+BaseJob::Query JoinRoomJob::buildQuery(
+immer::array<std::string> serverName)
+{
+BaseJob::Query _q;
+
+ addToQueryIfNeeded(_q, "server_name"s, serverName);
+return _q;
+}
+
+ BaseJob::Body JoinRoomJob::buildBody(std::string roomIdOrAlias, immer::array<std::string> serverName, std::optional<ThirdPartySigned> thirdPartySigned)
+ {
+ // ignore unused param
+ (void)(roomIdOrAlias);(void)(serverName);(void)(thirdPartySigned);
+
+ json _data
+ ;
+
+
+ addToJsonIfNeeded(_data, "third_party_signed"s, thirdPartySigned);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+JoinRoomJob::JoinRoomJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomIdOrAlias, immer::array<std::string> serverName, std::optional<ThirdPartySigned> thirdPartySigned)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/join/" + roomIdOrAlias,
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomIdOrAlias, serverName, thirdPartySigned)
+ , buildQuery(serverName))
+ {
+
+
+ //addExpectedKey("room_id");
+ }
+
+
+
+ std::string JoinRoomJob::roomId(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("room_id"s)) {
+ return
+ jsonBody(r).get()["room_id"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+}
diff --git a/src/csapi/joining.hpp b/src/csapi/joining.hpp
new file mode 100644
index 0000000..902a624
--- /dev/null
+++ b/src/csapi/joining.hpp
@@ -0,0 +1,132 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+#include "csapi/definitions/third_party_signed.hpp"
+
+namespace Kazv {
+
+/*! \brief Start the requesting user participating in a particular room.
+ *
+ * *Note that this API requires a room ID, not alias.*
+ * ``/join/{roomIdOrAlias}`` *exists if you have a room alias.*
+ *
+ * This API starts a user participating in a particular room, if that user
+ * is allowed to participate in that room. After this call, the client is
+ * allowed to see all current state events in the room, and all subsequent
+ * events associated with the room until the user leaves the room.
+ *
+ * After a user has joined a room, the room will appear as an entry in the
+ * response of the |/initialSync|_ and |/sync|_ APIs.
+ */
+class JoinRoomByIdJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Start the requesting user participating in a particular room.
+ *
+ * \param roomId
+ * The room identifier (not alias) to join.
+ *
+ * \param thirdPartySigned
+ * If supplied, the homeserver must verify that it matches a pending
+ * ``m.room.third_party_invite`` event in the room, and perform
+ * key validity checking if required by the event.
+ */
+ explicit JoinRoomByIdJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId , std::optional<ThirdPartySigned> thirdPartySigned = std::nullopt);
+
+
+ // Result properties
+
+
+
+
+/// The joined room ID.
+static std::string roomId(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string roomId, std::optional<ThirdPartySigned> thirdPartySigned);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Start the requesting user participating in a particular room.
+ *
+ * *Note that this API takes either a room ID or alias, unlike* ``/room/{roomId}/join``.
+ *
+ * This API starts a user participating in a particular room, if that user
+ * is allowed to participate in that room. After this call, the client is
+ * allowed to see all current state events in the room, and all subsequent
+ * events associated with the room until the user leaves the room.
+ *
+ * After a user has joined a room, the room will appear as an entry in the
+ * response of the |/initialSync|_ and |/sync|_ APIs.
+ */
+class JoinRoomJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Start the requesting user participating in a particular room.
+ *
+ * \param roomIdOrAlias
+ * The room identifier or alias to join.
+ *
+ * \param serverName
+ * The servers to attempt to join the room through. One of the servers
+ * must be participating in the room.
+ *
+ * \param thirdPartySigned
+ * If a ``third_party_signed`` was supplied, the homeserver must verify
+ * that it matches a pending ``m.room.third_party_invite`` event in the
+ * room, and perform key validity checking if required by the event.
+ */
+ explicit JoinRoomJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomIdOrAlias , immer::array<std::string> serverName = {}, std::optional<ThirdPartySigned> thirdPartySigned = std::nullopt);
+
+
+ // Result properties
+
+
+
+
+/// The joined room ID.
+static std::string roomId(Response r);
+
+ static BaseJob::Query buildQuery(
+ immer::array<std::string> serverName);
+
+ static BaseJob::Body buildBody(std::string roomIdOrAlias, immer::array<std::string> serverName, std::optional<ThirdPartySigned> thirdPartySigned);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/keys.cpp b/src/csapi/keys.cpp
new file mode 100644
index 0000000..53d2a0c
--- /dev/null
+++ b/src/csapi/keys.cpp
@@ -0,0 +1,241 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "keys.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body UploadKeysJob::buildBody(std::optional<DeviceKeys> deviceKeys, immer::map<std::string, Variant> oneTimeKeys)
+ {
+ // ignore unused param
+ (void)(deviceKeys);(void)(oneTimeKeys);
+
+ json _data
+ ;
+
+
+ addToJsonIfNeeded(_data, "device_keys"s, deviceKeys);
+
+ addToJsonIfNeeded(_data, "one_time_keys"s, oneTimeKeys);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+UploadKeysJob::UploadKeysJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::optional<DeviceKeys> deviceKeys, immer::map<std::string, Variant> oneTimeKeys)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/keys/upload",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(deviceKeys, oneTimeKeys)
+ )
+ {
+
+
+ //addExpectedKey("one_time_key_counts");
+ }
+
+
+
+ immer::map<std::string, int> UploadKeysJob::oneTimeKeyCounts(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("one_time_key_counts"s)) {
+ return
+ jsonBody(r).get()["one_time_key_counts"s]
+ /*.get<immer::map<std::string, int>>()*/;}
+ else { return immer::map<std::string, int>( );}
+ }
+
+
+
+ BaseJob::Body QueryKeysJob::buildBody(immer::map<std::string, immer::array<std::string>> deviceKeys, std::optional<int> timeout, std::string token)
+ {
+ // ignore unused param
+ (void)(deviceKeys);(void)(timeout);(void)(token);
+
+ json _data
+ ;
+
+
+ addToJsonIfNeeded(_data, "timeout"s, timeout);
+ _data["device_keys"s] = deviceKeys;
+
+
+ addToJsonIfNeeded(_data, "token"s, token);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+QueryKeysJob::QueryKeysJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ immer::map<std::string, immer::array<std::string>> deviceKeys, std::optional<int> timeout, std::string token)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/keys/query",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(deviceKeys, timeout, token)
+ )
+ {
+
+
+ }
+
+
+
+ immer::map<std::string, JsonWrap> QueryKeysJob::failures(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("failures"s)) {
+ return
+ jsonBody(r).get()["failures"s]
+ /*.get<immer::map<std::string, JsonWrap>>()*/;}
+ else { return immer::map<std::string, JsonWrap>( );}
+ }
+
+
+ immer::map<std::string, immer::map<std::string, QueryKeysJob::DeviceInformation>> QueryKeysJob::deviceKeys(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("device_keys"s)) {
+ return
+ jsonBody(r).get()["device_keys"s]
+ /*.get<immer::map<std::string, immer::map<std::string, DeviceInformation>>>()*/;}
+ else { return immer::map<std::string, immer::map<std::string, DeviceInformation>>( );}
+ }
+
+
+
+ BaseJob::Body ClaimKeysJob::buildBody(immer::map<std::string, immer::map<std::string, std::string>> oneTimeKeys, std::optional<int> timeout)
+ {
+ // ignore unused param
+ (void)(oneTimeKeys);(void)(timeout);
+
+ json _data
+ ;
+
+
+ addToJsonIfNeeded(_data, "timeout"s, timeout);
+ _data["one_time_keys"s] = oneTimeKeys;
+
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+ClaimKeysJob::ClaimKeysJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ immer::map<std::string, immer::map<std::string, std::string>> oneTimeKeys, std::optional<int> timeout)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/keys/claim",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(oneTimeKeys, timeout)
+ )
+ {
+
+
+ //addExpectedKey("one_time_keys");
+ }
+
+
+
+ immer::map<std::string, JsonWrap> ClaimKeysJob::failures(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("failures"s)) {
+ return
+ jsonBody(r).get()["failures"s]
+ /*.get<immer::map<std::string, JsonWrap>>()*/;}
+ else { return immer::map<std::string, JsonWrap>( );}
+ }
+
+
+ immer::map<std::string, immer::map<std::string, Variant>> ClaimKeysJob::oneTimeKeys(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("one_time_keys"s)) {
+ return
+ jsonBody(r).get()["one_time_keys"s]
+ /*.get<immer::map<std::string, immer::map<std::string, Variant>>>()*/;}
+ else { return immer::map<std::string, immer::map<std::string, Variant>>( );}
+ }
+
+
+BaseJob::Query GetKeysChangesJob::buildQuery(
+std::string from, std::string to)
+{
+BaseJob::Query _q;
+ addToQuery(_q, "from"s, from);
+
+ addToQuery(_q, "to"s, to);
+
+return _q;
+}
+
+ BaseJob::Body GetKeysChangesJob::buildBody(std::string from, std::string to)
+ {
+ // ignore unused param
+ (void)(from);(void)(to);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetKeysChangesJob::GetKeysChangesJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string from, std::string to)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/keys/changes",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(from, to)
+ , buildQuery(from, to))
+ {
+
+
+ }
+
+
+
+ immer::array<std::string> GetKeysChangesJob::changed(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("changed"s)) {
+ return
+ jsonBody(r).get()["changed"s]
+ /*.get<immer::array<std::string>>()*/;}
+ else { return immer::array<std::string>( );}
+ }
+
+
+ immer::array<std::string> GetKeysChangesJob::left(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("left"s)) {
+ return
+ jsonBody(r).get()["left"s]
+ /*.get<immer::array<std::string>>()*/;}
+ else { return immer::array<std::string>( );}
+ }
+
+}
diff --git a/src/csapi/keys.hpp b/src/csapi/keys.hpp
new file mode 100644
index 0000000..dc23446
--- /dev/null
+++ b/src/csapi/keys.hpp
@@ -0,0 +1,311 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+#include "csapi/definitions/device_keys.hpp"
+
+namespace Kazv {
+
+/*! \brief Upload end-to-end encryption keys.
+ *
+ * Publishes end-to-end encryption keys for the device.
+ */
+class UploadKeysJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Upload end-to-end encryption keys.
+ *
+ * \param deviceKeys
+ * Identity keys for the device. May be absent if no new
+ * identity keys are required.
+ *
+ * \param oneTimeKeys
+ * One-time public keys for "pre-key" messages. The names of
+ * the properties should be in the format
+ * ``<algorithm>:<key_id>``. The format of the key is determined
+ * by the `key algorithm <#key-algorithms>`_.
+ *
+ * May be absent if no new one-time keys are required.
+ */
+ explicit UploadKeysJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::optional<DeviceKeys> deviceKeys = std::nullopt, immer::map<std::string, Variant> oneTimeKeys = {});
+
+
+ // Result properties
+
+
+
+
+/// For each key algorithm, the number of unclaimed one-time keys
+/// of that type currently held on the server for this device.
+static immer::map<std::string, int> oneTimeKeyCounts(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::optional<DeviceKeys> deviceKeys, immer::map<std::string, Variant> oneTimeKeys);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Download device identity keys.
+ *
+ * Returns the current devices and identity keys for the given users.
+ */
+class QueryKeysJob : public BaseJob {
+public:
+ // Inner data structures
+
+/// Additional data added to the device key information
+/// by intermediate servers, and not covered by the
+/// signatures.
+ struct UnsignedDeviceInfo
+ {
+/// The display name which the user set on the device.
+ std::string deviceDisplayName;
+
+ };
+
+/// Returns the current devices and identity keys for the given users.
+ struct DeviceInformation :
+ DeviceKeys
+ {
+/// Additional data added to the device key information
+/// by intermediate servers, and not covered by the
+/// signatures.
+ std::optional<UnsignedDeviceInfo> unsignedData;
+
+ };
+
+
+// Construction/destruction
+
+ /*! \brief Download device identity keys.
+ *
+ * \param deviceKeys
+ * The keys to be downloaded. A map from user ID, to a list of
+ * device IDs, or to an empty list to indicate all devices for the
+ * corresponding user.
+ *
+ * \param timeout
+ * The time (in milliseconds) to wait when downloading keys from
+ * remote servers. 10 seconds is the recommended default.
+ *
+ * \param token
+ * If the client is fetching keys as a result of a device update received
+ * in a sync request, this should be the 'since' token of that sync request,
+ * or any later sync token. This allows the server to ensure its response
+ * contains the keys advertised by the notification in that sync.
+ */
+ explicit QueryKeysJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ immer::map<std::string, immer::array<std::string>> deviceKeys , std::optional<int> timeout = std::nullopt, std::string token = {});
+
+
+ // Result properties
+
+
+
+
+/// If any remote homeservers could not be reached, they are
+/// recorded here. The names of the properties are the names of
+/// the unreachable servers.
+///
+/// If the homeserver could be reached, but the user or device
+/// was unknown, no failure is recorded. Instead, the corresponding
+/// user or device is missing from the ``device_keys`` result.
+static immer::map<std::string, JsonWrap> failures(Response r);
+
+
+/// Information on the queried devices. A map from user ID, to a
+/// map from device ID to device information. For each device,
+/// the information returned will be the same as uploaded via
+/// ``/keys/upload``, with the addition of an ``unsigned``
+/// property.
+static immer::map<std::string, immer::map<std::string, DeviceInformation>> deviceKeys(Response r);
+
+
+
+ static BaseJob::Body buildBody(immer::map<std::string, immer::array<std::string>> deviceKeys, std::optional<int> timeout, std::string token);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+ template<>
+ struct adl_serializer<QueryKeysJob::UnsignedDeviceInfo> {
+
+ static void from_json(const json &jo, QueryKeysJob::UnsignedDeviceInfo& result)
+ {
+
+ result.deviceDisplayName = jo.at("device_display_name"s);
+
+ }
+};
+ template<>
+ struct adl_serializer<QueryKeysJob::DeviceInformation> {
+
+ static void from_json(const json &jo, QueryKeysJob::DeviceInformation& result)
+ {
+ static_cast<DeviceKeys &>(result) = jo;
+ //nlohmann::from_json(jo, static_cast<const DeviceKeys &>(result));
+ result.unsignedData = jo.at("unsigned"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Claim one-time encryption keys.
+ *
+ * Claims one-time keys for use in pre-key messages.
+ */
+class ClaimKeysJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Claim one-time encryption keys.
+ *
+ * \param oneTimeKeys
+ * The keys to be claimed. A map from user ID, to a map from
+ * device ID to algorithm name.
+ *
+ * \param timeout
+ * The time (in milliseconds) to wait when downloading keys from
+ * remote servers. 10 seconds is the recommended default.
+ */
+ explicit ClaimKeysJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ immer::map<std::string, immer::map<std::string, std::string>> oneTimeKeys , std::optional<int> timeout = std::nullopt);
+
+
+ // Result properties
+
+
+
+
+/// If any remote homeservers could not be reached, they are
+/// recorded here. The names of the properties are the names of
+/// the unreachable servers.
+///
+/// If the homeserver could be reached, but the user or device
+/// was unknown, no failure is recorded. Instead, the corresponding
+/// user or device is missing from the ``one_time_keys`` result.
+static immer::map<std::string, JsonWrap> failures(Response r);
+
+
+/// One-time keys for the queried devices. A map from user ID, to a
+/// map from devices to a map from ``<algorithm>:<key_id>`` to the key object.
+///
+/// See the `key algorithms <#key-algorithms>`_ section for information
+/// on the Key Object format.
+static immer::map<std::string, immer::map<std::string, Variant>> oneTimeKeys(Response r);
+
+
+
+ static BaseJob::Body buildBody(immer::map<std::string, immer::map<std::string, std::string>> oneTimeKeys, std::optional<int> timeout);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Query users with recent device key updates.
+ *
+ * Gets a list of users who have updated their device identity keys since a
+ * previous sync token.
+ *
+ * The server should include in the results any users who:
+ *
+ * * currently share a room with the calling user (ie, both users have
+ * membership state ``join``); *and*
+ * * added new device identity keys or removed an existing device with
+ * identity keys, between ``from`` and ``to``.
+ */
+class GetKeysChangesJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Query users with recent device key updates.
+ *
+ * \param from
+ * The desired start point of the list. Should be the ``next_batch`` field
+ * from a response to an earlier call to |/sync|. Users who have not
+ * uploaded new device identity keys since this point, nor deleted
+ * existing devices with identity keys since then, will be excluded
+ * from the results.
+ *
+ * \param to
+ * The desired end point of the list. Should be the ``next_batch``
+ * field from a recent call to |/sync| - typically the most recent
+ * such call. This may be used by the server as a hint to check its
+ * caches are up to date.
+ */
+ explicit GetKeysChangesJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string from , std::string to );
+
+
+ // Result properties
+
+
+
+
+/// The Matrix User IDs of all users who updated their device
+/// identity keys.
+static immer::array<std::string> changed(Response r);
+
+
+/// The Matrix User IDs of all users who may have left all
+/// the end-to-end encrypted rooms they previously shared
+/// with the user.
+static immer::array<std::string> left(Response r);
+
+ static BaseJob::Query buildQuery(
+ std::string from, std::string to);
+
+ static BaseJob::Body buildBody(std::string from, std::string to);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/kicking.cpp b/src/csapi/kicking.cpp
new file mode 100644
index 0000000..df5d487
--- /dev/null
+++ b/src/csapi/kicking.cpp
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "kicking.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body KickJob::buildBody(std::string roomId, std::string userId, std::string reason)
+ {
+ // ignore unused param
+ (void)(roomId);(void)(userId);(void)(reason);
+
+ json _data
+ ;
+
+ _data["user_id"s] = userId;
+
+
+ addToJsonIfNeeded(_data, "reason"s, reason);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+KickJob::KickJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId, std::string userId, std::string reason)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/kick",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId, userId, reason)
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/kicking.hpp b/src/csapi/kicking.hpp
new file mode 100644
index 0000000..7e8a8bb
--- /dev/null
+++ b/src/csapi/kicking.hpp
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Kick a user from the room.
+ *
+ * Kick a user from the room.
+ *
+ * The caller must have the required power level in order to perform this operation.
+ *
+ * Kicking a user adjusts the target member's membership state to be ``leave`` with an
+ * optional ``reason``. Like with other membership changes, a user can directly adjust
+ * the target member's state by making a request to ``/rooms/<room id>/state/m.room.member/<user id>``.
+ */
+class KickJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Kick a user from the room.
+ *
+ * \param roomId
+ * The room identifier (not alias) from which the user should be kicked.
+ *
+ * \param userId
+ * The fully qualified user ID of the user being kicked.
+ *
+ * \param reason
+ * The reason the user has been kicked. This will be supplied as the
+ * ``reason`` on the target's updated `m.room.member`_ event.
+ */
+ explicit KickJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId , std::string userId , std::string reason = {});
+
+
+
+
+ static BaseJob::Body buildBody(std::string roomId, std::string userId, std::string reason);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/leaving.cpp b/src/csapi/leaving.cpp
new file mode 100644
index 0000000..a293f18
--- /dev/null
+++ b/src/csapi/leaving.cpp
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "leaving.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body LeaveRoomJob::buildBody(std::string roomId)
+ {
+ // ignore unused param
+ (void)(roomId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+LeaveRoomJob::LeaveRoomJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/leave",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body ForgetRoomJob::buildBody(std::string roomId)
+ {
+ // ignore unused param
+ (void)(roomId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+ForgetRoomJob::ForgetRoomJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/forget",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId)
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/leaving.hpp b/src/csapi/leaving.hpp
new file mode 100644
index 0000000..a7d0c12
--- /dev/null
+++ b/src/csapi/leaving.hpp
@@ -0,0 +1,102 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Stop the requesting user participating in a particular room.
+ *
+ * This API stops a user participating in a particular room.
+ *
+ * If the user was already in the room, they will no longer be able to see
+ * new events in the room. If the room requires an invite to join, they
+ * will need to be re-invited before they can re-join.
+ *
+ * If the user was invited to the room, but had not joined, this call
+ * serves to reject the invite.
+ *
+ * The user will still be allowed to retrieve history from the room which
+ * they were previously allowed to see.
+ */
+class LeaveRoomJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Stop the requesting user participating in a particular room.
+ *
+ * \param roomId
+ * The room identifier to leave.
+ */
+ explicit LeaveRoomJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId );
+
+
+
+
+ static BaseJob::Body buildBody(std::string roomId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Stop the requesting user remembering about a particular room.
+ *
+ * This API stops a user remembering about a particular room.
+ *
+ * In general, history is a first class citizen in Matrix. After this API
+ * is called, however, a user will no longer be able to retrieve history
+ * for this room. If all users on a homeserver forget a room, the room is
+ * eligible for deletion from that homeserver.
+ *
+ * If the user is currently joined to the room, they must leave the room
+ * before calling this API.
+ */
+class ForgetRoomJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Stop the requesting user remembering about a particular room.
+ *
+ * \param roomId
+ * The room identifier to forget.
+ */
+ explicit ForgetRoomJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId );
+
+
+
+
+ static BaseJob::Body buildBody(std::string roomId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/list_joined_rooms.cpp b/src/csapi/list_joined_rooms.cpp
new file mode 100644
index 0000000..8355de1
--- /dev/null
+++ b/src/csapi/list_joined_rooms.cpp
@@ -0,0 +1,51 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "list_joined_rooms.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body GetJoinedRoomsJob::buildBody()
+ {
+ // ignore unused param
+
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetJoinedRoomsJob::GetJoinedRoomsJob(
+ std::string serverUrl
+ , std::string _accessToken
+
+ )
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/joined_rooms",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody()
+ )
+ {
+
+
+ //addExpectedKey("joined_rooms");
+ }
+
+
+
+ immer::array<std::string> GetJoinedRoomsJob::joinedRooms(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("joined_rooms"s)) {
+ return
+ jsonBody(r).get()["joined_rooms"s]
+ /*.get<immer::array<std::string>>()*/;}
+ else { return immer::array<std::string>( );}
+ }
+
+}
diff --git a/src/csapi/list_joined_rooms.hpp b/src/csapi/list_joined_rooms.hpp
new file mode 100644
index 0000000..d67abcb
--- /dev/null
+++ b/src/csapi/list_joined_rooms.hpp
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Lists the user's current rooms.
+ *
+ * This API returns a list of the user's current rooms.
+ */
+class GetJoinedRoomsJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /// Lists the user's current rooms.
+ explicit GetJoinedRoomsJob(std::string serverUrl
+ , std::string _accessToken
+
+ );
+
+
+ // Result properties
+
+
+
+
+/// The ID of each room in which the user has ``joined`` membership.
+static immer::array<std::string> joinedRooms(Response r);
+
+
+
+ static BaseJob::Body buildBody();
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/list_public_rooms.cpp b/src/csapi/list_public_rooms.cpp
new file mode 100644
index 0000000..5b47673
--- /dev/null
+++ b/src/csapi/list_public_rooms.cpp
@@ -0,0 +1,268 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "list_public_rooms.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body GetRoomVisibilityOnDirectoryJob::buildBody(std::string roomId)
+ {
+ // ignore unused param
+ (void)(roomId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetRoomVisibilityOnDirectoryJob::GetRoomVisibilityOnDirectoryJob(
+ std::string serverUrl
+
+ ,
+ std::string roomId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/directory/list/room/" + roomId,
+ GET,
+ {} ,
+ ReturnType::Json,
+ buildBody(roomId)
+ )
+ {
+
+
+ }
+
+
+
+ std::string GetRoomVisibilityOnDirectoryJob::visibility(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("visibility"s)) {
+ return
+ jsonBody(r).get()["visibility"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+
+ BaseJob::Body SetRoomVisibilityOnDirectoryJob::buildBody(std::string roomId, std::string visibility)
+ {
+ // ignore unused param
+ (void)(roomId);(void)(visibility);
+
+ json _data
+ ;
+
+
+ addToJsonIfNeeded(_data, "visibility"s, visibility);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+SetRoomVisibilityOnDirectoryJob::SetRoomVisibilityOnDirectoryJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId, std::string visibility)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/directory/list/room/" + roomId,
+ PUT,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId, visibility)
+ )
+ {
+
+
+ }
+
+
+
+BaseJob::Query GetPublicRoomsJob::buildQuery(
+std::optional<int> limit, std::string since, std::string server)
+{
+BaseJob::Query _q;
+
+ addToQueryIfNeeded(_q, "limit"s, limit);
+
+ addToQueryIfNeeded(_q, "since"s, since);
+
+ addToQueryIfNeeded(_q, "server"s, server);
+return _q;
+}
+
+ BaseJob::Body GetPublicRoomsJob::buildBody(std::optional<int> limit, std::string since, std::string server)
+ {
+ // ignore unused param
+ (void)(limit);(void)(since);(void)(server);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetPublicRoomsJob::GetPublicRoomsJob(
+ std::string serverUrl
+
+ ,
+ std::optional<int> limit, std::string since, std::string server)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/publicRooms",
+ GET,
+ {} ,
+ ReturnType::Json,
+ buildBody(limit, since, server)
+ , buildQuery(limit, since, server))
+ {
+
+
+ //addExpectedKey("chunk");
+ }
+
+
+
+ immer::array<PublicRoomsChunk> GetPublicRoomsJob::chunk(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("chunk"s)) {
+ return
+ jsonBody(r).get()["chunk"s]
+ /*.get<immer::array<PublicRoomsChunk>>()*/;}
+ else { return immer::array<PublicRoomsChunk>( );}
+ }
+
+
+ std::string GetPublicRoomsJob::nextBatch(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("next_batch"s)) {
+ return
+ jsonBody(r).get()["next_batch"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ std::string GetPublicRoomsJob::prevBatch(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("prev_batch"s)) {
+ return
+ jsonBody(r).get()["prev_batch"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ std::optional<int> GetPublicRoomsJob::totalRoomCountEstimate(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("total_room_count_estimate"s)) {
+ return
+ jsonBody(r).get()["total_room_count_estimate"s]
+ /*.get<int>()*/;}
+ else { return std::optional<int>( );}
+ }
+
+
+BaseJob::Query QueryPublicRoomsJob::buildQuery(
+std::string server)
+{
+BaseJob::Query _q;
+
+ addToQueryIfNeeded(_q, "server"s, server);
+return _q;
+}
+
+ BaseJob::Body QueryPublicRoomsJob::buildBody(std::string server, std::optional<int> limit, std::string since, std::optional<Filter> filter, std::optional<bool> includeAllNetworks, std::string thirdPartyInstanceId)
+ {
+ // ignore unused param
+ (void)(server);(void)(limit);(void)(since);(void)(filter);(void)(includeAllNetworks);(void)(thirdPartyInstanceId);
+
+ json _data
+ ;
+
+
+ addToJsonIfNeeded(_data, "limit"s, limit);
+
+ addToJsonIfNeeded(_data, "since"s, since);
+
+ addToJsonIfNeeded(_data, "filter"s, filter);
+
+ addToJsonIfNeeded(_data, "include_all_networks"s, includeAllNetworks);
+
+ addToJsonIfNeeded(_data, "third_party_instance_id"s, thirdPartyInstanceId);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+QueryPublicRoomsJob::QueryPublicRoomsJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string server, std::optional<int> limit, std::string since, std::optional<Filter> filter, std::optional<bool> includeAllNetworks, std::string thirdPartyInstanceId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/publicRooms",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(server, limit, since, filter, includeAllNetworks, thirdPartyInstanceId)
+ , buildQuery(server))
+ {
+
+
+ //addExpectedKey("chunk");
+ }
+
+
+
+ immer::array<PublicRoomsChunk> QueryPublicRoomsJob::chunk(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("chunk"s)) {
+ return
+ jsonBody(r).get()["chunk"s]
+ /*.get<immer::array<PublicRoomsChunk>>()*/;}
+ else { return immer::array<PublicRoomsChunk>( );}
+ }
+
+
+ std::string QueryPublicRoomsJob::nextBatch(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("next_batch"s)) {
+ return
+ jsonBody(r).get()["next_batch"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ std::string QueryPublicRoomsJob::prevBatch(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("prev_batch"s)) {
+ return
+ jsonBody(r).get()["prev_batch"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ std::optional<int> QueryPublicRoomsJob::totalRoomCountEstimate(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("total_room_count_estimate"s)) {
+ return
+ jsonBody(r).get()["total_room_count_estimate"s]
+ /*.get<int>()*/;}
+ else { return std::optional<int>( );}
+ }
+
+}
diff --git a/src/csapi/list_public_rooms.hpp b/src/csapi/list_public_rooms.hpp
new file mode 100644
index 0000000..5592b96
--- /dev/null
+++ b/src/csapi/list_public_rooms.hpp
@@ -0,0 +1,282 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+#include "csapi/definitions/public_rooms_response.hpp"
+
+namespace Kazv {
+
+/*! \brief Gets the visibility of a room in the directory
+ *
+ * Gets the visibility of a given room on the server's public room directory.
+ */
+class GetRoomVisibilityOnDirectoryJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Gets the visibility of a room in the directory
+ *
+ * \param roomId
+ * The room ID.
+ */
+ explicit GetRoomVisibilityOnDirectoryJob(std::string serverUrl
+
+ ,
+ std::string roomId );
+
+
+ // Result properties
+
+
+
+
+/// The visibility of the room in the directory.
+static std::string visibility(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string roomId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Sets the visibility of a room in the room directory
+ *
+ * Sets the visibility of a given room in the server's public room
+ * directory.
+ *
+ * Servers may choose to implement additional access control checks
+ * here, for instance that room visibility can only be changed by
+ * the room creator or a server administrator.
+ */
+class SetRoomVisibilityOnDirectoryJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Sets the visibility of a room in the room directory
+ *
+ * \param roomId
+ * The room ID.
+ *
+ * \param visibility
+ * The new visibility setting for the room.
+ * Defaults to 'public'.
+ */
+ explicit SetRoomVisibilityOnDirectoryJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId , std::string visibility = {});
+
+
+
+
+ static BaseJob::Body buildBody(std::string roomId, std::string visibility);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Lists the public rooms on the server.
+ *
+ * Lists the public rooms on the server.
+ *
+ * This API returns paginated responses. The rooms are ordered by the number
+ * of joined members, with the largest rooms first.
+ */
+class GetPublicRoomsJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Lists the public rooms on the server.
+ *
+ * \param limit
+ * Limit the number of results returned.
+ *
+ * \param since
+ * A pagination token from a previous request, allowing clients to
+ * get the next (or previous) batch of rooms.
+ * The direction of pagination is specified solely by which token
+ * is supplied, rather than via an explicit flag.
+ *
+ * \param server
+ * The server to fetch the public room lists from. Defaults to the
+ * local server.
+ */
+ explicit GetPublicRoomsJob(std::string serverUrl
+
+ ,
+ std::optional<int> limit = std::nullopt, std::string since = {}, std::string server = {});
+
+
+ // Result properties
+
+
+
+
+/// A paginated chunk of public rooms.
+static immer::array<PublicRoomsChunk> chunk(Response r);
+
+
+/// A pagination token for the response. The absence of this token
+/// means there are no more results to fetch and the client should
+/// stop paginating.
+static std::string nextBatch(Response r);
+
+
+/// A pagination token that allows fetching previous results. The
+/// absence of this token means there are no results before this
+/// batch, i.e. this is the first batch.
+static std::string prevBatch(Response r);
+
+
+/// An estimate on the total number of public rooms, if the
+/// server has an estimate.
+static std::optional<int> totalRoomCountEstimate(Response r);
+
+ static BaseJob::Query buildQuery(
+ std::optional<int> limit, std::string since, std::string server);
+
+ static BaseJob::Body buildBody(std::optional<int> limit, std::string since, std::string server);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Lists the public rooms on the server with optional filter.
+ *
+ * Lists the public rooms on the server, with optional filter.
+ *
+ * This API returns paginated responses. The rooms are ordered by the number
+ * of joined members, with the largest rooms first.
+ */
+class QueryPublicRoomsJob : public BaseJob {
+public:
+ // Inner data structures
+
+/// Filter to apply to the results.
+ struct Filter
+ {
+/// A string to search for in the room metadata, e.g. name,
+/// topic, canonical alias etc. (Optional).
+ std::string genericSearchTerm;
+
+ };
+
+
+// Construction/destruction
+
+ /*! \brief Lists the public rooms on the server with optional filter.
+ *
+ * \param server
+ * The server to fetch the public room lists from. Defaults to the
+ * local server.
+ *
+ * \param limit
+ * Limit the number of results returned.
+ *
+ * \param since
+ * A pagination token from a previous request, allowing clients
+ * to get the next (or previous) batch of rooms. The direction
+ * of pagination is specified solely by which token is supplied,
+ * rather than via an explicit flag.
+ *
+ * \param filter
+ * Filter to apply to the results.
+ *
+ * \param includeAllNetworks
+ * Whether or not to include all known networks/protocols from
+ * application services on the homeserver. Defaults to false.
+ *
+ * \param thirdPartyInstanceId
+ * The specific third party network/protocol to request from the
+ * homeserver. Can only be used if ``include_all_networks`` is false.
+ */
+ explicit QueryPublicRoomsJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string server = {}, std::optional<int> limit = std::nullopt, std::string since = {}, std::optional<Filter> filter = std::nullopt, std::optional<bool> includeAllNetworks = std::nullopt, std::string thirdPartyInstanceId = {});
+
+
+ // Result properties
+
+
+
+
+/// A paginated chunk of public rooms.
+static immer::array<PublicRoomsChunk> chunk(Response r);
+
+
+/// A pagination token for the response. The absence of this token
+/// means there are no more results to fetch and the client should
+/// stop paginating.
+static std::string nextBatch(Response r);
+
+
+/// A pagination token that allows fetching previous results. The
+/// absence of this token means there are no results before this
+/// batch, i.e. this is the first batch.
+static std::string prevBatch(Response r);
+
+
+/// An estimate on the total number of public rooms, if the
+/// server has an estimate.
+static std::optional<int> totalRoomCountEstimate(Response r);
+
+ static BaseJob::Query buildQuery(
+ std::string server);
+
+ static BaseJob::Body buildBody(std::string server, std::optional<int> limit, std::string since, std::optional<Filter> filter, std::optional<bool> includeAllNetworks, std::string thirdPartyInstanceId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+ template<>
+ struct adl_serializer<QueryPublicRoomsJob::Filter> {
+ static void to_json(json& jo, const QueryPublicRoomsJob::Filter &pod)
+ {
+
+
+
+ addToJsonIfNeeded(jo, "generic_search_term"s, pod.genericSearchTerm);
+ }
+
+};
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/login.cpp b/src/csapi/login.cpp
new file mode 100644
index 0000000..a831ff0
--- /dev/null
+++ b/src/csapi/login.cpp
@@ -0,0 +1,150 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "login.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body GetLoginFlowsJob::buildBody()
+ {
+ // ignore unused param
+
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetLoginFlowsJob::GetLoginFlowsJob(
+ std::string serverUrl
+
+
+ )
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/login",
+ GET,
+ {} ,
+ ReturnType::Json,
+ buildBody()
+ )
+ {
+
+
+ }
+
+
+
+ immer::array<GetLoginFlowsJob::LoginFlow> GetLoginFlowsJob::flows(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("flows"s)) {
+ return
+ jsonBody(r).get()["flows"s]
+ /*.get<immer::array<LoginFlow>>()*/;}
+ else { return immer::array<LoginFlow>( );}
+ }
+
+
+
+ BaseJob::Body LoginJob::buildBody(std::string type, std::optional<UserIdentifier> identifier, std::string password, std::string token, std::string deviceId, std::string initialDeviceDisplayName)
+ {
+ // ignore unused param
+ (void)(type);(void)(identifier);(void)(password);(void)(token);(void)(deviceId);(void)(initialDeviceDisplayName);
+
+ json _data
+ ;
+
+ _data["type"s] = type;
+
+
+ addToJsonIfNeeded(_data, "identifier"s, identifier);
+
+ addToJsonIfNeeded(_data, "password"s, password);
+
+ addToJsonIfNeeded(_data, "token"s, token);
+
+ addToJsonIfNeeded(_data, "device_id"s, deviceId);
+
+ addToJsonIfNeeded(_data, "initial_device_display_name"s, initialDeviceDisplayName);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+LoginJob::LoginJob(
+ std::string serverUrl
+
+ ,
+ std::string type, std::optional<UserIdentifier> identifier, std::string password, std::string token, std::string deviceId, std::string initialDeviceDisplayName)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/login",
+ POST,
+ {} ,
+ ReturnType::Json,
+ buildBody(type, identifier, password, token, deviceId, initialDeviceDisplayName)
+ )
+ {
+
+
+ }
+
+
+
+ std::string LoginJob::userId(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("user_id"s)) {
+ return
+ jsonBody(r).get()["user_id"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ std::string LoginJob::accessToken(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("access_token"s)) {
+ return
+ jsonBody(r).get()["access_token"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ std::string LoginJob::homeServer(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("home_server"s)) {
+ return
+ jsonBody(r).get()["home_server"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ std::string LoginJob::deviceId(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("device_id"s)) {
+ return
+ jsonBody(r).get()["device_id"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ std::optional<DiscoveryInformation> LoginJob::wellKnown(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("well_known"s)) {
+ return
+ jsonBody(r).get()["well_known"s]
+ /*.get<DiscoveryInformation>()*/;}
+ else { return std::optional<DiscoveryInformation>( );}
+ }
+
+}
diff --git a/src/csapi/login.hpp b/src/csapi/login.hpp
new file mode 100644
index 0000000..e5186c1
--- /dev/null
+++ b/src/csapi/login.hpp
@@ -0,0 +1,181 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+#include "csapi/definitions/wellknown/full.hpp"
+#include "csapi/definitions/user_identifier.hpp"
+
+namespace Kazv {
+
+/*! \brief Get the supported login types to authenticate users
+ *
+ * Gets the homeserver's supported login types to authenticate users. Clients
+ * should pick one of these and supply it as the ``type`` when logging in.
+ */
+class GetLoginFlowsJob : public BaseJob {
+public:
+ // Inner data structures
+
+/// Gets the homeserver's supported login types to authenticate users. Clients
+/// should pick one of these and supply it as the ``type`` when logging in.
+ struct LoginFlow
+ {
+/// The login type. This is supplied as the ``type`` when
+/// logging in.
+ std::string type;
+
+ };
+
+
+// Construction/destruction
+
+ /// Get the supported login types to authenticate users
+ explicit GetLoginFlowsJob(std::string serverUrl
+
+
+ );
+
+
+ // Result properties
+
+
+
+
+/// The homeserver's supported login types
+static immer::array<LoginFlow> flows(Response r);
+
+
+
+ static BaseJob::Body buildBody();
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+ template<>
+ struct adl_serializer<GetLoginFlowsJob::LoginFlow> {
+
+ static void from_json(const json &jo, GetLoginFlowsJob::LoginFlow& result)
+ {
+
+ result.type = jo.at("type"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Authenticates the user.
+ *
+ * Authenticates the user, and issues an access token they can
+ * use to authorize themself in subsequent requests.
+ *
+ * If the client does not supply a ``device_id``, the server must
+ * auto-generate one.
+ *
+ * The returned access token must be associated with the ``device_id``
+ * supplied by the client or generated by the server. The server may
+ * invalidate any access token previously associated with that device. See
+ * `Relationship between access tokens and devices`_.
+ */
+class LoginJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Authenticates the user.
+ *
+ * \param type
+ * The login type being used.
+ *
+ * \param identifier
+ * Authenticates the user, and issues an access token they can
+ * use to authorize themself in subsequent requests.
+ *
+ * If the client does not supply a ``device_id``, the server must
+ * auto-generate one.
+ *
+ * The returned access token must be associated with the ``device_id``
+ * supplied by the client or generated by the server. The server may
+ * invalidate any access token previously associated with that device. See
+ * `Relationship between access tokens and devices`_.
+ *
+ * \param password
+ * Required when ``type`` is ``m.login.password``. The user's
+ * password.
+ *
+ * \param token
+ * Required when ``type`` is ``m.login.token``. Part of `Token-based`_ login.
+ *
+ * \param deviceId
+ * ID of the client device. If this does not correspond to a
+ * known client device, a new device will be created. The server
+ * will auto-generate a device_id if this is not specified.
+ *
+ * \param initialDeviceDisplayName
+ * A display name to assign to the newly-created device. Ignored
+ * if ``device_id`` corresponds to a known device.
+ */
+ explicit LoginJob(std::string serverUrl
+
+ ,
+ std::string type , std::optional<UserIdentifier> identifier = std::nullopt, std::string password = {}, std::string token = {}, std::string deviceId = {}, std::string initialDeviceDisplayName = {});
+
+
+ // Result properties
+
+
+
+
+/// The fully-qualified Matrix ID for the account.
+static std::string userId(Response r);
+
+
+/// An access token for the account.
+/// This access token can then be used to authorize other requests.
+static std::string accessToken(Response r);
+
+
+/// The server_name of the homeserver on which the account has
+/// been registered.
+///
+/// **Deprecated**. Clients should extract the server_name from
+/// ``user_id`` (by splitting at the first colon) if they require
+/// it. Note also that ``homeserver`` is not spelt this way.
+static std::string homeServer(Response r);
+
+
+/// ID of the logged-in device. Will be the same as the
+/// corresponding parameter in the request, if one was specified.
+static std::string deviceId(Response r);
+
+
+/// Optional client configuration provided by the server. If present,
+/// clients SHOULD use the provided object to reconfigure themselves,
+/// optionally validating the URLs within. This object takes the same
+/// form as the one returned from .well-known autodiscovery.
+static std::optional<DiscoveryInformation> wellKnown(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string type, std::optional<UserIdentifier> identifier, std::string password, std::string token, std::string deviceId, std::string initialDeviceDisplayName);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/logout.cpp b/src/csapi/logout.cpp
new file mode 100644
index 0000000..bd23cb6
--- /dev/null
+++ b/src/csapi/logout.cpp
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "logout.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body LogoutJob::buildBody()
+ {
+ // ignore unused param
+
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+LogoutJob::LogoutJob(
+ std::string serverUrl
+ , std::string _accessToken
+
+ )
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/logout",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody()
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body LogoutAllJob::buildBody()
+ {
+ // ignore unused param
+
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+LogoutAllJob::LogoutAllJob(
+ std::string serverUrl
+ , std::string _accessToken
+
+ )
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/logout/all",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody()
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/logout.hpp b/src/csapi/logout.hpp
new file mode 100644
index 0000000..301df4c
--- /dev/null
+++ b/src/csapi/logout.hpp
@@ -0,0 +1,88 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Invalidates a user access token
+ *
+ * Invalidates an existing access token, so that it can no longer be used for
+ * authorization. The device associated with the access token is also deleted.
+ * `Device keys <#device-keys>`_ for the device are deleted alongside the device.
+ */
+class LogoutJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /// Invalidates a user access token
+ explicit LogoutJob(std::string serverUrl
+ , std::string _accessToken
+
+ );
+
+
+
+
+ static BaseJob::Body buildBody();
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Invalidates all access tokens for a user
+ *
+ * Invalidates all access tokens for a user, so that they can no longer be used for
+ * authorization. This includes the access token that made this request. All devices
+ * for the user are also deleted. `Device keys <#device-keys>`_ for the device are
+ * deleted alongside the device.
+ *
+ * This endpoint does not use the `User-Interactive Authentication API`_ because
+ * User-Interactive Authentication is designed to protect against attacks where the
+ * someone gets hold of a single access token then takes over the account. This
+ * endpoint invalidates all access tokens for the user, including the token used in
+ * the request, and therefore the attacker is unable to take over the account in
+ * this way.
+ */
+class LogoutAllJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /// Invalidates all access tokens for a user
+ explicit LogoutAllJob(std::string serverUrl
+ , std::string _accessToken
+
+ );
+
+
+
+
+ static BaseJob::Body buildBody();
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/message_pagination.cpp b/src/csapi/message_pagination.cpp
new file mode 100644
index 0000000..b8205d3
--- /dev/null
+++ b/src/csapi/message_pagination.cpp
@@ -0,0 +1,99 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "message_pagination.hpp"
+
+namespace Kazv
+{
+
+BaseJob::Query GetRoomEventsJob::buildQuery(
+std::string from, std::string to, std::string dir, std::optional<int> limit, std::string filter)
+{
+BaseJob::Query _q;
+ addToQuery(_q, "from"s, from);
+
+
+ addToQueryIfNeeded(_q, "to"s, to);
+ addToQuery(_q, "dir"s, dir);
+
+
+ addToQueryIfNeeded(_q, "limit"s, limit);
+
+ addToQueryIfNeeded(_q, "filter"s, filter);
+return _q;
+}
+
+ BaseJob::Body GetRoomEventsJob::buildBody(std::string roomId, std::string from, std::string dir, std::string to, std::optional<int> limit, std::string filter)
+ {
+ // ignore unused param
+ (void)(roomId);(void)(from);(void)(dir);(void)(to);(void)(limit);(void)(filter);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetRoomEventsJob::GetRoomEventsJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId, std::string from, std::string dir, std::string to, std::optional<int> limit, std::string filter)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/messages",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId, from, dir, to, limit, filter)
+ , buildQuery(from, to, dir, limit, filter))
+ {
+
+
+ }
+
+
+
+ std::string GetRoomEventsJob::start(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("start"s)) {
+ return
+ jsonBody(r).get()["start"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ std::string GetRoomEventsJob::end(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("end"s)) {
+ return
+ jsonBody(r).get()["end"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ EventList GetRoomEventsJob::chunk(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("chunk"s)) {
+ return
+ jsonBody(r).get()["chunk"s]
+ /*.get<EventList>()*/;}
+ else { return EventList( );}
+ }
+
+
+ EventList GetRoomEventsJob::state(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("state"s)) {
+ return
+ jsonBody(r).get()["state"s]
+ /*.get<EventList>()*/;}
+ else { return EventList( );}
+ }
+
+}
diff --git a/src/csapi/message_pagination.hpp b/src/csapi/message_pagination.hpp
new file mode 100644
index 0000000..199e25e
--- /dev/null
+++ b/src/csapi/message_pagination.hpp
@@ -0,0 +1,106 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Get a list of events for this room
+ *
+ * This API returns a list of message and state events for a room. It uses
+ * pagination query parameters to paginate history in the room.
+ *
+ * *Note*: This endpoint supports lazy-loading of room member events. See
+ * `Lazy-loading room members <#lazy-loading-room-members>`_ for more information.
+ */
+class GetRoomEventsJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Get a list of events for this room
+ *
+ * \param roomId
+ * The room to get events from.
+ *
+ * \param from
+ * The token to start returning events from. This token can be obtained
+ * from a ``prev_batch`` token returned for each room by the sync API,
+ * or from a ``start`` or ``end`` token returned by a previous request
+ * to this endpoint.
+ *
+ * \param dir
+ * The direction to return events from.
+ *
+ * \param to
+ * The token to stop returning events at. This token can be obtained from
+ * a ``prev_batch`` token returned for each room by the sync endpoint,
+ * or from a ``start`` or ``end`` token returned by a previous request to
+ * this endpoint.
+ *
+ * \param limit
+ * The maximum number of events to return. Default: 10.
+ *
+ * \param filter
+ * A JSON RoomEventFilter to filter returned events with.
+ */
+ explicit GetRoomEventsJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId , std::string from , std::string dir , std::string to = {}, std::optional<int> limit = std::nullopt, std::string filter = {});
+
+
+ // Result properties
+
+
+
+
+/// The token the pagination starts from. If ``dir=b`` this will be
+/// the token supplied in ``from``.
+static std::string start(Response r);
+
+
+/// The token the pagination ends at. If ``dir=b`` this token should
+/// be used again to request even earlier events.
+static std::string end(Response r);
+
+
+/// A list of room events. The order depends on the ``dir`` parameter.
+/// For ``dir=b`` events will be in reverse-chronological order,
+/// for ``dir=f`` in chronological order, so that events start
+/// at the ``from`` point.
+static EventList chunk(Response r);
+
+
+/// A list of state events relevant to showing the ``chunk``. For example, if
+/// ``lazy_load_members`` is enabled in the filter then this may contain
+/// the membership events for the senders of events in the ``chunk``.
+///
+/// Unless ``include_redundant_members`` is ``true``, the server
+/// may remove membership events which would have already been
+/// sent to the client in prior calls to this endpoint, assuming
+/// the membership of those members has not changed.
+static EventList state(Response r);
+
+ static BaseJob::Query buildQuery(
+ std::string from, std::string to, std::string dir, std::optional<int> limit, std::string filter);
+
+ static BaseJob::Body buildBody(std::string roomId, std::string from, std::string dir, std::string to, std::optional<int> limit, std::string filter);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/notifications.cpp b/src/csapi/notifications.cpp
new file mode 100644
index 0000000..51f86f9
--- /dev/null
+++ b/src/csapi/notifications.cpp
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "notifications.hpp"
+
+namespace Kazv
+{
+
+BaseJob::Query GetNotificationsJob::buildQuery(
+std::string from, std::optional<int> limit, std::string only)
+{
+BaseJob::Query _q;
+
+ addToQueryIfNeeded(_q, "from"s, from);
+
+ addToQueryIfNeeded(_q, "limit"s, limit);
+
+ addToQueryIfNeeded(_q, "only"s, only);
+return _q;
+}
+
+ BaseJob::Body GetNotificationsJob::buildBody(std::string from, std::optional<int> limit, std::string only)
+ {
+ // ignore unused param
+ (void)(from);(void)(limit);(void)(only);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetNotificationsJob::GetNotificationsJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string from, std::optional<int> limit, std::string only)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/notifications",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(from, limit, only)
+ , buildQuery(from, limit, only))
+ {
+
+
+ //addExpectedKey("notifications");
+ }
+
+
+
+ std::string GetNotificationsJob::nextToken(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("next_token"s)) {
+ return
+ jsonBody(r).get()["next_token"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ immer::array<GetNotificationsJob::Notification> GetNotificationsJob::notifications(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("notifications"s)) {
+ return
+ jsonBody(r).get()["notifications"s]
+ /*.get<immer::array<Notification>>()*/;}
+ else { return immer::array<Notification>( );}
+ }
+
+}
diff --git a/src/csapi/notifications.hpp b/src/csapi/notifications.hpp
new file mode 100644
index 0000000..ce30875
--- /dev/null
+++ b/src/csapi/notifications.hpp
@@ -0,0 +1,109 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Gets a list of events that the user has been notified about
+ *
+ * This API is used to paginate through the list of events that the
+ * user has been, or would have been notified about.
+ */
+class GetNotificationsJob : public BaseJob {
+public:
+ // Inner data structures
+
+/// This API is used to paginate through the list of events that the
+/// user has been, or would have been notified about.
+ struct Notification
+ {
+/// The action(s) to perform when the conditions for this rule are met.
+/// See `Push Rules: API`_.
+ immer::array<Variant> actions;
+/// The Event object for the event that triggered the notification.
+ JsonWrap event;
+/// The profile tag of the rule that matched this event.
+ std::string profileTag;
+/// Indicates whether the user has sent a read receipt indicating
+/// that they have read this message.
+ bool read;
+/// The ID of the room in which the event was posted.
+ std::string roomId;
+/// The unix timestamp at which the event notification was sent,
+/// in milliseconds.
+ int ts;
+
+ };
+
+
+// Construction/destruction
+
+ /*! \brief Gets a list of events that the user has been notified about
+ *
+ * \param from
+ * Pagination token given to retrieve the next set of events.
+ *
+ * \param limit
+ * Limit on the number of events to return in this request.
+ *
+ * \param only
+ * Allows basic filtering of events returned. Supply ``highlight``
+ * to return only events where the notification had the highlight
+ * tweak set.
+ */
+ explicit GetNotificationsJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string from = {}, std::optional<int> limit = std::nullopt, std::string only = {});
+
+
+ // Result properties
+
+
+
+
+/// The token to supply in the ``from`` param of the next
+/// ``/notifications`` request in order to request more
+/// events. If this is absent, there are no more results.
+static std::string nextToken(Response r);
+
+
+/// The list of events that triggered notifications.
+static immer::array<Notification> notifications(Response r);
+
+ static BaseJob::Query buildQuery(
+ std::string from, std::optional<int> limit, std::string only);
+
+ static BaseJob::Body buildBody(std::string from, std::optional<int> limit, std::string only);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+ template<>
+ struct adl_serializer<GetNotificationsJob::Notification> {
+
+ static void from_json(const json &jo, GetNotificationsJob::Notification& result)
+ {
+
+ result.actions = jo.at("actions"s);
+ result.event = jo.at("event"s);
+ result.profileTag = jo.at("profile_tag"s);
+ result.read = jo.at("read"s);
+ result.roomId = jo.at("room_id"s);
+ result.ts = jo.at("ts"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/old_sync.cpp b/src/csapi/old_sync.cpp
new file mode 100644
index 0000000..153d9bc
--- /dev/null
+++ b/src/csapi/old_sync.cpp
@@ -0,0 +1,199 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "old_sync.hpp"
+
+namespace Kazv
+{
+
+BaseJob::Query GetEventsJob::buildQuery(
+std::string from, std::optional<int> timeout)
+{
+BaseJob::Query _q;
+
+ addToQueryIfNeeded(_q, "from"s, from);
+
+ addToQueryIfNeeded(_q, "timeout"s, timeout);
+return _q;
+}
+
+ BaseJob::Body GetEventsJob::buildBody(std::string from, std::optional<int> timeout)
+ {
+ // ignore unused param
+ (void)(from);(void)(timeout);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetEventsJob::GetEventsJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string from, std::optional<int> timeout)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/events",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(from, timeout)
+ , buildQuery(from, timeout))
+ {
+
+
+ }
+
+
+
+ std::string GetEventsJob::start(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("start"s)) {
+ return
+ jsonBody(r).get()["start"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ std::string GetEventsJob::end(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("end"s)) {
+ return
+ jsonBody(r).get()["end"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ EventList GetEventsJob::chunk(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("chunk"s)) {
+ return
+ jsonBody(r).get()["chunk"s]
+ /*.get<EventList>()*/;}
+ else { return EventList( );}
+ }
+
+
+BaseJob::Query InitialSyncJob::buildQuery(
+std::optional<int> limit, std::optional<bool> archived)
+{
+BaseJob::Query _q;
+
+ addToQueryIfNeeded(_q, "limit"s, limit);
+
+ addToQueryIfNeeded(_q, "archived"s, archived);
+return _q;
+}
+
+ BaseJob::Body InitialSyncJob::buildBody(std::optional<int> limit, std::optional<bool> archived)
+ {
+ // ignore unused param
+ (void)(limit);(void)(archived);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+InitialSyncJob::InitialSyncJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::optional<int> limit, std::optional<bool> archived)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/initialSync",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(limit, archived)
+ , buildQuery(limit, archived))
+ {
+
+
+ //addExpectedKey("end");
+ //addExpectedKey("presence");
+ //addExpectedKey("rooms");
+ }
+
+
+
+ std::string InitialSyncJob::end(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("end"s)) {
+ return
+ jsonBody(r).get()["end"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ EventList InitialSyncJob::presence(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("presence"s)) {
+ return
+ jsonBody(r).get()["presence"s]
+ /*.get<EventList>()*/;}
+ else { return EventList( );}
+ }
+
+
+ immer::array<InitialSyncJob::RoomInfo> InitialSyncJob::rooms(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("rooms"s)) {
+ return
+ jsonBody(r).get()["rooms"s]
+ /*.get<immer::array<RoomInfo>>()*/;}
+ else { return immer::array<RoomInfo>( );}
+ }
+
+
+ EventList InitialSyncJob::accountData(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("account_data"s)) {
+ return
+ jsonBody(r).get()["account_data"s]
+ /*.get<EventList>()*/;}
+ else { return EventList( );}
+ }
+
+
+
+ BaseJob::Body GetOneEventJob::buildBody(std::string eventId)
+ {
+ // ignore unused param
+ (void)(eventId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetOneEventJob::GetOneEventJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string eventId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/events/" + eventId,
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(eventId)
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/old_sync.hpp b/src/csapi/old_sync.hpp
new file mode 100644
index 0000000..dfabb79
--- /dev/null
+++ b/src/csapi/old_sync.hpp
@@ -0,0 +1,285 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+#include "csapi/definitions/event-schemas/schema/m.room.member.hpp"
+
+namespace Kazv {
+
+/*! \brief Listen on the event stream.
+ *
+ * This will listen for new events and return them to the caller. This will
+ * block until an event is received, or until the ``timeout`` is reached.
+ *
+ * This endpoint was deprecated in r0 of this specification. Clients
+ * should instead call the |/sync|_ API with a ``since`` parameter. See
+ * the `migration guide
+ * <https://matrix.org/docs/guides/client-server-migrating-from-v1.html#deprecated-endpoints>`_.
+ */
+class GetEventsJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Listen on the event stream.
+ *
+ * \param from
+ * The token to stream from. This token is either from a previous
+ * request to this API or from the initial sync API.
+ *
+ * \param timeout
+ * The maximum time in milliseconds to wait for an event.
+ */
+ explicit GetEventsJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string from = {}, std::optional<int> timeout = std::nullopt);
+
+
+ // Result properties
+
+
+
+
+/// A token which correlates to the first value in ``chunk``. This
+/// is usually the same token supplied to ``from=``.
+static std::string start(Response r);
+
+
+/// A token which correlates to the last value in ``chunk``. This
+/// token should be used in the next request to ``/events``.
+static std::string end(Response r);
+
+
+/// An array of events.
+static EventList chunk(Response r);
+
+ static BaseJob::Query buildQuery(
+ std::string from, std::optional<int> timeout);
+
+ static BaseJob::Body buildBody(std::string from, std::optional<int> timeout);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Get the user's current state.
+ *
+ * This returns the full state for this user, with an optional limit on the
+ * number of messages per room to return.
+ *
+ * This endpoint was deprecated in r0 of this specification. Clients
+ * should instead call the |/sync|_ API with no ``since`` parameter. See
+ * the `migration guide
+ * <https://matrix.org/docs/guides/client-server-migrating-from-v1.html#deprecated-endpoints>`_.
+ */
+class InitialSyncJob : public BaseJob {
+public:
+ // Inner data structures
+
+/// The pagination chunk for this room.
+ struct PaginationChunk
+ {
+/// A token which correlates to the first value in ``chunk``.
+/// Used for pagination.
+ std::string start;
+/// A token which correlates to the last value in ``chunk``.
+/// Used for pagination.
+ std::string end;
+/// If the user is a member of the room this will be a
+/// list of the most recent messages for this room. If
+/// the user has left the room this will be the
+/// messages that preceeded them leaving. This array
+/// will consist of at most ``limit`` elements.
+ EventList chunk;
+
+ };
+
+/// This returns the full state for this user, with an optional limit on the
+/// number of messages per room to return.
+///
+/// This endpoint was deprecated in r0 of this specification. Clients
+/// should instead call the |/sync|_ API with no ``since`` parameter. See
+/// the `migration guide
+/// <https://matrix.org/docs/guides/client-server-migrating-from-v1.html#deprecated-endpoints>`_.
+ struct RoomInfo
+ {
+/// The ID of this room.
+ std::string roomId;
+/// The user's membership state in this room.
+ std::string membership;
+/// The invite event if ``membership`` is ``invite``
+ std::optional<TheCurrentMembershipStateOfAUserInTheRoom> invite;
+/// The pagination chunk for this room.
+ std::optional<PaginationChunk> messages;
+/// If the user is a member of the room this will be the
+/// current state of the room as a list of events. If the
+/// user has left the room this will be the state of the
+/// room when they left it.
+ EventList state;
+/// Whether this room is visible to the ``/publicRooms`` API
+/// or not."
+ std::string visibility;
+/// The private data that this user has attached to
+/// this room.
+ EventList accountData;
+
+ };
+
+
+// Construction/destruction
+
+ /*! \brief Get the user's current state.
+ *
+ * \param limit
+ * The maximum number of messages to return for each room.
+ *
+ * \param archived
+ * Whether to include rooms that the user has left. If ``false`` then
+ * only rooms that the user has been invited to or has joined are
+ * included. If set to ``true`` then rooms that the user has left are
+ * included as well. By default this is ``false``.
+ */
+ explicit InitialSyncJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::optional<int> limit = std::nullopt, std::optional<bool> archived = std::nullopt);
+
+
+ // Result properties
+
+
+
+
+/// A token which correlates to the last value in ``chunk``. This
+/// token should be used with the ``/events`` API to listen for new
+/// events.
+static std::string end(Response r);
+
+
+/// A list of presence events.
+static EventList presence(Response r);
+
+
+/// This returns the full state for this user, with an optional limit on the
+/// number of messages per room to return.
+///
+/// This endpoint was deprecated in r0 of this specification. Clients
+/// should instead call the |/sync|_ API with no ``since`` parameter. See
+/// the `migration guide
+/// <https://matrix.org/docs/guides/client-server-migrating-from-v1.html#deprecated-endpoints>`_.
+static immer::array<RoomInfo> rooms(Response r);
+
+
+/// The global private data created by this user.
+static EventList accountData(Response r);
+
+ static BaseJob::Query buildQuery(
+ std::optional<int> limit, std::optional<bool> archived);
+
+ static BaseJob::Body buildBody(std::optional<int> limit, std::optional<bool> archived);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+ template<>
+ struct adl_serializer<InitialSyncJob::PaginationChunk> {
+
+ static void from_json(const json &jo, InitialSyncJob::PaginationChunk& result)
+ {
+
+ result.start = jo.at("start"s);
+ result.end = jo.at("end"s);
+ result.chunk = jo.at("chunk"s);
+
+ }
+};
+ template<>
+ struct adl_serializer<InitialSyncJob::RoomInfo> {
+
+ static void from_json(const json &jo, InitialSyncJob::RoomInfo& result)
+ {
+
+ result.roomId = jo.at("room_id"s);
+ result.membership = jo.at("membership"s);
+ result.invite = jo.at("invite"s);
+ result.messages = jo.at("messages"s);
+ result.state = jo.at("state"s);
+ result.visibility = jo.at("visibility"s);
+ result.accountData = jo.at("account_data"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Get a single event by event ID.
+ *
+ * Get a single event based on ``event_id``. You must have permission to
+ * retrieve this event e.g. by being a member in the room for this event.
+ *
+ * This endpoint was deprecated in r0 of this specification. Clients
+ * should instead call the |/rooms/{roomId}/event/{eventId}|_ API
+ * or the |/rooms/{roomId}/context/{eventId}|_ API.
+ */
+class GetOneEventJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Get a single event by event ID.
+ *
+ * \param eventId
+ * The event ID to get.
+ */
+ explicit GetOneEventJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string eventId );
+
+
+ // Result properties
+
+
+/// The full event.
+ static JsonWrap data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<JsonWrap>()
+ ;
+ }
+
+
+
+
+ static BaseJob::Body buildBody(std::string eventId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/openid.cpp b/src/csapi/openid.cpp
new file mode 100644
index 0000000..d699e04
--- /dev/null
+++ b/src/csapi/openid.cpp
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "openid.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body RequestOpenIdTokenJob::buildBody(std::string userId, JsonWrap body)
+ {
+ // ignore unused param
+ (void)(userId);(void)(body);
+ return
+ BaseJob::JsonBody(body);
+
+
+
+ };
+
+RequestOpenIdTokenJob::RequestOpenIdTokenJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId, JsonWrap body)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/user/" + userId + "/openid/request_token",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(userId, body)
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/openid.hpp b/src/csapi/openid.hpp
new file mode 100644
index 0000000..1dc1c94
--- /dev/null
+++ b/src/csapi/openid.hpp
@@ -0,0 +1,75 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+#include "csapi/definitions/openid_token.hpp"
+
+namespace Kazv {
+
+/*! \brief Get an OpenID token object to verify the requester's identity.
+ *
+ * Gets an OpenID token object that the requester may supply to another
+ * service to verify their identity in Matrix. The generated token is only
+ * valid for exchanging for user information from the federation API for
+ * OpenID.
+ *
+ * The access token generated is only valid for the OpenID API. It cannot
+ * be used to request another OpenID access token or call ``/sync``, for
+ * example.
+ */
+class RequestOpenIdTokenJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Get an OpenID token object to verify the requester's identity.
+ *
+ * \param userId
+ * The user to request and OpenID token for. Should be the user who
+ * is authenticated for the request.
+ *
+ * \param body
+ * An empty object. Reserved for future expansion.
+ */
+ explicit RequestOpenIdTokenJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId , JsonWrap body = {});
+
+
+ // Result properties
+
+
+/// OpenID token information. This response is nearly compatible with the
+/// response documented in the `OpenID Connect 1.0 Specification <http://openid.net/specs/openid-connect-core-1_0.html#TokenResponse>`_
+/// with the only difference being the lack of an ``id_token``. Instead,
+/// the Matrix homeserver's name is provided.
+ static OpenidToken data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<OpenidToken>()
+ ;
+ }
+
+
+
+
+ static BaseJob::Body buildBody(std::string userId, JsonWrap body);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/peeking_events.cpp b/src/csapi/peeking_events.cpp
new file mode 100644
index 0000000..f2ac236
--- /dev/null
+++ b/src/csapi/peeking_events.cpp
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "peeking_events.hpp"
+
+namespace Kazv
+{
+
+BaseJob::Query PeekEventsJob::buildQuery(
+std::string from, std::optional<int> timeout, std::string roomId)
+{
+BaseJob::Query _q;
+
+ addToQueryIfNeeded(_q, "from"s, from);
+
+ addToQueryIfNeeded(_q, "timeout"s, timeout);
+
+ addToQueryIfNeeded(_q, "room_id"s, roomId);
+return _q;
+}
+
+ BaseJob::Body PeekEventsJob::buildBody(std::string from, std::optional<int> timeout, std::string roomId)
+ {
+ // ignore unused param
+ (void)(from);(void)(timeout);(void)(roomId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+PeekEventsJob::PeekEventsJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string from, std::optional<int> timeout, std::string roomId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/events",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(from, timeout, roomId)
+ , buildQuery(from, timeout, roomId))
+ {
+
+
+ }
+
+
+
+ std::string PeekEventsJob::start(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("start"s)) {
+ return
+ jsonBody(r).get()["start"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ std::string PeekEventsJob::end(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("end"s)) {
+ return
+ jsonBody(r).get()["end"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ EventList PeekEventsJob::chunk(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("chunk"s)) {
+ return
+ jsonBody(r).get()["chunk"s]
+ /*.get<EventList>()*/;}
+ else { return EventList( );}
+ }
+
+}
diff --git a/src/csapi/peeking_events.hpp b/src/csapi/peeking_events.hpp
new file mode 100644
index 0000000..13fbdf7
--- /dev/null
+++ b/src/csapi/peeking_events.hpp
@@ -0,0 +1,83 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Listen on the event stream.
+ *
+ * This will listen for new events related to a particular room and return
+ * them to the caller. This will block until an event is received, or until
+ * the ``timeout`` is reached.
+ *
+ * This API is the same as the normal ``/events`` endpoint, but can be
+ * called by users who have not joined the room.
+ *
+ * Note that the normal ``/events`` endpoint has been deprecated. This
+ * API will also be deprecated at some point, but its replacement is not
+ * yet known.
+ */
+class PeekEventsJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Listen on the event stream.
+ *
+ * \param from
+ * The token to stream from. This token is either from a previous
+ * request to this API or from the initial sync API.
+ *
+ * \param timeout
+ * The maximum time in milliseconds to wait for an event.
+ *
+ * \param roomId
+ * The room ID for which events should be returned.
+ */
+ explicit PeekEventsJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string from = {}, std::optional<int> timeout = std::nullopt, std::string roomId = {});
+
+
+ // Result properties
+
+
+
+
+/// A token which correlates to the first value in ``chunk``. This
+/// is usually the same token supplied to ``from=``.
+static std::string start(Response r);
+
+
+/// A token which correlates to the last value in ``chunk``. This
+/// token should be used in the next request to ``/events``.
+static std::string end(Response r);
+
+
+/// An array of events.
+static EventList chunk(Response r);
+
+ static BaseJob::Query buildQuery(
+ std::string from, std::optional<int> timeout, std::string roomId);
+
+ static BaseJob::Body buildBody(std::string from, std::optional<int> timeout, std::string roomId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/presence.cpp b/src/csapi/presence.cpp
new file mode 100644
index 0000000..cc7fa54
--- /dev/null
+++ b/src/csapi/presence.cpp
@@ -0,0 +1,121 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "presence.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body SetPresenceJob::buildBody(std::string userId, std::string presence, std::string statusMsg)
+ {
+ // ignore unused param
+ (void)(userId);(void)(presence);(void)(statusMsg);
+
+ json _data
+ ;
+
+ _data["presence"s] = presence;
+
+
+ addToJsonIfNeeded(_data, "status_msg"s, statusMsg);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+SetPresenceJob::SetPresenceJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId, std::string presence, std::string statusMsg)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/presence/" + userId + "/status",
+ PUT,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(userId, presence, statusMsg)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body GetPresenceJob::buildBody(std::string userId)
+ {
+ // ignore unused param
+ (void)(userId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetPresenceJob::GetPresenceJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/presence/" + userId + "/status",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(userId)
+ )
+ {
+
+
+ //addExpectedKey("presence");
+ }
+
+
+
+ std::string GetPresenceJob::presence(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("presence"s)) {
+ return
+ jsonBody(r).get()["presence"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ std::optional<int> GetPresenceJob::lastActiveAgo(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("last_active_ago"s)) {
+ return
+ jsonBody(r).get()["last_active_ago"s]
+ /*.get<int>()*/;}
+ else { return std::optional<int>( );}
+ }
+
+
+ Variant GetPresenceJob::statusMsg(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("status_msg"s)) {
+ return
+ jsonBody(r).get()["status_msg"s]
+ /*.get<Variant>()*/;}
+ else { return Variant( );}
+ }
+
+
+ std::optional<bool> GetPresenceJob::currentlyActive(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("currently_active"s)) {
+ return
+ jsonBody(r).get()["currently_active"s]
+ /*.get<bool>()*/;}
+ else { return std::optional<bool>( );}
+ }
+
+}
diff --git a/src/csapi/presence.hpp b/src/csapi/presence.hpp
new file mode 100644
index 0000000..87db4d7
--- /dev/null
+++ b/src/csapi/presence.hpp
@@ -0,0 +1,114 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Update this user's presence state.
+ *
+ * This API sets the given user's presence state. When setting the status,
+ * the activity time is updated to reflect that activity; the client does
+ * not need to specify the ``last_active_ago`` field. You cannot set the
+ * presence state of another user.
+ */
+class SetPresenceJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Update this user's presence state.
+ *
+ * \param userId
+ * The user whose presence state to update.
+ *
+ * \param presence
+ * The new presence state.
+ *
+ * \param statusMsg
+ * The status message to attach to this state.
+ */
+ explicit SetPresenceJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId , std::string presence , std::string statusMsg = {});
+
+
+
+
+ static BaseJob::Body buildBody(std::string userId, std::string presence, std::string statusMsg);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Get this user's presence state.
+ *
+ * Get the given user's presence state.
+ */
+class GetPresenceJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Get this user's presence state.
+ *
+ * \param userId
+ * The user whose presence state to get.
+ */
+ explicit GetPresenceJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId );
+
+
+ // Result properties
+
+
+
+
+/// This user's presence.
+static std::string presence(Response r);
+
+
+/// The length of time in milliseconds since an action was performed
+/// by this user.
+static std::optional<int> lastActiveAgo(Response r);
+
+
+/// The state message for this user if one was set.
+static Variant statusMsg(Response r);
+
+
+/// Whether the user is currently active
+static std::optional<bool> currentlyActive(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string userId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/profile.cpp b/src/csapi/profile.cpp
new file mode 100644
index 0000000..cee9d74
--- /dev/null
+++ b/src/csapi/profile.cpp
@@ -0,0 +1,213 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "profile.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body SetDisplayNameJob::buildBody(std::string userId, std::string displayname)
+ {
+ // ignore unused param
+ (void)(userId);(void)(displayname);
+
+ json _data
+ ;
+
+
+ addToJsonIfNeeded(_data, "displayname"s, displayname);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+SetDisplayNameJob::SetDisplayNameJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId, std::string displayname)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/profile/" + userId + "/displayname",
+ PUT,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(userId, displayname)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body GetDisplayNameJob::buildBody(std::string userId)
+ {
+ // ignore unused param
+ (void)(userId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetDisplayNameJob::GetDisplayNameJob(
+ std::string serverUrl
+
+ ,
+ std::string userId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/profile/" + userId + "/displayname",
+ GET,
+ {} ,
+ ReturnType::Json,
+ buildBody(userId)
+ )
+ {
+
+
+ }
+
+
+
+ std::string GetDisplayNameJob::displayname(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("displayname"s)) {
+ return
+ jsonBody(r).get()["displayname"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+
+ BaseJob::Body SetAvatarUrlJob::buildBody(std::string userId, std::string avatarUrl)
+ {
+ // ignore unused param
+ (void)(userId);(void)(avatarUrl);
+
+ json _data
+ ;
+
+
+ addToJsonIfNeeded(_data, "avatar_url"s, avatarUrl);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+SetAvatarUrlJob::SetAvatarUrlJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId, std::string avatarUrl)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/profile/" + userId + "/avatar_url",
+ PUT,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(userId, avatarUrl)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body GetAvatarUrlJob::buildBody(std::string userId)
+ {
+ // ignore unused param
+ (void)(userId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetAvatarUrlJob::GetAvatarUrlJob(
+ std::string serverUrl
+
+ ,
+ std::string userId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/profile/" + userId + "/avatar_url",
+ GET,
+ {} ,
+ ReturnType::Json,
+ buildBody(userId)
+ )
+ {
+
+
+ }
+
+
+
+ std::string GetAvatarUrlJob::avatarUrl(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("avatar_url"s)) {
+ return
+ jsonBody(r).get()["avatar_url"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+
+ BaseJob::Body GetUserProfileJob::buildBody(std::string userId)
+ {
+ // ignore unused param
+ (void)(userId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetUserProfileJob::GetUserProfileJob(
+ std::string serverUrl
+
+ ,
+ std::string userId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/profile/" + userId,
+ GET,
+ {} ,
+ ReturnType::Json,
+ buildBody(userId)
+ )
+ {
+
+
+ }
+
+
+
+ std::string GetUserProfileJob::avatarUrl(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("avatar_url"s)) {
+ return
+ jsonBody(r).get()["avatar_url"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ std::string GetUserProfileJob::displayname(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("displayname"s)) {
+ return
+ jsonBody(r).get()["displayname"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+}
diff --git a/src/csapi/profile.hpp b/src/csapi/profile.hpp
new file mode 100644
index 0000000..87509d8
--- /dev/null
+++ b/src/csapi/profile.hpp
@@ -0,0 +1,235 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Set the user's display name.
+ *
+ * This API sets the given user's display name. You must have permission to
+ * set this user's display name, e.g. you need to have their ``access_token``.
+ */
+class SetDisplayNameJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Set the user's display name.
+ *
+ * \param userId
+ * The user whose display name to set.
+ *
+ * \param displayname
+ * The new display name for this user.
+ */
+ explicit SetDisplayNameJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId , std::string displayname = {});
+
+
+
+
+ static BaseJob::Body buildBody(std::string userId, std::string displayname);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Get the user's display name.
+ *
+ * Get the user's display name. This API may be used to fetch the user's
+ * own displayname or to query the name of other users; either locally or
+ * on remote homeservers.
+ */
+class GetDisplayNameJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Get the user's display name.
+ *
+ * \param userId
+ * The user whose display name to get.
+ */
+ explicit GetDisplayNameJob(std::string serverUrl
+
+ ,
+ std::string userId );
+
+
+ // Result properties
+
+
+
+
+/// The user's display name if they have set one, otherwise not present.
+static std::string displayname(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string userId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Set the user's avatar URL.
+ *
+ * This API sets the given user's avatar URL. You must have permission to
+ * set this user's avatar URL, e.g. you need to have their ``access_token``.
+ */
+class SetAvatarUrlJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Set the user's avatar URL.
+ *
+ * \param userId
+ * The user whose avatar URL to set.
+ *
+ * \param avatarUrl
+ * The new avatar URL for this user.
+ */
+ explicit SetAvatarUrlJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId , std::string avatarUrl = {});
+
+
+
+
+ static BaseJob::Body buildBody(std::string userId, std::string avatarUrl);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Get the user's avatar URL.
+ *
+ * Get the user's avatar URL. This API may be used to fetch the user's
+ * own avatar URL or to query the URL of other users; either locally or
+ * on remote homeservers.
+ */
+class GetAvatarUrlJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Get the user's avatar URL.
+ *
+ * \param userId
+ * The user whose avatar URL to get.
+ */
+ explicit GetAvatarUrlJob(std::string serverUrl
+
+ ,
+ std::string userId );
+
+
+ // Result properties
+
+
+
+
+/// The user's avatar URL if they have set one, otherwise not present.
+static std::string avatarUrl(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string userId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Get this user's profile information.
+ *
+ * Get the combined profile information for this user. This API may be used
+ * to fetch the user's own profile information or other users; either
+ * locally or on remote homeservers. This API may return keys which are not
+ * limited to ``displayname`` or ``avatar_url``.
+ */
+class GetUserProfileJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Get this user's profile information.
+ *
+ * \param userId
+ * The user whose profile information to get.
+ */
+ explicit GetUserProfileJob(std::string serverUrl
+
+ ,
+ std::string userId );
+
+
+ // Result properties
+
+
+
+
+/// The user's avatar URL if they have set one, otherwise not present.
+static std::string avatarUrl(Response r);
+
+
+/// The user's display name if they have set one, otherwise not present.
+static std::string displayname(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string userId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/pusher.cpp b/src/csapi/pusher.cpp
new file mode 100644
index 0000000..0325c10
--- /dev/null
+++ b/src/csapi/pusher.cpp
@@ -0,0 +1,101 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "pusher.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body GetPushersJob::buildBody()
+ {
+ // ignore unused param
+
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetPushersJob::GetPushersJob(
+ std::string serverUrl
+ , std::string _accessToken
+
+ )
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/pushers",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody()
+ )
+ {
+
+
+ }
+
+
+
+ immer::array<GetPushersJob::Pusher> GetPushersJob::pushers(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("pushers"s)) {
+ return
+ jsonBody(r).get()["pushers"s]
+ /*.get<immer::array<Pusher>>()*/;}
+ else { return immer::array<Pusher>( );}
+ }
+
+
+
+ BaseJob::Body PostPusherJob::buildBody(std::string pushkey, std::string kind, std::string appId, std::string appDisplayName, std::string deviceDisplayName, std::string lang, PusherData data, std::string profileTag, std::optional<bool> append)
+ {
+ // ignore unused param
+ (void)(pushkey);(void)(kind);(void)(appId);(void)(appDisplayName);(void)(deviceDisplayName);(void)(lang);(void)(data);(void)(profileTag);(void)(append);
+
+ json _data
+ ;
+
+ _data["pushkey"s] = pushkey;
+
+ _data["kind"s] = kind;
+
+ _data["app_id"s] = appId;
+
+ _data["app_display_name"s] = appDisplayName;
+
+ _data["device_display_name"s] = deviceDisplayName;
+
+
+ addToJsonIfNeeded(_data, "profile_tag"s, profileTag);
+ _data["lang"s] = lang;
+
+ _data["data"s] = data;
+
+
+ addToJsonIfNeeded(_data, "append"s, append);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+PostPusherJob::PostPusherJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string pushkey, std::string kind, std::string appId, std::string appDisplayName, std::string deviceDisplayName, std::string lang, PusherData data, std::string profileTag, std::optional<bool> append)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/pushers/set",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(pushkey, kind, appId, appDisplayName, deviceDisplayName, lang, data, profileTag, append)
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/pusher.hpp b/src/csapi/pusher.hpp
new file mode 100644
index 0000000..75b781a
--- /dev/null
+++ b/src/csapi/pusher.hpp
@@ -0,0 +1,242 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Gets the current pushers for the authenticated user
+ *
+ * Gets all currently active pushers for the authenticated user.
+ */
+class GetPushersJob : public BaseJob {
+public:
+ // Inner data structures
+
+/// A dictionary of information for the pusher implementation
+/// itself.
+ struct PusherData
+ {
+/// Required if ``kind`` is ``http``. The URL to use to send
+/// notifications to.
+ std::string url;
+/// The format to use when sending notifications to the Push
+/// Gateway.
+ std::string format;
+
+ };
+
+/// Gets all currently active pushers for the authenticated user.
+ struct Pusher
+ {
+/// This is a unique identifier for this pusher. See ``/set`` for
+/// more detail.
+/// Max length, 512 bytes.
+ std::string pushkey;
+/// The kind of pusher. ``"http"`` is a pusher that
+/// sends HTTP pokes.
+ std::string kind;
+/// This is a reverse-DNS style identifier for the application.
+/// Max length, 64 chars.
+ std::string appId;
+/// A string that will allow the user to identify what application
+/// owns this pusher.
+ std::string appDisplayName;
+/// A string that will allow the user to identify what device owns
+/// this pusher.
+ std::string deviceDisplayName;
+/// This string determines which set of device specific rules this
+/// pusher executes.
+ std::string profileTag;
+/// The preferred language for receiving notifications (e.g. 'en'
+/// or 'en-US')
+ std::string lang;
+/// A dictionary of information for the pusher implementation
+/// itself.
+ PusherData data;
+
+ };
+
+
+// Construction/destruction
+
+ /// Gets the current pushers for the authenticated user
+ explicit GetPushersJob(std::string serverUrl
+ , std::string _accessToken
+
+ );
+
+
+ // Result properties
+
+
+
+
+/// An array containing the current pushers for the user
+static immer::array<Pusher> pushers(Response r);
+
+
+
+ static BaseJob::Body buildBody();
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+ template<>
+ struct adl_serializer<GetPushersJob::PusherData> {
+
+ static void from_json(const json &jo, GetPushersJob::PusherData& result)
+ {
+
+ result.url = jo.at("url"s);
+ result.format = jo.at("format"s);
+
+ }
+};
+ template<>
+ struct adl_serializer<GetPushersJob::Pusher> {
+
+ static void from_json(const json &jo, GetPushersJob::Pusher& result)
+ {
+
+ result.pushkey = jo.at("pushkey"s);
+ result.kind = jo.at("kind"s);
+ result.appId = jo.at("app_id"s);
+ result.appDisplayName = jo.at("app_display_name"s);
+ result.deviceDisplayName = jo.at("device_display_name"s);
+ result.profileTag = jo.at("profile_tag"s);
+ result.lang = jo.at("lang"s);
+ result.data = jo.at("data"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Modify a pusher for this user on the homeserver.
+ *
+ * This endpoint allows the creation, modification and deletion of `pushers`_
+ * for this user ID. The behaviour of this endpoint varies depending on the
+ * values in the JSON body.
+ */
+class PostPusherJob : public BaseJob {
+public:
+ // Inner data structures
+
+/// A dictionary of information for the pusher implementation
+/// itself. If ``kind`` is ``http``, this should contain ``url``
+/// which is the URL to use to send notifications to.
+ struct PusherData
+ {
+/// Required if ``kind`` is ``http``. The URL to use to send
+/// notifications to. MUST be an HTTPS URL with a path of
+/// ``/_matrix/push/v1/notify``.
+ std::string url;
+/// The format to send notifications in to Push Gateways if the
+/// ``kind`` is ``http``. The details about what fields the
+/// homeserver should send to the push gateway are defined in the
+/// `Push Gateway Specification`_. Currently the only format
+/// available is 'event_id_only'.
+ std::string format;
+
+ };
+
+
+// Construction/destruction
+
+ /*! \brief Modify a pusher for this user on the homeserver.
+ *
+ * \param pushkey
+ * This is a unique identifier for this pusher. The value you
+ * should use for this is the routing or destination address
+ * information for the notification, for example, the APNS token
+ * for APNS or the Registration ID for GCM. If your notification
+ * client has no such concept, use any unique identifier.
+ * Max length, 512 bytes.
+ *
+ * If the ``kind`` is ``"email"``, this is the email address to
+ * send notifications to.
+ *
+ * \param kind
+ * The kind of pusher to configure. ``"http"`` makes a pusher that
+ * sends HTTP pokes. ``"email"`` makes a pusher that emails the
+ * user with unread notifications. ``null`` deletes the pusher.
+ *
+ * \param appId
+ * This is a reverse-DNS style identifier for the application.
+ * It is recommended that this end with the platform, such that
+ * different platform versions get different app identifiers.
+ * Max length, 64 chars.
+ *
+ * If the ``kind`` is ``"email"``, this is ``"m.email"``.
+ *
+ * \param appDisplayName
+ * A string that will allow the user to identify what application
+ * owns this pusher.
+ *
+ * \param deviceDisplayName
+ * A string that will allow the user to identify what device owns
+ * this pusher.
+ *
+ * \param lang
+ * The preferred language for receiving notifications (e.g. 'en'
+ * or 'en-US').
+ *
+ * \param data
+ * A dictionary of information for the pusher implementation
+ * itself. If ``kind`` is ``http``, this should contain ``url``
+ * which is the URL to use to send notifications to.
+ *
+ * \param profileTag
+ * This string determines which set of device specific rules this
+ * pusher executes.
+ *
+ * \param append
+ * If true, the homeserver should add another pusher with the
+ * given pushkey and App ID in addition to any others with
+ * different user IDs. Otherwise, the homeserver must remove any
+ * other pushers with the same App ID and pushkey for different
+ * users. The default is ``false``.
+ */
+ explicit PostPusherJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string pushkey , std::string kind , std::string appId , std::string appDisplayName , std::string deviceDisplayName , std::string lang , PusherData data , std::string profileTag = {}, std::optional<bool> append = std::nullopt);
+
+
+
+
+ static BaseJob::Body buildBody(std::string pushkey, std::string kind, std::string appId, std::string appDisplayName, std::string deviceDisplayName, std::string lang, PusherData data, std::string profileTag, std::optional<bool> append);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+ template<>
+ struct adl_serializer<PostPusherJob::PusherData> {
+ static void to_json(json& jo, const PostPusherJob::PusherData &pod)
+ {
+
+
+
+ addToJsonIfNeeded(jo, "url"s, pod.url);
+
+ addToJsonIfNeeded(jo, "format"s, pod.format);
+ }
+
+};
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/pushrules.cpp b/src/csapi/pushrules.cpp
new file mode 100644
index 0000000..ba594e4
--- /dev/null
+++ b/src/csapi/pushrules.cpp
@@ -0,0 +1,314 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "pushrules.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body GetPushRulesJob::buildBody()
+ {
+ // ignore unused param
+
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetPushRulesJob::GetPushRulesJob(
+ std::string serverUrl
+ , std::string _accessToken
+
+ )
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/pushrules",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody()
+ )
+ {
+
+
+ //addExpectedKey("global");
+ }
+
+
+
+ PushRuleset GetPushRulesJob::global(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("global"s)) {
+ return
+ jsonBody(r).get()["global"s]
+ /*.get<PushRuleset>()*/;}
+ else { return PushRuleset( );}
+ }
+
+
+
+ BaseJob::Body GetPushRuleJob::buildBody(std::string scope, std::string kind, std::string ruleId)
+ {
+ // ignore unused param
+ (void)(scope);(void)(kind);(void)(ruleId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetPushRuleJob::GetPushRuleJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string scope, std::string kind, std::string ruleId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/pushrules/" + scope + "/" + kind + "/" + ruleId,
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(scope, kind, ruleId)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body DeletePushRuleJob::buildBody(std::string scope, std::string kind, std::string ruleId)
+ {
+ // ignore unused param
+ (void)(scope);(void)(kind);(void)(ruleId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+DeletePushRuleJob::DeletePushRuleJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string scope, std::string kind, std::string ruleId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/pushrules/" + scope + "/" + kind + "/" + ruleId,
+ DELETE,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(scope, kind, ruleId)
+ )
+ {
+
+
+ }
+
+
+
+BaseJob::Query SetPushRuleJob::buildQuery(
+std::string before, std::string after)
+{
+BaseJob::Query _q;
+
+ addToQueryIfNeeded(_q, "before"s, before);
+
+ addToQueryIfNeeded(_q, "after"s, after);
+return _q;
+}
+
+ BaseJob::Body SetPushRuleJob::buildBody(std::string scope, std::string kind, std::string ruleId, immer::array<Variant> actions, std::string before, std::string after, immer::array<PushCondition> conditions, std::string pattern)
+ {
+ // ignore unused param
+ (void)(scope);(void)(kind);(void)(ruleId);(void)(actions);(void)(before);(void)(after);(void)(conditions);(void)(pattern);
+
+ json _data
+ ;
+
+ _data["actions"s] = actions;
+
+
+ addToJsonIfNeeded(_data, "conditions"s, conditions);
+
+ addToJsonIfNeeded(_data, "pattern"s, pattern);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+SetPushRuleJob::SetPushRuleJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string scope, std::string kind, std::string ruleId, immer::array<Variant> actions, std::string before, std::string after, immer::array<PushCondition> conditions, std::string pattern)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/pushrules/" + scope + "/" + kind + "/" + ruleId,
+ PUT,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(scope, kind, ruleId, actions, before, after, conditions, pattern)
+ , buildQuery(before, after))
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body IsPushRuleEnabledJob::buildBody(std::string scope, std::string kind, std::string ruleId)
+ {
+ // ignore unused param
+ (void)(scope);(void)(kind);(void)(ruleId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+IsPushRuleEnabledJob::IsPushRuleEnabledJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string scope, std::string kind, std::string ruleId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/pushrules/" + scope + "/" + kind + "/" + ruleId + "/enabled",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(scope, kind, ruleId)
+ )
+ {
+
+
+ //addExpectedKey("enabled");
+ }
+
+
+
+ bool IsPushRuleEnabledJob::enabled(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("enabled"s)) {
+ return
+ jsonBody(r).get()["enabled"s]
+ /*.get<bool>()*/;}
+ else { return bool( );}
+ }
+
+
+
+ BaseJob::Body SetPushRuleEnabledJob::buildBody(std::string scope, std::string kind, std::string ruleId, bool enabled)
+ {
+ // ignore unused param
+ (void)(scope);(void)(kind);(void)(ruleId);(void)(enabled);
+
+ json _data
+ ;
+
+ _data["enabled"s] = enabled;
+
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+SetPushRuleEnabledJob::SetPushRuleEnabledJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string scope, std::string kind, std::string ruleId, bool enabled)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/pushrules/" + scope + "/" + kind + "/" + ruleId + "/enabled",
+ PUT,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(scope, kind, ruleId, enabled)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body GetPushRuleActionsJob::buildBody(std::string scope, std::string kind, std::string ruleId)
+ {
+ // ignore unused param
+ (void)(scope);(void)(kind);(void)(ruleId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetPushRuleActionsJob::GetPushRuleActionsJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string scope, std::string kind, std::string ruleId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/pushrules/" + scope + "/" + kind + "/" + ruleId + "/actions",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(scope, kind, ruleId)
+ )
+ {
+
+
+ //addExpectedKey("actions");
+ }
+
+
+
+ immer::array<Variant> GetPushRuleActionsJob::actions(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("actions"s)) {
+ return
+ jsonBody(r).get()["actions"s]
+ /*.get<immer::array<Variant>>()*/;}
+ else { return immer::array<Variant>( );}
+ }
+
+
+
+ BaseJob::Body SetPushRuleActionsJob::buildBody(std::string scope, std::string kind, std::string ruleId, immer::array<Variant> actions)
+ {
+ // ignore unused param
+ (void)(scope);(void)(kind);(void)(ruleId);(void)(actions);
+
+ json _data
+ ;
+
+ _data["actions"s] = actions;
+
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+SetPushRuleActionsJob::SetPushRuleActionsJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string scope, std::string kind, std::string ruleId, immer::array<Variant> actions)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/pushrules/" + scope + "/" + kind + "/" + ruleId + "/actions",
+ PUT,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(scope, kind, ruleId, actions)
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/pushrules.hpp b/src/csapi/pushrules.hpp
new file mode 100644
index 0000000..50a4c2b
--- /dev/null
+++ b/src/csapi/pushrules.hpp
@@ -0,0 +1,416 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+#include "csapi/definitions/push_condition.hpp"
+#include "csapi/definitions/push_rule.hpp"
+#include "csapi/definitions/push_ruleset.hpp"
+
+namespace Kazv {
+
+/*! \brief Retrieve all push rulesets.
+ *
+ * Retrieve all push rulesets for this user. Clients can "drill-down" on
+ * the rulesets by suffixing a ``scope`` to this path e.g.
+ * ``/pushrules/global/``. This will return a subset of this data under the
+ * specified key e.g. the ``global`` key.
+ */
+class GetPushRulesJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /// Retrieve all push rulesets.
+ explicit GetPushRulesJob(std::string serverUrl
+ , std::string _accessToken
+
+ );
+
+
+ // Result properties
+
+
+
+
+/// The global ruleset.
+static PushRuleset global(Response r);
+
+
+
+ static BaseJob::Body buildBody();
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Retrieve a push rule.
+ *
+ * Retrieve a single specified push rule.
+ */
+class GetPushRuleJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Retrieve a push rule.
+ *
+ * \param scope
+ * ``global`` to specify global rules.
+ *
+ * \param kind
+ * The kind of rule
+ *
+ * \param ruleId
+ * The identifier for the rule.
+ */
+ explicit GetPushRuleJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string scope , std::string kind , std::string ruleId );
+
+
+ // Result properties
+
+
+/// The specific push rule. This will also include keys specific to the
+/// rule itself such as the rule's ``actions`` and ``conditions`` if set.
+ static PushRule data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<PushRule>()
+ ;
+ }
+
+
+
+
+ static BaseJob::Body buildBody(std::string scope, std::string kind, std::string ruleId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Delete a push rule.
+ *
+ * This endpoint removes the push rule defined in the path.
+ */
+class DeletePushRuleJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Delete a push rule.
+ *
+ * \param scope
+ * ``global`` to specify global rules.
+ *
+ * \param kind
+ * The kind of rule
+ *
+ * \param ruleId
+ * The identifier for the rule.
+ */
+ explicit DeletePushRuleJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string scope , std::string kind , std::string ruleId );
+
+
+
+
+ static BaseJob::Body buildBody(std::string scope, std::string kind, std::string ruleId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Add or change a push rule.
+ *
+ * This endpoint allows the creation, modification and deletion of pushers
+ * for this user ID. The behaviour of this endpoint varies depending on the
+ * values in the JSON body.
+ *
+ * When creating push rules, they MUST be enabled by default.
+ */
+class SetPushRuleJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Add or change a push rule.
+ *
+ * \param scope
+ * ``global`` to specify global rules.
+ *
+ * \param kind
+ * The kind of rule
+ *
+ * \param ruleId
+ * The identifier for the rule.
+ *
+ * \param actions
+ * The action(s) to perform when the conditions for this rule are met.
+ *
+ * \param before
+ * Use 'before' with a ``rule_id`` as its value to make the new rule the
+ * next-most important rule with respect to the given user defined rule.
+ * It is not possible to add a rule relative to a predefined server rule.
+ *
+ * \param after
+ * This makes the new rule the next-less important rule relative to the
+ * given user defined rule. It is not possible to add a rule relative
+ * to a predefined server rule.
+ *
+ * \param conditions
+ * The conditions that must hold true for an event in order for a
+ * rule to be applied to an event. A rule with no conditions
+ * always matches. Only applicable to ``underride`` and ``override`` rules.
+ *
+ * \param pattern
+ * Only applicable to ``content`` rules. The glob-style pattern to match against.
+ */
+ explicit SetPushRuleJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string scope , std::string kind , std::string ruleId , immer::array<Variant> actions , std::string before = {}, std::string after = {}, immer::array<PushCondition> conditions = {}, std::string pattern = {});
+
+
+ static BaseJob::Query buildQuery(
+ std::string before, std::string after);
+
+ static BaseJob::Body buildBody(std::string scope, std::string kind, std::string ruleId, immer::array<Variant> actions, std::string before, std::string after, immer::array<PushCondition> conditions, std::string pattern);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Get whether a push rule is enabled
+ *
+ * This endpoint gets whether the specified push rule is enabled.
+ */
+class IsPushRuleEnabledJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Get whether a push rule is enabled
+ *
+ * \param scope
+ * Either ``global`` or ``device/<profile_tag>`` to specify global
+ * rules or device rules for the given ``profile_tag``.
+ *
+ * \param kind
+ * The kind of rule
+ *
+ * \param ruleId
+ * The identifier for the rule.
+ */
+ explicit IsPushRuleEnabledJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string scope , std::string kind , std::string ruleId );
+
+
+ // Result properties
+
+
+
+
+/// Whether the push rule is enabled or not.
+static bool enabled(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string scope, std::string kind, std::string ruleId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Enable or disable a push rule.
+ *
+ * This endpoint allows clients to enable or disable the specified push rule.
+ */
+class SetPushRuleEnabledJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Enable or disable a push rule.
+ *
+ * \param scope
+ * ``global`` to specify global rules.
+ *
+ * \param kind
+ * The kind of rule
+ *
+ * \param ruleId
+ * The identifier for the rule.
+ *
+ * \param enabled
+ * Whether the push rule is enabled or not.
+ */
+ explicit SetPushRuleEnabledJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string scope , std::string kind , std::string ruleId , bool enabled );
+
+
+
+
+ static BaseJob::Body buildBody(std::string scope, std::string kind, std::string ruleId, bool enabled);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief The actions for a push rule
+ *
+ * This endpoint get the actions for the specified push rule.
+ */
+class GetPushRuleActionsJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief The actions for a push rule
+ *
+ * \param scope
+ * Either ``global`` or ``device/<profile_tag>`` to specify global
+ * rules or device rules for the given ``profile_tag``.
+ *
+ * \param kind
+ * The kind of rule
+ *
+ * \param ruleId
+ * The identifier for the rule.
+ */
+ explicit GetPushRuleActionsJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string scope , std::string kind , std::string ruleId );
+
+
+ // Result properties
+
+
+
+
+/// The action(s) to perform for this rule.
+static immer::array<Variant> actions(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string scope, std::string kind, std::string ruleId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Set the actions for a push rule.
+ *
+ * This endpoint allows clients to change the actions of a push rule.
+ * This can be used to change the actions of builtin rules.
+ */
+class SetPushRuleActionsJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Set the actions for a push rule.
+ *
+ * \param scope
+ * ``global`` to specify global rules.
+ *
+ * \param kind
+ * The kind of rule
+ *
+ * \param ruleId
+ * The identifier for the rule.
+ *
+ * \param actions
+ * The action(s) to perform for this rule.
+ */
+ explicit SetPushRuleActionsJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string scope , std::string kind , std::string ruleId , immer::array<Variant> actions );
+
+
+
+
+ static BaseJob::Body buildBody(std::string scope, std::string kind, std::string ruleId, immer::array<Variant> actions);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/read_markers.cpp b/src/csapi/read_markers.cpp
new file mode 100644
index 0000000..1aef844
--- /dev/null
+++ b/src/csapi/read_markers.cpp
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "read_markers.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body SetReadMarkerJob::buildBody(std::string roomId, std::string mFullyRead, std::string mRead)
+ {
+ // ignore unused param
+ (void)(roomId);(void)(mFullyRead);(void)(mRead);
+
+ json _data
+ ;
+
+ _data["m.fully_read"s] = mFullyRead;
+
+
+ addToJsonIfNeeded(_data, "m.read"s, mRead);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+SetReadMarkerJob::SetReadMarkerJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId, std::string mFullyRead, std::string mRead)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/read_markers",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId, mFullyRead, mRead)
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/read_markers.hpp b/src/csapi/read_markers.hpp
new file mode 100644
index 0000000..14270ad
--- /dev/null
+++ b/src/csapi/read_markers.hpp
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Set the position of the read marker for a room.
+ *
+ * Sets the position of the read marker for a given room, and optionally
+ * the read receipt's location.
+ */
+class SetReadMarkerJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Set the position of the read marker for a room.
+ *
+ * \param roomId
+ * The room ID to set the read marker in for the user.
+ *
+ * \param mFullyRead
+ * The event ID the read marker should be located at. The
+ * event MUST belong to the room.
+ *
+ * \param mRead
+ * The event ID to set the read receipt location at. This is
+ * equivalent to calling ``/receipt/m.read/$elsewhere:example.org``
+ * and is provided here to save that extra call.
+ */
+ explicit SetReadMarkerJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId , std::string mFullyRead , std::string mRead = {});
+
+
+
+
+ static BaseJob::Body buildBody(std::string roomId, std::string mFullyRead, std::string mRead);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/receipts.cpp b/src/csapi/receipts.cpp
new file mode 100644
index 0000000..8b5a644
--- /dev/null
+++ b/src/csapi/receipts.cpp
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "receipts.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body PostReceiptJob::buildBody(std::string roomId, std::string receiptType, std::string eventId, JsonWrap receipt)
+ {
+ // ignore unused param
+ (void)(roomId);(void)(receiptType);(void)(eventId);(void)(receipt);
+ return
+ BaseJob::JsonBody(receipt);
+
+
+
+ };
+
+PostReceiptJob::PostReceiptJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId, std::string receiptType, std::string eventId, JsonWrap receipt)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/receipt/" + receiptType + "/" + eventId,
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId, receiptType, eventId, receipt)
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/receipts.hpp b/src/csapi/receipts.hpp
new file mode 100644
index 0000000..d033a56
--- /dev/null
+++ b/src/csapi/receipts.hpp
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Send a receipt for the given event ID.
+ *
+ * This API updates the marker for the given receipt type to the event ID
+ * specified.
+ */
+class PostReceiptJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Send a receipt for the given event ID.
+ *
+ * \param roomId
+ * The room in which to send the event.
+ *
+ * \param receiptType
+ * The type of receipt to send.
+ *
+ * \param eventId
+ * The event ID to acknowledge up to.
+ *
+ * \param receipt
+ * Extra receipt information to attach to ``content`` if any. The
+ * server will automatically set the ``ts`` field.
+ */
+ explicit PostReceiptJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId , std::string receiptType , std::string eventId , JsonWrap receipt = {});
+
+
+
+
+ static BaseJob::Body buildBody(std::string roomId, std::string receiptType, std::string eventId, JsonWrap receipt);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/redaction.cpp b/src/csapi/redaction.cpp
new file mode 100644
index 0000000..836ae0f
--- /dev/null
+++ b/src/csapi/redaction.cpp
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "redaction.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body RedactEventJob::buildBody(std::string roomId, std::string eventId, std::string txnId, std::string reason)
+ {
+ // ignore unused param
+ (void)(roomId);(void)(eventId);(void)(txnId);(void)(reason);
+
+ json _data
+ ;
+
+
+ addToJsonIfNeeded(_data, "reason"s, reason);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+RedactEventJob::RedactEventJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId, std::string eventId, std::string txnId, std::string reason)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/redact/" + eventId + "/" + txnId,
+ PUT,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId, eventId, txnId, reason)
+ )
+ {
+
+
+ }
+
+
+
+ std::string RedactEventJob::eventId(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("event_id"s)) {
+ return
+ jsonBody(r).get()["event_id"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+}
diff --git a/src/csapi/redaction.hpp b/src/csapi/redaction.hpp
new file mode 100644
index 0000000..f4cf7c0
--- /dev/null
+++ b/src/csapi/redaction.hpp
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Strips all non-integrity-critical information out of an event.
+ *
+ * Strips all information out of an event which isn't critical to the
+ * integrity of the server-side representation of the room.
+ *
+ * This cannot be undone.
+ *
+ * Users may redact their own events, and any user with a power level
+ * greater than or equal to the ``redact`` power level of the room may
+ * redact events there.
+ */
+class RedactEventJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Strips all non-integrity-critical information out of an event.
+ *
+ * \param roomId
+ * The room from which to redact the event.
+ *
+ * \param eventId
+ * The ID of the event to redact
+ *
+ * \param txnId
+ * The transaction ID for this event. Clients should generate a
+ * unique ID; it will be used by the server to ensure idempotency of requests.
+ *
+ * \param reason
+ * The reason for the event being redacted.
+ */
+ explicit RedactEventJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId , std::string eventId , std::string txnId , std::string reason = {});
+
+
+ // Result properties
+
+
+
+
+/// A unique identifier for the event.
+static std::string eventId(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string roomId, std::string eventId, std::string txnId, std::string reason);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/registration.cpp b/src/csapi/registration.cpp
new file mode 100644
index 0000000..b18cf5f
--- /dev/null
+++ b/src/csapi/registration.cpp
@@ -0,0 +1,368 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "registration.hpp"
+
+namespace Kazv
+{
+
+BaseJob::Query RegisterJob::buildQuery(
+std::string kind)
+{
+BaseJob::Query _q;
+
+ addToQueryIfNeeded(_q, "kind"s, kind);
+return _q;
+}
+
+ BaseJob::Body RegisterJob::buildBody(std::string kind, std::optional<AuthenticationData> auth, std::string username, std::string password, std::string deviceId, std::string initialDeviceDisplayName, std::optional<bool> inhibitLogin)
+ {
+ // ignore unused param
+ (void)(kind);(void)(auth);(void)(username);(void)(password);(void)(deviceId);(void)(initialDeviceDisplayName);(void)(inhibitLogin);
+
+ json _data
+ ;
+
+
+ addToJsonIfNeeded(_data, "auth"s, auth);
+
+ addToJsonIfNeeded(_data, "username"s, username);
+
+ addToJsonIfNeeded(_data, "password"s, password);
+
+ addToJsonIfNeeded(_data, "device_id"s, deviceId);
+
+ addToJsonIfNeeded(_data, "initial_device_display_name"s, initialDeviceDisplayName);
+
+ addToJsonIfNeeded(_data, "inhibit_login"s, inhibitLogin);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+RegisterJob::RegisterJob(
+ std::string serverUrl
+
+ ,
+ std::string kind, std::optional<AuthenticationData> auth, std::string username, std::string password, std::string deviceId, std::string initialDeviceDisplayName, std::optional<bool> inhibitLogin)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/register",
+ POST,
+ {} ,
+ ReturnType::Json,
+ buildBody(kind, auth, username, password, deviceId, initialDeviceDisplayName, inhibitLogin)
+ , buildQuery(kind))
+ {
+
+
+ //addExpectedKey("user_id");
+ }
+
+
+
+ std::string RegisterJob::userId(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("user_id"s)) {
+ return
+ jsonBody(r).get()["user_id"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ std::string RegisterJob::accessToken(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("access_token"s)) {
+ return
+ jsonBody(r).get()["access_token"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ std::string RegisterJob::homeServer(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("home_server"s)) {
+ return
+ jsonBody(r).get()["home_server"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ std::string RegisterJob::deviceId(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("device_id"s)) {
+ return
+ jsonBody(r).get()["device_id"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+
+ BaseJob::Body RequestTokenToRegisterEmailJob::buildBody(EmailValidationData body)
+ {
+ // ignore unused param
+ (void)(body);
+ return
+ BaseJob::JsonBody(body);
+
+
+
+ };
+
+RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob(
+ std::string serverUrl
+
+ ,
+ EmailValidationData body)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/register/email/requestToken",
+ POST,
+ {} ,
+ ReturnType::Json,
+ buildBody(body)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body RequestTokenToRegisterMSISDNJob::buildBody(MsisdnValidationData body)
+ {
+ // ignore unused param
+ (void)(body);
+ return
+ BaseJob::JsonBody(body);
+
+
+
+ };
+
+RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob(
+ std::string serverUrl
+
+ ,
+ MsisdnValidationData body)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/register/msisdn/requestToken",
+ POST,
+ {} ,
+ ReturnType::Json,
+ buildBody(body)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body ChangePasswordJob::buildBody(std::string newPassword, std::optional<bool> logoutDevices, std::optional<AuthenticationData> auth)
+ {
+ // ignore unused param
+ (void)(newPassword);(void)(logoutDevices);(void)(auth);
+
+ json _data
+ ;
+
+ _data["new_password"s] = newPassword;
+
+
+ addToJsonIfNeeded(_data, "logout_devices"s, logoutDevices);
+
+ addToJsonIfNeeded(_data, "auth"s, auth);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+ChangePasswordJob::ChangePasswordJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string newPassword, std::optional<bool> logoutDevices, std::optional<AuthenticationData> auth)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/account/password",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(newPassword, logoutDevices, auth)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body RequestTokenToResetPasswordEmailJob::buildBody(EmailValidationData body)
+ {
+ // ignore unused param
+ (void)(body);
+ return
+ BaseJob::JsonBody(body);
+
+
+
+ };
+
+RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob(
+ std::string serverUrl
+
+ ,
+ EmailValidationData body)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/account/password/email/requestToken",
+ POST,
+ {} ,
+ ReturnType::Json,
+ buildBody(body)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body RequestTokenToResetPasswordMSISDNJob::buildBody(MsisdnValidationData body)
+ {
+ // ignore unused param
+ (void)(body);
+ return
+ BaseJob::JsonBody(body);
+
+
+
+ };
+
+RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob(
+ std::string serverUrl
+
+ ,
+ MsisdnValidationData body)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/account/password/msisdn/requestToken",
+ POST,
+ {} ,
+ ReturnType::Json,
+ buildBody(body)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body DeactivateAccountJob::buildBody(std::optional<AuthenticationData> auth, std::string idServer)
+ {
+ // ignore unused param
+ (void)(auth);(void)(idServer);
+
+ json _data
+ ;
+
+
+ addToJsonIfNeeded(_data, "auth"s, auth);
+
+ addToJsonIfNeeded(_data, "id_server"s, idServer);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+DeactivateAccountJob::DeactivateAccountJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::optional<AuthenticationData> auth, std::string idServer)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/account/deactivate",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(auth, idServer)
+ )
+ {
+
+
+ //addExpectedKey("id_server_unbind_result");
+ }
+
+
+
+ std::string DeactivateAccountJob::idServerUnbindResult(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("id_server_unbind_result"s)) {
+ return
+ jsonBody(r).get()["id_server_unbind_result"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+BaseJob::Query CheckUsernameAvailabilityJob::buildQuery(
+std::string username)
+{
+BaseJob::Query _q;
+ addToQuery(_q, "username"s, username);
+
+return _q;
+}
+
+ BaseJob::Body CheckUsernameAvailabilityJob::buildBody(std::string username)
+ {
+ // ignore unused param
+ (void)(username);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+CheckUsernameAvailabilityJob::CheckUsernameAvailabilityJob(
+ std::string serverUrl
+
+ ,
+ std::string username)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/register/available",
+ GET,
+ {} ,
+ ReturnType::Json,
+ buildBody(username)
+ , buildQuery(username))
+ {
+
+
+ }
+
+
+
+ std::optional<bool> CheckUsernameAvailabilityJob::available(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("available"s)) {
+ return
+ jsonBody(r).get()["available"s]
+ /*.get<bool>()*/;}
+ else { return std::optional<bool>( );}
+ }
+
+}
diff --git a/src/csapi/registration.hpp b/src/csapi/registration.hpp
new file mode 100644
index 0000000..cbd2713
--- /dev/null
+++ b/src/csapi/registration.hpp
@@ -0,0 +1,619 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+#include "csapi/definitions/request_msisdn_validation.hpp"
+#include "csapi/definitions/request_token_response.hpp"
+#include "csapi/definitions/request_email_validation.hpp"
+#include "csapi/definitions/auth_data.hpp"
+
+namespace Kazv {
+
+/*! \brief Register for an account on this homeserver.
+ *
+ * This API endpoint uses the `User-Interactive Authentication API`_, except in
+ * the cases where a guest account is being registered.
+ *
+ * Register for an account on this homeserver.
+ *
+ * There are two kinds of user account:
+ *
+ * - `user` accounts. These accounts may use the full API described in this specification.
+ *
+ * - `guest` accounts. These accounts may have limited permissions and may not be supported by all servers.
+ *
+ * If registration is successful, this endpoint will issue an access token
+ * the client can use to authorize itself in subsequent requests.
+ *
+ * If the client does not supply a ``device_id``, the server must
+ * auto-generate one.
+ *
+ * The server SHOULD register an account with a User ID based on the
+ * ``username`` provided, if any. Note that the grammar of Matrix User ID
+ * localparts is restricted, so the server MUST either map the provided
+ * ``username`` onto a ``user_id`` in a logical manner, or reject
+ * ``username``\s which do not comply to the grammar, with
+ * ``M_INVALID_USERNAME``.
+ *
+ * Matrix clients MUST NOT assume that localpart of the registered
+ * ``user_id`` matches the provided ``username``.
+ *
+ * The returned access token must be associated with the ``device_id``
+ * supplied by the client or generated by the server. The server may
+ * invalidate any access token previously associated with that device. See
+ * `Relationship between access tokens and devices`_.
+ *
+ * When registering a guest account, all parameters in the request body
+ * with the exception of ``initial_device_display_name`` MUST BE ignored
+ * by the server. The server MUST pick a ``device_id`` for the account
+ * regardless of input.
+ *
+ * Any user ID returned by this API must conform to the grammar given in the
+ * `Matrix specification <../appendices.html#user-identifiers>`_.
+ */
+class RegisterJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Register for an account on this homeserver.
+ *
+ * \param kind
+ * The kind of account to register. Defaults to ``user``.
+ *
+ * \param auth
+ * Additional authentication information for the
+ * user-interactive authentication API. Note that this
+ * information is *not* used to define how the registered user
+ * should be authenticated, but is instead used to
+ * authenticate the ``register`` call itself.
+ *
+ * \param username
+ * The basis for the localpart of the desired Matrix ID. If omitted,
+ * the homeserver MUST generate a Matrix ID local part.
+ *
+ * \param password
+ * The desired password for the account.
+ *
+ * \param deviceId
+ * ID of the client device. If this does not correspond to a
+ * known client device, a new device will be created. The server
+ * will auto-generate a device_id if this is not specified.
+ *
+ * \param initialDeviceDisplayName
+ * A display name to assign to the newly-created device. Ignored
+ * if ``device_id`` corresponds to a known device.
+ *
+ * \param inhibitLogin
+ * If true, an ``access_token`` and ``device_id`` should not be
+ * returned from this call, therefore preventing an automatic
+ * login. Defaults to false.
+ */
+ explicit RegisterJob(std::string serverUrl
+
+ ,
+ std::string kind = std::string("user"), std::optional<AuthenticationData> auth = std::nullopt, std::string username = {}, std::string password = {}, std::string deviceId = {}, std::string initialDeviceDisplayName = {}, std::optional<bool> inhibitLogin = std::nullopt);
+
+
+ // Result properties
+
+
+
+
+/// The fully-qualified Matrix user ID (MXID) that has been registered.
+///
+/// Any user ID returned by this API must conform to the grammar given in the
+/// `Matrix specification <../appendices.html#user-identifiers>`_.
+static std::string userId(Response r);
+
+
+/// An access token for the account.
+/// This access token can then be used to authorize other requests.
+/// Required if the ``inhibit_login`` option is false.
+static std::string accessToken(Response r);
+
+
+/// The server_name of the homeserver on which the account has
+/// been registered.
+///
+/// **Deprecated**. Clients should extract the server_name from
+/// ``user_id`` (by splitting at the first colon) if they require
+/// it. Note also that ``homeserver`` is not spelt this way.
+static std::string homeServer(Response r);
+
+
+/// ID of the registered device. Will be the same as the
+/// corresponding parameter in the request, if one was specified.
+/// Required if the ``inhibit_login`` option is false.
+static std::string deviceId(Response r);
+
+ static BaseJob::Query buildQuery(
+ std::string kind);
+
+ static BaseJob::Body buildBody(std::string kind, std::optional<AuthenticationData> auth, std::string username, std::string password, std::string deviceId, std::string initialDeviceDisplayName, std::optional<bool> inhibitLogin);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Begins the validation process for an email to be used during registration.
+ *
+ * The homeserver must check that the given email address is **not**
+ * already associated with an account on this homeserver. The homeserver
+ * should validate the email itself, either by sending a validation email
+ * itself or by using a service it has control over.
+ */
+class RequestTokenToRegisterEmailJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Begins the validation process for an email to be used during registration.
+ *
+ * \param body
+ * The homeserver must check that the given email address is **not**
+ * already associated with an account on this homeserver. The homeserver
+ * should validate the email itself, either by sending a validation email
+ * itself or by using a service it has control over.
+ */
+ explicit RequestTokenToRegisterEmailJob(std::string serverUrl
+
+ ,
+ EmailValidationData body );
+
+
+ // Result properties
+
+
+/// An email has been sent to the specified address. Note that this
+/// may be an email containing the validation token or it may be
+/// informing the user of an error.
+ static RequestTokenResponse data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<RequestTokenResponse>()
+ ;
+ }
+
+
+
+
+ static BaseJob::Body buildBody(EmailValidationData body);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Requests a validation token be sent to the given phone number for the purpose of registering an account
+ *
+ * The homeserver must check that the given phone number is **not**
+ * already associated with an account on this homeserver. The homeserver
+ * should validate the phone number itself, either by sending a validation
+ * message itself or by using a service it has control over.
+ */
+class RequestTokenToRegisterMSISDNJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Requests a validation token be sent to the given phone number for the purpose of registering an account
+ *
+ * \param body
+ * The homeserver must check that the given phone number is **not**
+ * already associated with an account on this homeserver. The homeserver
+ * should validate the phone number itself, either by sending a validation
+ * message itself or by using a service it has control over.
+ */
+ explicit RequestTokenToRegisterMSISDNJob(std::string serverUrl
+
+ ,
+ MsisdnValidationData body );
+
+
+ // Result properties
+
+
+/// An SMS message has been sent to the specified phone number. Note
+/// that this may be an SMS message containing the validation token or
+/// it may be informing the user of an error.
+ static RequestTokenResponse data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<RequestTokenResponse>()
+ ;
+ }
+
+
+
+
+ static BaseJob::Body buildBody(MsisdnValidationData body);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Changes a user's password.
+ *
+ * Changes the password for an account on this homeserver.
+ *
+ * This API endpoint uses the `User-Interactive Authentication API`_ to
+ * ensure the user changing the password is actually the owner of the
+ * account.
+ *
+ * An access token should be submitted to this endpoint if the client has
+ * an active session.
+ *
+ * The homeserver may change the flows available depending on whether a
+ * valid access token is provided. The homeserver SHOULD NOT revoke the
+ * access token provided in the request. Whether other access tokens for
+ * the user are revoked depends on the request parameters.
+ */
+class ChangePasswordJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Changes a user's password.
+ *
+ * \param newPassword
+ * The new password for the account.
+ *
+ * \param logoutDevices
+ * Whether the user's other access tokens, and their associated devices, should be
+ * revoked if the request succeeds. Defaults to true.
+ *
+ * When ``false``, the server can still take advantage of `the soft logout method <#soft-logout>`_
+ * for the user's remaining devices.
+ *
+ * \param auth
+ * Additional authentication information for the user-interactive authentication API.
+ */
+ explicit ChangePasswordJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string newPassword , std::optional<bool> logoutDevices = std::nullopt, std::optional<AuthenticationData> auth = std::nullopt);
+
+
+
+
+ static BaseJob::Body buildBody(std::string newPassword, std::optional<bool> logoutDevices, std::optional<AuthenticationData> auth);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Requests a validation token be sent to the given email address for the purpose of resetting a user's password
+ *
+ * The homeserver must check that the given email address **is
+ * associated** with an account on this homeserver. This API should be
+ * used to request validation tokens when authenticating for the
+ * ``/account/password`` endpoint.
+ *
+ * This API's parameters and response are identical to that of the
+ * |/register/email/requestToken|_ endpoint, except that
+ * ``M_THREEPID_NOT_FOUND`` may be returned if no account matching the
+ * given email address could be found. The server may instead send an
+ * email to the given address prompting the user to create an account.
+ * ``M_THREEPID_IN_USE`` may not be returned.
+ *
+ * The homeserver should validate the email itself, either by sending a
+ * validation email itself or by using a service it has control over.
+ *
+ *
+ * .. |/register/email/requestToken| replace:: ``/register/email/requestToken``
+ *
+ * .. _/register/email/requestToken: #post-matrix-client-r0-register-email-requesttoken
+ */
+class RequestTokenToResetPasswordEmailJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Requests a validation token be sent to the given email address for the purpose of resetting a user's password
+ *
+ * \param body
+ * The homeserver must check that the given email address **is
+ * associated** with an account on this homeserver. This API should be
+ * used to request validation tokens when authenticating for the
+ * ``/account/password`` endpoint.
+ *
+ * This API's parameters and response are identical to that of the
+ * |/register/email/requestToken|_ endpoint, except that
+ * ``M_THREEPID_NOT_FOUND`` may be returned if no account matching the
+ * given email address could be found. The server may instead send an
+ * email to the given address prompting the user to create an account.
+ * ``M_THREEPID_IN_USE`` may not be returned.
+ *
+ * The homeserver should validate the email itself, either by sending a
+ * validation email itself or by using a service it has control over.
+ *
+ *
+ * .. |/register/email/requestToken| replace:: ``/register/email/requestToken``
+ *
+ * .. _/register/email/requestToken: #post-matrix-client-r0-register-email-requesttoken
+ */
+ explicit RequestTokenToResetPasswordEmailJob(std::string serverUrl
+
+ ,
+ EmailValidationData body );
+
+
+ // Result properties
+
+
+/// An email was sent to the given address.
+ static RequestTokenResponse data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<RequestTokenResponse>()
+ ;
+ }
+
+
+
+
+ static BaseJob::Body buildBody(EmailValidationData body);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Requests a validation token be sent to the given phone number for the purpose of resetting a user's password.
+ *
+ * The homeserver must check that the given phone number **is
+ * associated** with an account on this homeserver. This API should be
+ * used to request validation tokens when authenticating for the
+ * ``/account/password`` endpoint.
+ *
+ * This API's parameters and response are identical to that of the
+ * |/register/msisdn/requestToken|_ endpoint, except that
+ * ``M_THREEPID_NOT_FOUND`` may be returned if no account matching the
+ * given phone number could be found. The server may instead send the SMS
+ * to the given phone number prompting the user to create an account.
+ * ``M_THREEPID_IN_USE`` may not be returned.
+ *
+ * The homeserver should validate the phone number itself, either by sending a
+ * validation message itself or by using a service it has control over.
+ *
+ * .. |/register/msisdn/requestToken| replace:: ``/register/msisdn/requestToken``
+ *
+ * .. _/register/msisdn/requestToken: #post-matrix-client-r0-register-email-requesttoken
+ */
+class RequestTokenToResetPasswordMSISDNJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Requests a validation token be sent to the given phone number for the purpose of resetting a user's password.
+ *
+ * \param body
+ * The homeserver must check that the given phone number **is
+ * associated** with an account on this homeserver. This API should be
+ * used to request validation tokens when authenticating for the
+ * ``/account/password`` endpoint.
+ *
+ * This API's parameters and response are identical to that of the
+ * |/register/msisdn/requestToken|_ endpoint, except that
+ * ``M_THREEPID_NOT_FOUND`` may be returned if no account matching the
+ * given phone number could be found. The server may instead send the SMS
+ * to the given phone number prompting the user to create an account.
+ * ``M_THREEPID_IN_USE`` may not be returned.
+ *
+ * The homeserver should validate the phone number itself, either by sending a
+ * validation message itself or by using a service it has control over.
+ *
+ * .. |/register/msisdn/requestToken| replace:: ``/register/msisdn/requestToken``
+ *
+ * .. _/register/msisdn/requestToken: #post-matrix-client-r0-register-email-requesttoken
+ */
+ explicit RequestTokenToResetPasswordMSISDNJob(std::string serverUrl
+
+ ,
+ MsisdnValidationData body );
+
+
+ // Result properties
+
+
+/// An SMS message was sent to the given phone number.
+ static RequestTokenResponse data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<RequestTokenResponse>()
+ ;
+ }
+
+
+
+
+ static BaseJob::Body buildBody(MsisdnValidationData body);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Deactivate a user's account.
+ *
+ * Deactivate the user's account, removing all ability for the user to
+ * login again.
+ *
+ * This API endpoint uses the `User-Interactive Authentication API`_.
+ *
+ * An access token should be submitted to this endpoint if the client has
+ * an active session.
+ *
+ * The homeserver may change the flows available depending on whether a
+ * valid access token is provided.
+ *
+ * Unlike other endpoints, this endpoint does not take an ``id_access_token``
+ * parameter because the homeserver is expected to sign the request to the
+ * identity server instead.
+ */
+class DeactivateAccountJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Deactivate a user's account.
+ *
+ * \param auth
+ * Additional authentication information for the user-interactive authentication API.
+ *
+ * \param idServer
+ * The identity server to unbind all of the user's 3PIDs from.
+ * If not provided, the homeserver MUST use the ``id_server``
+ * that was originally use to bind each identifier. If the
+ * homeserver does not know which ``id_server`` that was,
+ * it must return an ``id_server_unbind_result`` of
+ * ``no-support``.
+ */
+ explicit DeactivateAccountJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::optional<AuthenticationData> auth = std::nullopt, std::string idServer = {});
+
+
+ // Result properties
+
+
+
+
+/// An indicator as to whether or not the homeserver was able to unbind
+/// the user's 3PIDs from the identity server(s). ``success`` indicates
+/// that all identifiers have been unbound from the identity server while
+/// ``no-support`` indicates that one or more identifiers failed to unbind
+/// due to the identity server refusing the request or the homeserver
+/// being unable to determine an identity server to unbind from. This
+/// must be ``success`` if the homeserver has no identifiers to unbind
+/// for the user.
+static std::string idServerUnbindResult(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::optional<AuthenticationData> auth, std::string idServer);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Checks to see if a username is available on the server.
+ *
+ * Checks to see if a username is available, and valid, for the server.
+ *
+ * The server should check to ensure that, at the time of the request, the
+ * username requested is available for use. This includes verifying that an
+ * application service has not claimed the username and that the username
+ * fits the server's desired requirements (for example, a server could dictate
+ * that it does not permit usernames with underscores).
+ *
+ * Matrix clients may wish to use this API prior to attempting registration,
+ * however the clients must also be aware that using this API does not normally
+ * reserve the username. This can mean that the username becomes unavailable
+ * between checking its availability and attempting to register it.
+ */
+class CheckUsernameAvailabilityJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Checks to see if a username is available on the server.
+ *
+ * \param username
+ * The username to check the availability of.
+ */
+ explicit CheckUsernameAvailabilityJob(std::string serverUrl
+
+ ,
+ std::string username );
+
+
+ // Result properties
+
+
+
+
+/// A flag to indicate that the username is available. This should always
+/// be ``true`` when the server replies with 200 OK.
+static std::optional<bool> available(Response r);
+
+ static BaseJob::Query buildQuery(
+ std::string username);
+
+ static BaseJob::Body buildBody(std::string username);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/report_content.cpp b/src/csapi/report_content.cpp
new file mode 100644
index 0000000..2c38d08
--- /dev/null
+++ b/src/csapi/report_content.cpp
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "report_content.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body ReportContentJob::buildBody(std::string roomId, std::string eventId, int score, std::string reason)
+ {
+ // ignore unused param
+ (void)(roomId);(void)(eventId);(void)(score);(void)(reason);
+
+ json _data
+ ;
+
+ _data["score"s] = score;
+
+ _data["reason"s] = reason;
+
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+ReportContentJob::ReportContentJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId, std::string eventId, int score, std::string reason)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/report/" + eventId,
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId, eventId, score, reason)
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/report_content.hpp b/src/csapi/report_content.hpp
new file mode 100644
index 0000000..9b2b172
--- /dev/null
+++ b/src/csapi/report_content.hpp
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Reports an event as inappropriate.
+ *
+ * Reports an event as inappropriate to the server, which may then notify
+ * the appropriate people.
+ */
+class ReportContentJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Reports an event as inappropriate.
+ *
+ * \param roomId
+ * The room in which the event being reported is located.
+ *
+ * \param eventId
+ * The event to report.
+ *
+ * \param score
+ * The score to rate this content as where -100 is most offensive
+ * and 0 is inoffensive.
+ *
+ * \param reason
+ * The reason the content is being reported. May be blank.
+ */
+ explicit ReportContentJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId , std::string eventId , int score , std::string reason );
+
+
+
+
+ static BaseJob::Body buildBody(std::string roomId, std::string eventId, int score, std::string reason);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/room_initial_sync.cpp b/src/csapi/room_initial_sync.cpp
new file mode 100644
index 0000000..b22ccdf
--- /dev/null
+++ b/src/csapi/room_initial_sync.cpp
@@ -0,0 +1,106 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "room_initial_sync.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body RoomInitialSyncJob::buildBody(std::string roomId)
+ {
+ // ignore unused param
+ (void)(roomId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+RoomInitialSyncJob::RoomInitialSyncJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/initialSync",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId)
+ )
+ {
+
+
+ //addExpectedKey("room_id");
+ }
+
+
+
+ std::string RoomInitialSyncJob::roomId(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("room_id"s)) {
+ return
+ jsonBody(r).get()["room_id"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ std::string RoomInitialSyncJob::membership(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("membership"s)) {
+ return
+ jsonBody(r).get()["membership"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ std::optional<RoomInitialSyncJob::PaginationChunk> RoomInitialSyncJob::messages(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("messages"s)) {
+ return
+ jsonBody(r).get()["messages"s]
+ /*.get<PaginationChunk>()*/;}
+ else { return std::optional<PaginationChunk>( );}
+ }
+
+
+ EventList RoomInitialSyncJob::state(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("state"s)) {
+ return
+ jsonBody(r).get()["state"s]
+ /*.get<EventList>()*/;}
+ else { return EventList( );}
+ }
+
+
+ std::string RoomInitialSyncJob::visibility(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("visibility"s)) {
+ return
+ jsonBody(r).get()["visibility"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ EventList RoomInitialSyncJob::accountData(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("account_data"s)) {
+ return
+ jsonBody(r).get()["account_data"s]
+ /*.get<EventList>()*/;}
+ else { return EventList( );}
+ }
+
+}
diff --git a/src/csapi/room_initial_sync.hpp b/src/csapi/room_initial_sync.hpp
new file mode 100644
index 0000000..44738f2
--- /dev/null
+++ b/src/csapi/room_initial_sync.hpp
@@ -0,0 +1,115 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Snapshot the current state of a room and its most recent messages.
+ *
+ * Get a copy of the current state and the most recent messages in a room.
+ *
+ * This endpoint was deprecated in r0 of this specification. There is no
+ * direct replacement; the relevant information is returned by the
+ * |/sync|_ API. See the `migration guide
+ * <https://matrix.org/docs/guides/client-server-migrating-from-v1.html#deprecated-endpoints>`_.
+ */
+class RoomInitialSyncJob : public BaseJob {
+public:
+ // Inner data structures
+
+/// The pagination chunk for this room.
+ struct PaginationChunk
+ {
+/// A token which correlates to the first value in ``chunk``.
+/// Used for pagination.
+ std::string start;
+/// A token which correlates to the last value in ``chunk``.
+/// Used for pagination.
+ std::string end;
+/// If the user is a member of the room this will be a
+/// list of the most recent messages for this room. If
+/// the user has left the room this will be the
+/// messages that preceeded them leaving. This array
+/// will consist of at most ``limit`` elements.
+ EventList chunk;
+
+ };
+
+
+// Construction/destruction
+
+ /*! \brief Snapshot the current state of a room and its most recent messages.
+ *
+ * \param roomId
+ * The room to get the data.
+ */
+ explicit RoomInitialSyncJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId );
+
+
+ // Result properties
+
+
+
+
+/// The ID of this room.
+static std::string roomId(Response r);
+
+
+/// The user's membership state in this room.
+static std::string membership(Response r);
+
+
+/// The pagination chunk for this room.
+static std::optional<PaginationChunk> messages(Response r);
+
+
+/// If the user is a member of the room this will be the
+/// current state of the room as a list of events. If the
+/// user has left the room this will be the state of the
+/// room when they left it.
+static EventList state(Response r);
+
+
+/// Whether this room is visible to the ``/publicRooms`` API
+/// or not."
+static std::string visibility(Response r);
+
+
+/// The private data that this user has attached to this room.
+static EventList accountData(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string roomId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+ template<>
+ struct adl_serializer<RoomInitialSyncJob::PaginationChunk> {
+
+ static void from_json(const json &jo, RoomInitialSyncJob::PaginationChunk& result)
+ {
+
+ result.start = jo.at("start"s);
+ result.end = jo.at("end"s);
+ result.chunk = jo.at("chunk"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/room_send.cpp b/src/csapi/room_send.cpp
new file mode 100644
index 0000000..df3a759
--- /dev/null
+++ b/src/csapi/room_send.cpp
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "room_send.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body SendMessageJob::buildBody(std::string roomId, std::string eventType, std::string txnId, JsonWrap body)
+ {
+ // ignore unused param
+ (void)(roomId);(void)(eventType);(void)(txnId);(void)(body);
+ return
+ BaseJob::JsonBody(body);
+
+
+
+ };
+
+SendMessageJob::SendMessageJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId, std::string eventType, std::string txnId, JsonWrap body)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/send/" + eventType + "/" + txnId,
+ PUT,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId, eventType, txnId, body)
+ )
+ {
+
+
+ //addExpectedKey("event_id");
+ }
+
+
+
+ std::string SendMessageJob::eventId(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("event_id"s)) {
+ return
+ jsonBody(r).get()["event_id"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+}
diff --git a/src/csapi/room_send.hpp b/src/csapi/room_send.hpp
new file mode 100644
index 0000000..f587d71
--- /dev/null
+++ b/src/csapi/room_send.hpp
@@ -0,0 +1,79 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Send a message event to the given room.
+ *
+ * This endpoint is used to send a message event to a room. Message events
+ * allow access to historical events and pagination, making them suited
+ * for "once-off" activity in a room.
+ *
+ * The body of the request should be the content object of the event; the
+ * fields in this object will vary depending on the type of event. See
+ * `Room Events`_ for the m. event specification.
+ */
+class SendMessageJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Send a message event to the given room.
+ *
+ * \param roomId
+ * The room to send the event to.
+ *
+ * \param eventType
+ * The type of event to send.
+ *
+ * \param txnId
+ * The transaction ID for this event. Clients should generate an
+ * ID unique across requests with the same access token; it will be
+ * used by the server to ensure idempotency of requests.
+ *
+ * \param body
+ * This endpoint is used to send a message event to a room. Message events
+ * allow access to historical events and pagination, making them suited
+ * for "once-off" activity in a room.
+ *
+ * The body of the request should be the content object of the event; the
+ * fields in this object will vary depending on the type of event. See
+ * `Room Events`_ for the m. event specification.
+ */
+ explicit SendMessageJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId , std::string eventType , std::string txnId , JsonWrap body = {});
+
+
+ // Result properties
+
+
+
+
+/// A unique identifier for the event.
+static std::string eventId(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string roomId, std::string eventType, std::string txnId, JsonWrap body);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/room_state.cpp b/src/csapi/room_state.cpp
new file mode 100644
index 0000000..a003e47
--- /dev/null
+++ b/src/csapi/room_state.cpp
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "room_state.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body SetRoomStateWithKeyJob::buildBody(std::string roomId, std::string eventType, std::string stateKey, JsonWrap body)
+ {
+ // ignore unused param
+ (void)(roomId);(void)(eventType);(void)(stateKey);(void)(body);
+ return
+ BaseJob::JsonBody(body);
+
+
+
+ };
+
+SetRoomStateWithKeyJob::SetRoomStateWithKeyJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId, std::string eventType, std::string stateKey, JsonWrap body)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/state/" + eventType + "/" + stateKey,
+ PUT,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId, eventType, stateKey, body)
+ )
+ {
+
+
+ //addExpectedKey("event_id");
+ }
+
+
+
+ std::string SetRoomStateWithKeyJob::eventId(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("event_id"s)) {
+ return
+ jsonBody(r).get()["event_id"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+}
diff --git a/src/csapi/room_state.hpp b/src/csapi/room_state.hpp
new file mode 100644
index 0000000..83f62d2
--- /dev/null
+++ b/src/csapi/room_state.hpp
@@ -0,0 +1,104 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Send a state event to the given room.
+ *
+ * .. For backwards compatibility with older links...
+ * .. _`put-matrix-client-r0-rooms-roomid-state-eventtype`:
+ *
+ * State events can be sent using this endpoint. These events will be
+ * overwritten if ``<room id>``, ``<event type>`` and ``<state key>`` all
+ * match.
+ *
+ * Requests to this endpoint **cannot use transaction IDs**
+ * like other ``PUT`` paths because they cannot be differentiated from the
+ * ``state_key``. Furthermore, ``POST`` is unsupported on state paths.
+ *
+ * The body of the request should be the content object of the event; the
+ * fields in this object will vary depending on the type of event. See
+ * `Room Events`_ for the ``m.`` event specification.
+ *
+ * If the event type being sent is ``m.room.canonical_alias`` servers
+ * SHOULD ensure that any new aliases being listed in the event are valid
+ * per their grammar/syntax and that they point to the room ID where the
+ * state event is to be sent. Servers do not validate aliases which are
+ * being removed or are already present in the state event.
+ */
+class SetRoomStateWithKeyJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Send a state event to the given room.
+ *
+ * \param roomId
+ * The room to set the state in
+ *
+ * \param eventType
+ * The type of event to send.
+ *
+ * \param stateKey
+ * The state_key for the state to send. Defaults to the empty string. When
+ * an empty string, the trailing slash on this endpoint is optional.
+ *
+ * \param body
+ * .. For backwards compatibility with older links...
+ * .. _`put-matrix-client-r0-rooms-roomid-state-eventtype`:
+ *
+ * State events can be sent using this endpoint. These events will be
+ * overwritten if ``<room id>``, ``<event type>`` and ``<state key>`` all
+ * match.
+ *
+ * Requests to this endpoint **cannot use transaction IDs**
+ * like other ``PUT`` paths because they cannot be differentiated from the
+ * ``state_key``. Furthermore, ``POST`` is unsupported on state paths.
+ *
+ * The body of the request should be the content object of the event; the
+ * fields in this object will vary depending on the type of event. See
+ * `Room Events`_ for the ``m.`` event specification.
+ *
+ * If the event type being sent is ``m.room.canonical_alias`` servers
+ * SHOULD ensure that any new aliases being listed in the event are valid
+ * per their grammar/syntax and that they point to the room ID where the
+ * state event is to be sent. Servers do not validate aliases which are
+ * being removed or are already present in the state event.
+ */
+ explicit SetRoomStateWithKeyJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId , std::string eventType , std::string stateKey , JsonWrap body = {});
+
+
+ // Result properties
+
+
+
+
+/// A unique identifier for the event.
+static std::string eventId(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string roomId, std::string eventType, std::string stateKey, JsonWrap body);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/room_upgrades.cpp b/src/csapi/room_upgrades.cpp
new file mode 100644
index 0000000..376809f
--- /dev/null
+++ b/src/csapi/room_upgrades.cpp
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "room_upgrades.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body UpgradeRoomJob::buildBody(std::string roomId, std::string newVersion)
+ {
+ // ignore unused param
+ (void)(roomId);(void)(newVersion);
+
+ json _data
+ ;
+
+ _data["new_version"s] = newVersion;
+
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+UpgradeRoomJob::UpgradeRoomJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId, std::string newVersion)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/upgrade",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId, newVersion)
+ )
+ {
+
+
+ //addExpectedKey("replacement_room");
+ }
+
+
+
+ std::string UpgradeRoomJob::replacementRoom(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("replacement_room"s)) {
+ return
+ jsonBody(r).get()["replacement_room"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+}
diff --git a/src/csapi/room_upgrades.hpp b/src/csapi/room_upgrades.hpp
new file mode 100644
index 0000000..1343c12
--- /dev/null
+++ b/src/csapi/room_upgrades.hpp
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Upgrades a room to a new room version.
+ *
+ * Upgrades the given room to a particular room version.
+ */
+class UpgradeRoomJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Upgrades a room to a new room version.
+ *
+ * \param roomId
+ * The ID of the room to upgrade.
+ *
+ * \param newVersion
+ * The new version for the room.
+ */
+ explicit UpgradeRoomJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId , std::string newVersion );
+
+
+ // Result properties
+
+
+
+
+/// The ID of the new room.
+static std::string replacementRoom(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string roomId, std::string newVersion);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/rooms.cpp b/src/csapi/rooms.cpp
new file mode 100644
index 0000000..6137e41
--- /dev/null
+++ b/src/csapi/rooms.cpp
@@ -0,0 +1,193 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "rooms.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body GetOneRoomEventJob::buildBody(std::string roomId, std::string eventId)
+ {
+ // ignore unused param
+ (void)(roomId);(void)(eventId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetOneRoomEventJob::GetOneRoomEventJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId, std::string eventId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/event/" + eventId,
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId, eventId)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body GetRoomStateWithKeyJob::buildBody(std::string roomId, std::string eventType, std::string stateKey)
+ {
+ // ignore unused param
+ (void)(roomId);(void)(eventType);(void)(stateKey);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetRoomStateWithKeyJob::GetRoomStateWithKeyJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId, std::string eventType, std::string stateKey)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/state/" + eventType + "/" + stateKey,
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId, eventType, stateKey)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body GetRoomStateJob::buildBody(std::string roomId)
+ {
+ // ignore unused param
+ (void)(roomId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetRoomStateJob::GetRoomStateJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/state",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId)
+ )
+ {
+
+
+ }
+
+
+
+BaseJob::Query GetMembersByRoomJob::buildQuery(
+std::string at, std::string membership, std::string notMembership)
+{
+BaseJob::Query _q;
+
+ addToQueryIfNeeded(_q, "at"s, at);
+
+ addToQueryIfNeeded(_q, "membership"s, membership);
+
+ addToQueryIfNeeded(_q, "not_membership"s, notMembership);
+return _q;
+}
+
+ BaseJob::Body GetMembersByRoomJob::buildBody(std::string roomId, std::string at, std::string membership, std::string notMembership)
+ {
+ // ignore unused param
+ (void)(roomId);(void)(at);(void)(membership);(void)(notMembership);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetMembersByRoomJob::GetMembersByRoomJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId, std::string at, std::string membership, std::string notMembership)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/members",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId, at, membership, notMembership)
+ , buildQuery(at, membership, notMembership))
+ {
+
+
+ }
+
+
+
+ immer::array<TheCurrentMembershipStateOfAUserInTheRoom> GetMembersByRoomJob::chunk(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("chunk"s)) {
+ return
+ jsonBody(r).get()["chunk"s]
+ /*.get<immer::array<TheCurrentMembershipStateOfAUserInTheRoom>>()*/;}
+ else { return immer::array<TheCurrentMembershipStateOfAUserInTheRoom>( );}
+ }
+
+
+
+ BaseJob::Body GetJoinedMembersByRoomJob::buildBody(std::string roomId)
+ {
+ // ignore unused param
+ (void)(roomId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetJoinedMembersByRoomJob::GetJoinedMembersByRoomJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/joined_members",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId)
+ )
+ {
+
+
+ }
+
+
+
+ immer::map<std::string, GetJoinedMembersByRoomJob::RoomMember> GetJoinedMembersByRoomJob::joined(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("joined"s)) {
+ return
+ jsonBody(r).get()["joined"s]
+ /*.get<immer::map<std::string, RoomMember>>()*/;}
+ else { return immer::map<std::string, RoomMember>( );}
+ }
+
+}
diff --git a/src/csapi/rooms.hpp b/src/csapi/rooms.hpp
new file mode 100644
index 0000000..3c6a6f2
--- /dev/null
+++ b/src/csapi/rooms.hpp
@@ -0,0 +1,289 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+#include "csapi/definitions/event-schemas/schema/m.room.member.hpp"
+
+namespace Kazv {
+
+/*! \brief Get a single event by event ID.
+ *
+ * Get a single event based on ``roomId/eventId``. You must have permission to
+ * retrieve this event e.g. by being a member in the room for this event.
+ */
+class GetOneRoomEventJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Get a single event by event ID.
+ *
+ * \param roomId
+ * The ID of the room the event is in.
+ *
+ * \param eventId
+ * The event ID to get.
+ */
+ explicit GetOneRoomEventJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId , std::string eventId );
+
+
+ // Result properties
+
+
+/// The full event.
+ static JsonWrap data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<JsonWrap>()
+ ;
+ }
+
+
+
+
+ static BaseJob::Body buildBody(std::string roomId, std::string eventId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Get the state identified by the type and key.
+ *
+ * .. For backwards compatibility with older links...
+ * .. _`get-matrix-client-r0-rooms-roomid-state-eventtype`:
+ *
+ * Looks up the contents of a state event in a room. If the user is
+ * joined to the room then the state is taken from the current
+ * state of the room. If the user has left the room then the state is
+ * taken from the state of the room when they left.
+ */
+class GetRoomStateWithKeyJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Get the state identified by the type and key.
+ *
+ * \param roomId
+ * The room to look up the state in.
+ *
+ * \param eventType
+ * The type of state to look up.
+ *
+ * \param stateKey
+ * The key of the state to look up. Defaults to an empty string. When
+ * an empty string, the trailing slash on this endpoint is optional.
+ */
+ explicit GetRoomStateWithKeyJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId , std::string eventType , std::string stateKey );
+
+
+
+
+ static BaseJob::Body buildBody(std::string roomId, std::string eventType, std::string stateKey);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Get all state events in the current state of a room.
+ *
+ * Get the state events for the current state of a room.
+ */
+class GetRoomStateJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Get all state events in the current state of a room.
+ *
+ * \param roomId
+ * The room to look up the state for.
+ */
+ explicit GetRoomStateJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId );
+
+
+ // Result properties
+
+
+/// The current state of the room
+ static EventList data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<EventList>()
+ ;
+ }
+
+
+
+
+ static BaseJob::Body buildBody(std::string roomId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Get the m.room.member events for the room.
+ *
+ * Get the list of members for this room.
+ */
+class GetMembersByRoomJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Get the m.room.member events for the room.
+ *
+ * \param roomId
+ * The room to get the member events for.
+ *
+ * \param at
+ * The point in time (pagination token) to return members for in the room.
+ * This token can be obtained from a ``prev_batch`` token returned for
+ * each room by the sync API. Defaults to the current state of the room,
+ * as determined by the server.
+ *
+ * \param membership
+ * The kind of membership to filter for. Defaults to no filtering if
+ * unspecified. When specified alongside ``not_membership``, the two
+ * parameters create an 'or' condition: either the membership *is*
+ * the same as ``membership`` **or** *is not* the same as ``not_membership``.
+ *
+ * \param notMembership
+ * The kind of membership to exclude from the results. Defaults to no
+ * filtering if unspecified.
+ */
+ explicit GetMembersByRoomJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId , std::string at = {}, std::string membership = {}, std::string notMembership = {});
+
+
+ // Result properties
+
+
+
+
+/// Get the list of members for this room.
+static immer::array<TheCurrentMembershipStateOfAUserInTheRoom> chunk(Response r);
+
+ static BaseJob::Query buildQuery(
+ std::string at, std::string membership, std::string notMembership);
+
+ static BaseJob::Body buildBody(std::string roomId, std::string at, std::string membership, std::string notMembership);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Gets the list of currently joined users and their profile data.
+ *
+ * This API returns a map of MXIDs to member info objects for members of the room. The current user must be in the room for it to work, unless it is an Application Service in which case any of the AS's users must be in the room. This API is primarily for Application Services and should be faster to respond than ``/members`` as it can be implemented more efficiently on the server.
+ */
+class GetJoinedMembersByRoomJob : public BaseJob {
+public:
+ // Inner data structures
+
+/// This API returns a map of MXIDs to member info objects for members of the room. The current user must be in the room for it to work, unless it is an Application Service in which case any of the AS's users must be in the room. This API is primarily for Application Services and should be faster to respond than ``/members`` as it can be implemented more efficiently on the server.
+ struct RoomMember
+ {
+/// The display name of the user this object is representing.
+ std::string displayName;
+/// The mxc avatar url of the user this object is representing.
+ std::string avatarUrl;
+
+ };
+
+
+// Construction/destruction
+
+ /*! \brief Gets the list of currently joined users and their profile data.
+ *
+ * \param roomId
+ * The room to get the members of.
+ */
+ explicit GetJoinedMembersByRoomJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId );
+
+
+ // Result properties
+
+
+
+
+/// A map from user ID to a RoomMember object.
+static immer::map<std::string, RoomMember> joined(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string roomId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+ template<>
+ struct adl_serializer<GetJoinedMembersByRoomJob::RoomMember> {
+
+ static void from_json(const json &jo, GetJoinedMembersByRoomJob::RoomMember& result)
+ {
+
+ result.displayName = jo.at("display_name"s);
+ result.avatarUrl = jo.at("avatar_url"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/search.cpp b/src/csapi/search.cpp
new file mode 100644
index 0000000..e532740
--- /dev/null
+++ b/src/csapi/search.cpp
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "search.hpp"
+
+namespace Kazv
+{
+
+BaseJob::Query SearchJob::buildQuery(
+std::string nextBatch)
+{
+BaseJob::Query _q;
+
+ addToQueryIfNeeded(_q, "next_batch"s, nextBatch);
+return _q;
+}
+
+ BaseJob::Body SearchJob::buildBody(Categories searchCategories, std::string nextBatch)
+ {
+ // ignore unused param
+ (void)(searchCategories);(void)(nextBatch);
+
+ json _data
+ ;
+
+ _data["search_categories"s] = searchCategories;
+
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+SearchJob::SearchJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ Categories searchCategories, std::string nextBatch)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/search",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(searchCategories, nextBatch)
+ , buildQuery(nextBatch))
+ {
+
+
+ //addExpectedKey("search_categories");
+ }
+
+
+
+ SearchJob::ResultCategories SearchJob::searchCategories(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("search_categories"s)) {
+ return
+ jsonBody(r).get()["search_categories"s]
+ /*.get<ResultCategories>()*/;}
+ else { return ResultCategories( );}
+ }
+
+}
diff --git a/src/csapi/search.hpp b/src/csapi/search.hpp
new file mode 100644
index 0000000..9f59a82
--- /dev/null
+++ b/src/csapi/search.hpp
@@ -0,0 +1,370 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+#include "csapi/definitions/room_event_filter.hpp"
+
+namespace Kazv {
+
+/*! \brief Perform a server-side search.
+ *
+ * Performs a full text search across different categories.
+ */
+class SearchJob : public BaseJob {
+public:
+ // Inner data structures
+
+/// Configures whether any context for the events
+/// returned are included in the response.
+ struct IncludeEventContext
+ {
+/// How many events before the result are
+/// returned. By default, this is ``5``.
+ std::optional<int> beforeLimit;
+/// How many events after the result are
+/// returned. By default, this is ``5``.
+ std::optional<int> afterLimit;
+/// Requests that the server returns the
+/// historic profile information for the users
+/// that sent the events that were returned.
+/// By default, this is ``false``.
+ std::optional<bool> includeProfile;
+
+ };
+
+/// Configuration for group.
+ struct Group
+ {
+/// Key that defines the group.
+ std::string key;
+
+ };
+
+/// Requests that the server partitions the result set
+/// based on the provided list of keys.
+ struct Groupings
+ {
+/// List of groups to request.
+ immer::array<Group> groupBy;
+
+ };
+
+/// Mapping of category name to search criteria.
+ struct RoomEventsCriteria
+ {
+/// The string to search events for
+ std::string searchTerm;
+/// The keys to search. Defaults to all.
+ immer::array<std::string> keys;
+/// This takes a `filter`_.
+ RoomEventFilter filter;
+/// The order in which to search for results.
+/// By default, this is ``"rank"``.
+ std::string orderBy;
+/// Configures whether any context for the events
+/// returned are included in the response.
+ std::optional<IncludeEventContext> eventContext;
+/// Requests the server return the current state for
+/// each room returned.
+ std::optional<bool> includeState;
+/// Requests that the server partitions the result set
+/// based on the provided list of keys.
+ std::optional<Groupings> groupings;
+
+ };
+
+/// Describes which categories to search in and their criteria.
+ struct Categories
+ {
+/// Mapping of category name to search criteria.
+ std::optional<RoomEventsCriteria> roomEvents;
+
+ };
+
+/// Performs a full text search across different categories.
+ struct UserProfile
+ {
+/// Performs a full text search across different categories.
+ std::string displayname;
+/// Performs a full text search across different categories.
+ std::string avatarUrl;
+
+ };
+
+/// Context for result, if requested.
+ struct EventContext
+ {
+/// Pagination token for the start of the chunk
+ std::string start;
+/// Pagination token for the end of the chunk
+ std::string end;
+/// The historic profile information of the
+/// users that sent the events returned.
+///
+/// The ``string`` key is the user ID for which
+/// the profile belongs to.
+ immer::map<std::string, UserProfile> profileInfo;
+/// Events just before the result.
+ EventList eventsBefore;
+/// Events just after the result.
+ EventList eventsAfter;
+
+ };
+
+/// The result object.
+ struct Result
+ {
+/// A number that describes how closely this result matches the search. Higher is closer.
+ std::optional<double> rank;
+/// The event that matched.
+ JsonWrap result;
+/// Context for result, if requested.
+ std::optional<EventContext> context;
+
+ };
+
+/// The results for a particular group value.
+ struct GroupValue
+ {
+/// Token that can be used to get the next batch
+/// of results in the group, by passing as the
+/// `next_batch` parameter to the next call. If
+/// this field is absent, there are no more
+/// results in this group.
+ std::string nextBatch;
+/// Key that can be used to order different
+/// groups.
+ std::optional<int> order;
+/// Which results are in this group.
+ immer::array<std::string> results;
+
+ };
+
+/// Mapping of category name to search criteria.
+ struct ResultRoomEvents
+ {
+/// An approximate count of the total number of results found.
+ std::optional<int> count;
+/// List of words which should be highlighted, useful for stemming which may change the query terms.
+ immer::array<std::string> highlights;
+/// List of results in the requested order.
+ immer::array<Result> results;
+/// The current state for every room in the results.
+/// This is included if the request had the
+/// ``include_state`` key set with a value of ``true``.
+///
+/// The ``string`` key is the room ID for which the ``State
+/// Event`` array belongs to.
+ immer::map<std::string, EventList> state;
+/// Any groups that were requested.
+///
+/// The outer ``string`` key is the group key requested (eg: ``room_id``
+/// or ``sender``). The inner ``string`` key is the grouped value (eg:
+/// a room's ID or a user's ID).
+ immer::map<std::string, immer::map<std::string, GroupValue>> groups;
+/// Token that can be used to get the next batch of
+/// results, by passing as the `next_batch` parameter to
+/// the next call. If this field is absent, there are no
+/// more results.
+ std::string nextBatch;
+
+ };
+
+/// Describes which categories to search in and their criteria.
+ struct ResultCategories
+ {
+/// Mapping of category name to search criteria.
+ std::optional<ResultRoomEvents> roomEvents;
+
+ };
+
+
+// Construction/destruction
+
+ /*! \brief Perform a server-side search.
+ *
+ * \param searchCategories
+ * Describes which categories to search in and their criteria.
+ *
+ * \param nextBatch
+ * The point to return events from. If given, this should be a
+ * ``next_batch`` result from a previous call to this endpoint.
+ */
+ explicit SearchJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ Categories searchCategories , std::string nextBatch = {});
+
+
+ // Result properties
+
+
+
+
+/// Describes which categories to search in and their criteria.
+static ResultCategories searchCategories(Response r);
+
+ static BaseJob::Query buildQuery(
+ std::string nextBatch);
+
+ static BaseJob::Body buildBody(Categories searchCategories, std::string nextBatch);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+ template<>
+ struct adl_serializer<SearchJob::IncludeEventContext> {
+ static void to_json(json& jo, const SearchJob::IncludeEventContext &pod)
+ {
+
+
+
+ addToJsonIfNeeded(jo, "before_limit"s, pod.beforeLimit);
+
+ addToJsonIfNeeded(jo, "after_limit"s, pod.afterLimit);
+
+ addToJsonIfNeeded(jo, "include_profile"s, pod.includeProfile);
+ }
+
+};
+ template<>
+ struct adl_serializer<SearchJob::Group> {
+ static void to_json(json& jo, const SearchJob::Group &pod)
+ {
+
+
+
+ addToJsonIfNeeded(jo, "key"s, pod.key);
+ }
+
+};
+ template<>
+ struct adl_serializer<SearchJob::Groupings> {
+ static void to_json(json& jo, const SearchJob::Groupings &pod)
+ {
+
+
+
+ addToJsonIfNeeded(jo, "group_by"s, pod.groupBy);
+ }
+
+};
+ template<>
+ struct adl_serializer<SearchJob::RoomEventsCriteria> {
+ static void to_json(json& jo, const SearchJob::RoomEventsCriteria &pod)
+ {
+
+
+ jo["search_term"s] = pod.searchTerm;
+
+
+ addToJsonIfNeeded(jo, "keys"s, pod.keys);
+
+ addToJsonIfNeeded(jo, "filter"s, pod.filter);
+
+ addToJsonIfNeeded(jo, "order_by"s, pod.orderBy);
+
+ addToJsonIfNeeded(jo, "event_context"s, pod.eventContext);
+
+ addToJsonIfNeeded(jo, "include_state"s, pod.includeState);
+
+ addToJsonIfNeeded(jo, "groupings"s, pod.groupings);
+ }
+
+};
+ template<>
+ struct adl_serializer<SearchJob::Categories> {
+ static void to_json(json& jo, const SearchJob::Categories &pod)
+ {
+
+
+
+ addToJsonIfNeeded(jo, "room_events"s, pod.roomEvents);
+ }
+
+};
+ template<>
+ struct adl_serializer<SearchJob::UserProfile> {
+
+ static void from_json(const json &jo, SearchJob::UserProfile& result)
+ {
+
+ result.displayname = jo.at("displayname"s);
+ result.avatarUrl = jo.at("avatar_url"s);
+
+ }
+};
+ template<>
+ struct adl_serializer<SearchJob::EventContext> {
+
+ static void from_json(const json &jo, SearchJob::EventContext& result)
+ {
+
+ result.start = jo.at("start"s);
+ result.end = jo.at("end"s);
+ result.profileInfo = jo.at("profile_info"s);
+ result.eventsBefore = jo.at("events_before"s);
+ result.eventsAfter = jo.at("events_after"s);
+
+ }
+};
+ template<>
+ struct adl_serializer<SearchJob::Result> {
+
+ static void from_json(const json &jo, SearchJob::Result& result)
+ {
+
+ result.rank = jo.at("rank"s);
+ result.result = jo.at("result"s);
+ result.context = jo.at("context"s);
+
+ }
+};
+ template<>
+ struct adl_serializer<SearchJob::GroupValue> {
+
+ static void from_json(const json &jo, SearchJob::GroupValue& result)
+ {
+
+ result.nextBatch = jo.at("next_batch"s);
+ result.order = jo.at("order"s);
+ result.results = jo.at("results"s);
+
+ }
+};
+ template<>
+ struct adl_serializer<SearchJob::ResultRoomEvents> {
+
+ static void from_json(const json &jo, SearchJob::ResultRoomEvents& result)
+ {
+
+ result.count = jo.at("count"s);
+ result.highlights = jo.at("highlights"s);
+ result.results = jo.at("results"s);
+ result.state = jo.at("state"s);
+ result.groups = jo.at("groups"s);
+ result.nextBatch = jo.at("next_batch"s);
+
+ }
+};
+ template<>
+ struct adl_serializer<SearchJob::ResultCategories> {
+
+ static void from_json(const json &jo, SearchJob::ResultCategories& result)
+ {
+
+ result.roomEvents = jo.at("room_events"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/sso_login_redirect.cpp b/src/csapi/sso_login_redirect.cpp
new file mode 100644
index 0000000..2249a5d
--- /dev/null
+++ b/src/csapi/sso_login_redirect.cpp
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "sso_login_redirect.hpp"
+
+namespace Kazv
+{
+
+BaseJob::Query RedirectToSSOJob::buildQuery(
+std::string redirectUrl)
+{
+BaseJob::Query _q;
+ addToQuery(_q, "redirectUrl"s, redirectUrl);
+
+return _q;
+}
+
+ BaseJob::Body RedirectToSSOJob::buildBody(std::string redirectUrl)
+ {
+ // ignore unused param
+ (void)(redirectUrl);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+RedirectToSSOJob::RedirectToSSOJob(
+ std::string serverUrl
+
+ ,
+ std::string redirectUrl)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/login/sso/redirect",
+ GET,
+ {} ,
+ ReturnType::Json,
+ buildBody(redirectUrl)
+ , buildQuery(redirectUrl))
+ {
+
+
+ }
+
+
+
+}
diff --git a/src/csapi/sso_login_redirect.hpp b/src/csapi/sso_login_redirect.hpp
new file mode 100644
index 0000000..35a738c
--- /dev/null
+++ b/src/csapi/sso_login_redirect.hpp
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Redirect the user's browser to the SSO interface.
+ *
+ * A web-based Matrix client should instruct the user's browser to
+ * navigate to this endpoint in order to log in via SSO.
+ *
+ * The server MUST respond with an HTTP redirect to the SSO interface.
+ */
+class RedirectToSSOJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Redirect the user's browser to the SSO interface.
+ *
+ * \param redirectUrl
+ * URI to which the user will be redirected after the homeserver has
+ * authenticated the user with SSO.
+ */
+ explicit RedirectToSSOJob(std::string serverUrl
+
+ ,
+ std::string redirectUrl );
+
+
+
+ static BaseJob::Query buildQuery(
+ std::string redirectUrl);
+
+ static BaseJob::Body buildBody(std::string redirectUrl);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/sync.cpp b/src/csapi/sync.cpp
new file mode 100644
index 0000000..f3ce4bd
--- /dev/null
+++ b/src/csapi/sync.cpp
@@ -0,0 +1,133 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "sync.hpp"
+
+namespace Kazv
+{
+
+BaseJob::Query SyncJob::buildQuery(
+std::string filter, std::string since, std::optional<bool> fullState, std::string setPresence, std::optional<int> timeout)
+{
+BaseJob::Query _q;
+
+ addToQueryIfNeeded(_q, "filter"s, filter);
+
+ addToQueryIfNeeded(_q, "since"s, since);
+
+ addToQueryIfNeeded(_q, "full_state"s, fullState);
+
+ addToQueryIfNeeded(_q, "set_presence"s, setPresence);
+
+ addToQueryIfNeeded(_q, "timeout"s, timeout);
+return _q;
+}
+
+ BaseJob::Body SyncJob::buildBody(std::string filter, std::string since, std::optional<bool> fullState, std::string setPresence, std::optional<int> timeout)
+ {
+ // ignore unused param
+ (void)(filter);(void)(since);(void)(fullState);(void)(setPresence);(void)(timeout);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+SyncJob::SyncJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string filter, std::string since, std::optional<bool> fullState, std::string setPresence, std::optional<int> timeout)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/sync",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(filter, since, fullState, setPresence, timeout)
+ , buildQuery(filter, since, fullState, setPresence, timeout))
+ {
+
+
+ //addExpectedKey("next_batch");
+ }
+
+
+
+ std::string SyncJob::nextBatch(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("next_batch"s)) {
+ return
+ jsonBody(r).get()["next_batch"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+
+ std::optional<SyncJob::Rooms> SyncJob::rooms(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("rooms"s)) {
+ return
+ jsonBody(r).get()["rooms"s]
+ /*.get<Rooms>()*/;}
+ else { return std::optional<Rooms>( );}
+ }
+
+
+ std::optional<EventBatch> SyncJob::presence(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("presence"s)) {
+ return
+ jsonBody(r).get()["presence"s]
+ /*.get<EventBatch>()*/;}
+ else { return std::optional<EventBatch>( );}
+ }
+
+
+ std::optional<EventBatch> SyncJob::accountData(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("account_data"s)) {
+ return
+ jsonBody(r).get()["account_data"s]
+ /*.get<EventBatch>()*/;}
+ else { return std::optional<EventBatch>( );}
+ }
+
+
+ JsonWrap SyncJob::toDevice(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("to_device"s)) {
+ return
+ jsonBody(r).get()["to_device"s]
+ /*.get<JsonWrap>()*/;}
+ else { return JsonWrap( );}
+ }
+
+
+ JsonWrap SyncJob::deviceLists(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("device_lists"s)) {
+ return
+ jsonBody(r).get()["device_lists"s]
+ /*.get<JsonWrap>()*/;}
+ else { return JsonWrap( );}
+ }
+
+
+ immer::map<std::string, int> SyncJob::deviceOneTimeKeysCount(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("device_one_time_keys_count"s)) {
+ return
+ jsonBody(r).get()["device_one_time_keys_count"s]
+ /*.get<immer::map<std::string, int>>()*/;}
+ else { return immer::map<std::string, int>( );}
+ }
+
+}
diff --git a/src/csapi/sync.hpp b/src/csapi/sync.hpp
new file mode 100644
index 0000000..941462b
--- /dev/null
+++ b/src/csapi/sync.hpp
@@ -0,0 +1,430 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+#include "csapi/definitions/event-schemas/schema/stripped_state.hpp"
+#include "csapi/definitions/event_batch.hpp"
+#include "csapi/definitions/timeline_batch.hpp"
+#include "csapi/definitions/state_event_batch.hpp"
+
+namespace Kazv {
+
+/*! \brief Synchronise the client's state and receive new messages.
+ *
+ * Synchronise the client's state with the latest state on the server.
+ * Clients use this API when they first log in to get an initial snapshot
+ * of the state on the server, and then continue to call this API to get
+ * incremental deltas to the state, and to receive new messages.
+ *
+ * *Note*: This endpoint supports lazy-loading. See `Filtering <#filtering>`_
+ * for more information. Lazy-loading members is only supported on a ``StateFilter``
+ * for this endpoint. When lazy-loading is enabled, servers MUST include the
+ * syncing user's own membership event when they join a room, or when the
+ * full state of rooms is requested, to aid discovering the user's avatar &
+ * displayname.
+ *
+ * Like other members, the user's own membership event is eligible
+ * for being considered redundant by the server. When a sync is ``limited``,
+ * the server MUST return membership events for events in the gap
+ * (between ``since`` and the start of the returned timeline), regardless
+ * as to whether or not they are redundant. This ensures that joins/leaves
+ * and profile changes which occur during the gap are not lost.
+ */
+class SyncJob : public BaseJob {
+public:
+ // Inner data structures
+
+/// Information about the room which clients may need to
+/// correctly render it to users.
+ struct RoomSummary
+ {
+/// The users which can be used to generate a room name
+/// if the room does not have one. Required if the room's
+/// ``m.room.name`` or ``m.room.canonical_alias`` state events
+/// are unset or empty.
+///
+/// This should be the first 5 members of the room, ordered
+/// by stream ordering, which are joined or invited. The
+/// list must never include the client's own user ID. When
+/// no joined or invited members are available, this should
+/// consist of the banned and left users. More than 5 members
+/// may be provided, however less than 5 should only be provided
+/// when there are less than 5 members to represent.
+///
+/// When lazy-loading room members is enabled, the membership
+/// events for the heroes MUST be included in the ``state``,
+/// unless they are redundant. When the list of users changes,
+/// the server notifies the client by sending a fresh list of
+/// heroes. If there are no changes since the last sync, this
+/// field may be omitted.
+ immer::array<std::string> mHeroes;
+/// The number of users with ``membership`` of ``join``,
+/// including the client's own user ID. If this field has
+/// not changed since the last sync, it may be omitted.
+/// Required otherwise.
+ std::optional<int> mJoinedMemberCount;
+/// The number of users with ``membership`` of ``invite``.
+/// If this field has not changed since the last sync, it
+/// may be omitted. Required otherwise.
+ std::optional<int> mInvitedMemberCount;
+
+ };
+
+/// Counts of unread notifications for this room. See the
+/// `Receiving notifications section <#receiving-notifications>`_
+/// for more information on how these are calculated.
+ struct UnreadNotificationCounts
+ {
+/// The number of unread notifications for this room with the highlight flag set
+ std::optional<int> highlightCount;
+/// The total number of unread notifications for this room
+ std::optional<int> notificationCount;
+
+ };
+
+/// Synchronise the client's state with the latest state on the server.
+/// Clients use this API when they first log in to get an initial snapshot
+/// of the state on the server, and then continue to call this API to get
+/// incremental deltas to the state, and to receive new messages.
+///
+/// *Note*: This endpoint supports lazy-loading. See `Filtering <#filtering>`_
+/// for more information. Lazy-loading members is only supported on a ``StateFilter``
+/// for this endpoint. When lazy-loading is enabled, servers MUST include the
+/// syncing user's own membership event when they join a room, or when the
+/// full state of rooms is requested, to aid discovering the user's avatar &
+/// displayname.
+///
+/// Like other members, the user's own membership event is eligible
+/// for being considered redundant by the server. When a sync is ``limited``,
+/// the server MUST return membership events for events in the gap
+/// (between ``since`` and the start of the returned timeline), regardless
+/// as to whether or not they are redundant. This ensures that joins/leaves
+/// and profile changes which occur during the gap are not lost.
+ struct JoinedRoom
+ {
+/// Information about the room which clients may need to
+/// correctly render it to users.
+ std::optional<RoomSummary> summary;
+/// Updates to the state, between the time indicated by
+/// the ``since`` parameter, and the start of the
+/// ``timeline`` (or all state up to the start of the
+/// ``timeline``, if ``since`` is not given, or
+/// ``full_state`` is true).
+///
+/// N.B. state updates for ``m.room.member`` events will
+/// be incomplete if ``lazy_load_members`` is enabled in
+/// the ``/sync`` filter, and only return the member events
+/// required to display the senders of the timeline events
+/// in this response.
+ std::optional<StateEventBatch> state;
+/// The timeline of messages and state changes in the
+/// room.
+ Timeline timeline;
+/// The ephemeral events in the room that aren't
+/// recorded in the timeline or state of the room.
+/// e.g. typing.
+ std::optional<EventBatch> ephemeral;
+/// The private data that this user has attached to
+/// this room.
+ std::optional<EventBatch> accountData;
+/// Counts of unread notifications for this room. See the
+/// `Receiving notifications section <#receiving-notifications>`_
+/// for more information on how these are calculated.
+ std::optional<UnreadNotificationCounts> unreadNotifications;
+
+ };
+
+/// The state of a room that the user has been invited
+/// to. These state events may only have the ``sender``,
+/// ``type``, ``state_key`` and ``content`` keys
+/// present. These events do not replace any state that
+/// the client already has for the room, for example if
+/// the client has archived the room. Instead the
+/// client should keep two separate copies of the
+/// state: the one from the ``invite_state`` and one
+/// from the archived ``state``. If the client joins
+/// the room then the current state will be given as a
+/// delta against the archived ``state`` not the
+/// ``invite_state``.
+ struct InviteState
+ {
+/// The StrippedState events that form the invite state.
+ immer::array<StrippedState> events;
+
+ };
+
+/// Synchronise the client's state with the latest state on the server.
+/// Clients use this API when they first log in to get an initial snapshot
+/// of the state on the server, and then continue to call this API to get
+/// incremental deltas to the state, and to receive new messages.
+///
+/// *Note*: This endpoint supports lazy-loading. See `Filtering <#filtering>`_
+/// for more information. Lazy-loading members is only supported on a ``StateFilter``
+/// for this endpoint. When lazy-loading is enabled, servers MUST include the
+/// syncing user's own membership event when they join a room, or when the
+/// full state of rooms is requested, to aid discovering the user's avatar &
+/// displayname.
+///
+/// Like other members, the user's own membership event is eligible
+/// for being considered redundant by the server. When a sync is ``limited``,
+/// the server MUST return membership events for events in the gap
+/// (between ``since`` and the start of the returned timeline), regardless
+/// as to whether or not they are redundant. This ensures that joins/leaves
+/// and profile changes which occur during the gap are not lost.
+ struct InvitedRoom
+ {
+/// The state of a room that the user has been invited
+/// to. These state events may only have the ``sender``,
+/// ``type``, ``state_key`` and ``content`` keys
+/// present. These events do not replace any state that
+/// the client already has for the room, for example if
+/// the client has archived the room. Instead the
+/// client should keep two separate copies of the
+/// state: the one from the ``invite_state`` and one
+/// from the archived ``state``. If the client joins
+/// the room then the current state will be given as a
+/// delta against the archived ``state`` not the
+/// ``invite_state``.
+ std::optional<InviteState> inviteState;
+
+ };
+
+/// Synchronise the client's state with the latest state on the server.
+/// Clients use this API when they first log in to get an initial snapshot
+/// of the state on the server, and then continue to call this API to get
+/// incremental deltas to the state, and to receive new messages.
+///
+/// *Note*: This endpoint supports lazy-loading. See `Filtering <#filtering>`_
+/// for more information. Lazy-loading members is only supported on a ``StateFilter``
+/// for this endpoint. When lazy-loading is enabled, servers MUST include the
+/// syncing user's own membership event when they join a room, or when the
+/// full state of rooms is requested, to aid discovering the user's avatar &
+/// displayname.
+///
+/// Like other members, the user's own membership event is eligible
+/// for being considered redundant by the server. When a sync is ``limited``,
+/// the server MUST return membership events for events in the gap
+/// (between ``since`` and the start of the returned timeline), regardless
+/// as to whether or not they are redundant. This ensures that joins/leaves
+/// and profile changes which occur during the gap are not lost.
+ struct LeftRoom
+ {
+/// The state updates for the room up to the start of the timeline.
+ std::optional<StateEventBatch> state;
+/// The timeline of messages and state changes in the
+/// room up to the point when the user left.
+ Timeline timeline;
+/// The private data that this user has attached to
+/// this room.
+ std::optional<EventBatch> accountData;
+
+ };
+
+/// Updates to rooms.
+ struct Rooms
+ {
+/// The rooms that the user has joined, mapped as room ID to
+/// room information.
+ immer::map<std::string, JoinedRoom> join;
+/// The rooms that the user has been invited to, mapped as room ID to
+/// room information.
+ immer::map<std::string, InvitedRoom> invite;
+/// The rooms that the user has left or been banned from, mapped as room ID to
+/// room information.
+ immer::map<std::string, LeftRoom> leave;
+
+ };
+
+
+// Construction/destruction
+
+ /*! \brief Synchronise the client's state and receive new messages.
+ *
+ * \param filter
+ * The ID of a filter created using the filter API or a filter JSON
+ * object encoded as a string. The server will detect whether it is
+ * an ID or a JSON object by whether the first character is a ``"{"``
+ * open brace. Passing the JSON inline is best suited to one off
+ * requests. Creating a filter using the filter API is recommended for
+ * clients that reuse the same filter multiple times, for example in
+ * long poll requests.
+ *
+ * See `Filtering <#filtering>`_ for more information.
+ *
+ * \param since
+ * A point in time to continue a sync from.
+ *
+ * \param fullState
+ * Controls whether to include the full state for all rooms the user
+ * is a member of.
+ *
+ * If this is set to ``true``, then all state events will be returned,
+ * even if ``since`` is non-empty. The timeline will still be limited
+ * by the ``since`` parameter. In this case, the ``timeout`` parameter
+ * will be ignored and the query will return immediately, possibly with
+ * an empty timeline.
+ *
+ * If ``false``, and ``since`` is non-empty, only state which has
+ * changed since the point indicated by ``since`` will be returned.
+ *
+ * By default, this is ``false``.
+ *
+ * \param setPresence
+ * Controls whether the client is automatically marked as online by
+ * polling this API. If this parameter is omitted then the client is
+ * automatically marked as online when it uses this API. Otherwise if
+ * the parameter is set to "offline" then the client is not marked as
+ * being online when it uses this API. When set to "unavailable", the
+ * client is marked as being idle.
+ *
+ * \param timeout
+ * The maximum time to wait, in milliseconds, before returning this
+ * request. If no events (or other data) become available before this
+ * time elapses, the server will return a response with empty fields.
+ *
+ * By default, this is ``0``, so the server will return immediately
+ * even if the response is empty.
+ */
+ explicit SyncJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string filter = {}, std::string since = {}, std::optional<bool> fullState = std::nullopt, std::string setPresence = {}, std::optional<int> timeout = std::nullopt);
+
+
+ // Result properties
+
+
+
+
+/// The batch token to supply in the ``since`` param of the next
+/// ``/sync`` request.
+static std::string nextBatch(Response r);
+
+
+/// Updates to rooms.
+static std::optional<Rooms> rooms(Response r);
+
+
+/// The updates to the presence status of other users.
+static std::optional<EventBatch> presence(Response r);
+
+
+/// The global private data created by this user.
+static std::optional<EventBatch> accountData(Response r);
+
+
+/// Information on the send-to-device messages for the client
+/// device, as defined in |send_to_device_sync|_.
+static JsonWrap toDevice(Response r);
+
+
+/// Information on end-to-end device updates, as specified in
+/// |device_lists_sync|_.
+static JsonWrap deviceLists(Response r);
+
+
+/// Information on end-to-end encryption keys, as specified
+/// in |device_lists_sync|_.
+static immer::map<std::string, int> deviceOneTimeKeysCount(Response r);
+
+ static BaseJob::Query buildQuery(
+ std::string filter, std::string since, std::optional<bool> fullState, std::string setPresence, std::optional<int> timeout);
+
+ static BaseJob::Body buildBody(std::string filter, std::string since, std::optional<bool> fullState, std::string setPresence, std::optional<int> timeout);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+ template<>
+ struct adl_serializer<SyncJob::RoomSummary> {
+
+ static void from_json(const json &jo, SyncJob::RoomSummary& result)
+ {
+
+ result.mHeroes = jo.at("m.heroes"s);
+ result.mJoinedMemberCount = jo.at("m.joined_member_count"s);
+ result.mInvitedMemberCount = jo.at("m.invited_member_count"s);
+
+ }
+};
+ template<>
+ struct adl_serializer<SyncJob::UnreadNotificationCounts> {
+
+ static void from_json(const json &jo, SyncJob::UnreadNotificationCounts& result)
+ {
+
+ result.highlightCount = jo.at("highlight_count"s);
+ result.notificationCount = jo.at("notification_count"s);
+
+ }
+};
+ template<>
+ struct adl_serializer<SyncJob::JoinedRoom> {
+
+ static void from_json(const json &jo, SyncJob::JoinedRoom& result)
+ {
+
+ result.summary = jo.at("summary"s);
+ result.state = jo.at("state"s);
+ result.timeline = jo.at("timeline"s);
+ result.ephemeral = jo.at("ephemeral"s);
+ result.accountData = jo.at("account_data"s);
+ result.unreadNotifications = jo.at("unread_notifications"s);
+
+ }
+};
+ template<>
+ struct adl_serializer<SyncJob::InviteState> {
+
+ static void from_json(const json &jo, SyncJob::InviteState& result)
+ {
+
+ result.events = jo.at("events"s);
+
+ }
+};
+ template<>
+ struct adl_serializer<SyncJob::InvitedRoom> {
+
+ static void from_json(const json &jo, SyncJob::InvitedRoom& result)
+ {
+
+ result.inviteState = jo.at("invite_state"s);
+
+ }
+};
+ template<>
+ struct adl_serializer<SyncJob::LeftRoom> {
+
+ static void from_json(const json &jo, SyncJob::LeftRoom& result)
+ {
+
+ result.state = jo.at("state"s);
+ result.timeline = jo.at("timeline"s);
+ result.accountData = jo.at("account_data"s);
+
+ }
+};
+ template<>
+ struct adl_serializer<SyncJob::Rooms> {
+
+ static void from_json(const json &jo, SyncJob::Rooms& result)
+ {
+
+ result.join = jo.at("join"s);
+ result.invite = jo.at("invite"s);
+ result.leave = jo.at("leave"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/tags.cpp b/src/csapi/tags.cpp
new file mode 100644
index 0000000..84faaad
--- /dev/null
+++ b/src/csapi/tags.cpp
@@ -0,0 +1,115 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "tags.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body GetRoomTagsJob::buildBody(std::string userId, std::string roomId)
+ {
+ // ignore unused param
+ (void)(userId);(void)(roomId);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetRoomTagsJob::GetRoomTagsJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId, std::string roomId)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/user/" + userId + "/rooms/" + roomId + "/tags",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(userId, roomId)
+ )
+ {
+
+
+ }
+
+
+
+ immer::map<std::string, GetRoomTagsJob::Tag> GetRoomTagsJob::tags(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("tags"s)) {
+ return
+ jsonBody(r).get()["tags"s]
+ /*.get<immer::map<std::string, Tag>>()*/;}
+ else { return immer::map<std::string, Tag>( );}
+ }
+
+
+
+ BaseJob::Body SetRoomTagJob::buildBody(std::string userId, std::string roomId, std::string tag, std::optional<float> order, JsonWrap additionalProperties)
+ {
+ // ignore unused param
+ (void)(userId);(void)(roomId);(void)(tag);(void)(order);(void)(additionalProperties);
+
+ json _data
+ ;
+ addPropertyMapToJson(_data, additionalProperties);
+
+ addToJsonIfNeeded(_data, "order"s, order);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+SetRoomTagJob::SetRoomTagJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId, std::string roomId, std::string tag, std::optional<float> order, JsonWrap additionalProperties)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/user/" + userId + "/rooms/" + roomId + "/tags/" + tag,
+ PUT,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(userId, roomId, tag, order, additionalProperties)
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body DeleteRoomTagJob::buildBody(std::string userId, std::string roomId, std::string tag)
+ {
+ // ignore unused param
+ (void)(userId);(void)(roomId);(void)(tag);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+DeleteRoomTagJob::DeleteRoomTagJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId, std::string roomId, std::string tag)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/user/" + userId + "/rooms/" + roomId + "/tags/" + tag,
+ DELETE,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(userId, roomId, tag)
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/tags.hpp b/src/csapi/tags.hpp
new file mode 100644
index 0000000..8baab7c
--- /dev/null
+++ b/src/csapi/tags.hpp
@@ -0,0 +1,173 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief List the tags for a room.
+ *
+ * List the tags set by a user on a room.
+ */
+class GetRoomTagsJob : public BaseJob {
+public:
+ // Inner data structures
+
+/// List the tags set by a user on a room.
+ struct Tag
+ {
+/// A number in a range ``[0,1]`` describing a relative
+/// position of the room under the given tag.
+ std::optional<float> order;
+/// List the tags set by a user on a room.
+ JsonWrap additionalProperties;
+ };
+
+
+// Construction/destruction
+
+ /*! \brief List the tags for a room.
+ *
+ * \param userId
+ * The id of the user to get tags for. The access token must be
+ * authorized to make requests for this user ID.
+ *
+ * \param roomId
+ * The ID of the room to get tags for.
+ */
+ explicit GetRoomTagsJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId , std::string roomId );
+
+
+ // Result properties
+
+
+
+
+/// List the tags set by a user on a room.
+static immer::map<std::string, Tag> tags(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string userId, std::string roomId);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+ template<>
+ struct adl_serializer<GetRoomTagsJob::Tag> {
+
+ static void from_json(const json &jo, GetRoomTagsJob::Tag& result)
+ {
+
+ result.order = jo.at("order"s);
+ result.additionalProperties = jo;
+ }
+};
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Add a tag to a room.
+ *
+ * Add a tag to the room.
+ */
+class SetRoomTagJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Add a tag to a room.
+ *
+ * \param userId
+ * The id of the user to add a tag for. The access token must be
+ * authorized to make requests for this user ID.
+ *
+ * \param roomId
+ * The ID of the room to add a tag to.
+ *
+ * \param tag
+ * The tag to add.
+ *
+ * \param order
+ * A number in a range ``[0,1]`` describing a relative
+ * position of the room under the given tag.
+ *
+ * \param additionalProperties
+ * Add a tag to the room.
+ */
+ explicit SetRoomTagJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId , std::string roomId , std::string tag , std::optional<float> order = std::nullopt, JsonWrap additionalProperties = {});
+
+
+
+
+ static BaseJob::Body buildBody(std::string userId, std::string roomId, std::string tag, std::optional<float> order, JsonWrap additionalProperties);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Remove a tag from the room.
+ *
+ * Remove a tag from the room.
+ */
+class DeleteRoomTagJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Remove a tag from the room.
+ *
+ * \param userId
+ * The id of the user to remove a tag for. The access token must be
+ * authorized to make requests for this user ID.
+ *
+ * \param roomId
+ * The ID of the room to remove a tag from.
+ *
+ * \param tag
+ * The tag to remove.
+ */
+ explicit DeleteRoomTagJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId , std::string roomId , std::string tag );
+
+
+
+
+ static BaseJob::Body buildBody(std::string userId, std::string roomId, std::string tag);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/third_party_lookup.cpp b/src/csapi/third_party_lookup.cpp
new file mode 100644
index 0000000..f6c10e0
--- /dev/null
+++ b/src/csapi/third_party_lookup.cpp
@@ -0,0 +1,221 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "third_party_lookup.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body GetProtocolsJob::buildBody()
+ {
+ // ignore unused param
+
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetProtocolsJob::GetProtocolsJob(
+ std::string serverUrl
+ , std::string _accessToken
+
+ )
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/thirdparty/protocols",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody()
+ )
+ {
+
+
+ }
+
+
+
+
+ BaseJob::Body GetProtocolMetadataJob::buildBody(std::string protocol)
+ {
+ // ignore unused param
+ (void)(protocol);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetProtocolMetadataJob::GetProtocolMetadataJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string protocol)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/thirdparty/protocol/" + protocol,
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(protocol)
+ )
+ {
+
+
+ }
+
+
+
+BaseJob::Query QueryLocationByProtocolJob::buildQuery(
+std::string searchFields)
+{
+BaseJob::Query _q;
+
+ addToQueryIfNeeded(_q, "searchFields"s, searchFields);
+return _q;
+}
+
+ BaseJob::Body QueryLocationByProtocolJob::buildBody(std::string protocol, std::string searchFields)
+ {
+ // ignore unused param
+ (void)(protocol);(void)(searchFields);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+QueryLocationByProtocolJob::QueryLocationByProtocolJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string protocol, std::string searchFields)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/thirdparty/location/" + protocol,
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(protocol, searchFields)
+ , buildQuery(searchFields))
+ {
+
+
+ }
+
+
+
+BaseJob::Query QueryUserByProtocolJob::buildQuery(
+std::string fields)
+{
+BaseJob::Query _q;
+
+ addToQueryIfNeeded(_q, "fields..."s, fields);
+return _q;
+}
+
+ BaseJob::Body QueryUserByProtocolJob::buildBody(std::string protocol, std::string fields)
+ {
+ // ignore unused param
+ (void)(protocol);(void)(fields);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+QueryUserByProtocolJob::QueryUserByProtocolJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string protocol, std::string fields)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/thirdparty/user/" + protocol,
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(protocol, fields)
+ , buildQuery(fields))
+ {
+
+
+ }
+
+
+
+BaseJob::Query QueryLocationByAliasJob::buildQuery(
+std::string alias)
+{
+BaseJob::Query _q;
+ addToQuery(_q, "alias"s, alias);
+
+return _q;
+}
+
+ BaseJob::Body QueryLocationByAliasJob::buildBody(std::string alias)
+ {
+ // ignore unused param
+ (void)(alias);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+QueryLocationByAliasJob::QueryLocationByAliasJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string alias)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/thirdparty/location",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(alias)
+ , buildQuery(alias))
+ {
+
+
+ }
+
+
+
+BaseJob::Query QueryUserByIDJob::buildQuery(
+std::string userid)
+{
+BaseJob::Query _q;
+ addToQuery(_q, "userid"s, userid);
+
+return _q;
+}
+
+ BaseJob::Body QueryUserByIDJob::buildBody(std::string userid)
+ {
+ // ignore unused param
+ (void)(userid);
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+QueryUserByIDJob::QueryUserByIDJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userid)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/thirdparty/user",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(userid)
+ , buildQuery(userid))
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/third_party_lookup.hpp b/src/csapi/third_party_lookup.hpp
new file mode 100644
index 0000000..be65055
--- /dev/null
+++ b/src/csapi/third_party_lookup.hpp
@@ -0,0 +1,326 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+#include "csapi/../application-service/definitions/user.hpp"
+#include "csapi/../application-service/definitions/location.hpp"
+#include "csapi/../application-service/definitions/protocol.hpp"
+
+namespace Kazv {
+
+/*! \brief Retrieve metadata about all protocols that a homeserver supports.
+ *
+ * Fetches the overall metadata about protocols supported by the
+ * homeserver. Includes both the available protocols and all fields
+ * required for queries against each protocol.
+ */
+class GetProtocolsJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /// Retrieve metadata about all protocols that a homeserver supports.
+ explicit GetProtocolsJob(std::string serverUrl
+ , std::string _accessToken
+
+ );
+
+
+ // Result properties
+
+
+/// The protocols supported by the homeserver.
+ static immer::map<std::string, ThirdPartyProtocol> data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<immer::map<std::string, ThirdPartyProtocol>>()
+ ;
+ }
+
+
+
+
+ static BaseJob::Body buildBody();
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Retrieve metadata about a specific protocol that the homeserver supports.
+ *
+ * Fetches the metadata from the homeserver about a particular third party protocol.
+ */
+class GetProtocolMetadataJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Retrieve metadata about a specific protocol that the homeserver supports.
+ *
+ * \param protocol
+ * The name of the protocol.
+ */
+ explicit GetProtocolMetadataJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string protocol );
+
+
+ // Result properties
+
+
+/// The protocol was found and metadata returned.
+ static ThirdPartyProtocol data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<ThirdPartyProtocol>()
+ ;
+ }
+
+
+
+
+ static BaseJob::Body buildBody(std::string protocol);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Retrieve Matrix-side portals rooms leading to a third party location.
+ *
+ * Requesting this endpoint with a valid protocol name results in a list
+ * of successful mapping results in a JSON array. Each result contains
+ * objects to represent the Matrix room or rooms that represent a portal
+ * to this third party network. Each has the Matrix room alias string,
+ * an identifier for the particular third party network protocol, and an
+ * object containing the network-specific fields that comprise this
+ * identifier. It should attempt to canonicalise the identifier as much
+ * as reasonably possible given the network type.
+ */
+class QueryLocationByProtocolJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Retrieve Matrix-side portals rooms leading to a third party location.
+ *
+ * \param protocol
+ * The protocol used to communicate to the third party network.
+ *
+ * \param searchFields
+ * One or more custom fields to help identify the third party
+ * location.
+ */
+ explicit QueryLocationByProtocolJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string protocol , std::string searchFields = {});
+
+
+ // Result properties
+
+
+/// At least one portal room was found.
+ static immer::array<ThirdPartyLocation> data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<immer::array<ThirdPartyLocation>>()
+ ;
+ }
+
+
+ static BaseJob::Query buildQuery(
+ std::string searchFields);
+
+ static BaseJob::Body buildBody(std::string protocol, std::string searchFields);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Retrieve the Matrix User ID of a corresponding third party user.
+ *
+ * Retrieve a Matrix User ID linked to a user on the third party service, given
+ * a set of user parameters.
+ */
+class QueryUserByProtocolJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Retrieve the Matrix User ID of a corresponding third party user.
+ *
+ * \param protocol
+ * The name of the protocol.
+ *
+ * \param fields
+ * One or more custom fields that are passed to the AS to help identify the user.
+ */
+ explicit QueryUserByProtocolJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string protocol , std::string fields = {});
+
+
+ // Result properties
+
+
+/// The Matrix User IDs found with the given parameters.
+ static immer::array<ThirdPartyUser> data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<immer::array<ThirdPartyUser>>()
+ ;
+ }
+
+
+ static BaseJob::Query buildQuery(
+ std::string fields);
+
+ static BaseJob::Body buildBody(std::string protocol, std::string fields);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Reverse-lookup third party locations given a Matrix room alias.
+ *
+ * Retrieve an array of third party network locations from a Matrix room
+ * alias.
+ */
+class QueryLocationByAliasJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Reverse-lookup third party locations given a Matrix room alias.
+ *
+ * \param alias
+ * The Matrix room alias to look up.
+ */
+ explicit QueryLocationByAliasJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string alias );
+
+
+ // Result properties
+
+
+/// All found third party locations.
+ static immer::array<ThirdPartyLocation> data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<immer::array<ThirdPartyLocation>>()
+ ;
+ }
+
+
+ static BaseJob::Query buildQuery(
+ std::string alias);
+
+ static BaseJob::Body buildBody(std::string alias);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+/*! \brief Reverse-lookup third party users given a Matrix User ID.
+ *
+ * Retrieve an array of third party users from a Matrix User ID.
+ */
+class QueryUserByIDJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Reverse-lookup third party users given a Matrix User ID.
+ *
+ * \param userid
+ * The Matrix User ID to look up.
+ */
+ explicit QueryUserByIDJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userid );
+
+
+ // Result properties
+
+
+/// An array of third party users.
+ static immer::array<ThirdPartyUser> data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<immer::array<ThirdPartyUser>>()
+ ;
+ }
+
+
+ static BaseJob::Query buildQuery(
+ std::string userid);
+
+ static BaseJob::Body buildBody(std::string userid);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/third_party_membership.cpp b/src/csapi/third_party_membership.cpp
new file mode 100644
index 0000000..0796c24
--- /dev/null
+++ b/src/csapi/third_party_membership.cpp
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "third_party_membership.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body InviteBy3PIDJob::buildBody(std::string roomId, std::string idServer, std::string idAccessToken, std::string medium, std::string address)
+ {
+ // ignore unused param
+ (void)(roomId);(void)(idServer);(void)(idAccessToken);(void)(medium);(void)(address);
+
+ json _data
+ ;
+
+ _data["id_server"s] = idServer;
+
+ _data["id_access_token"s] = idAccessToken;
+
+ _data["medium"s] = medium;
+
+ _data["address"s] = address;
+
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+InviteBy3PIDJob::InviteBy3PIDJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId, std::string idServer, std::string idAccessToken, std::string medium, std::string address)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/invite",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(roomId, idServer, idAccessToken, medium, address)
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/third_party_membership.hpp b/src/csapi/third_party_membership.hpp
new file mode 100644
index 0000000..d0b769a
--- /dev/null
+++ b/src/csapi/third_party_membership.hpp
@@ -0,0 +1,105 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Invite a user to participate in a particular room.
+ *
+ * .. _invite-by-third-party-id-endpoint:
+ *
+ * *Note that there are two forms of this API, which are documented separately.
+ * This version of the API does not require that the inviter know the Matrix
+ * identifier of the invitee, and instead relies on third party identifiers.
+ * The homeserver uses an identity server to perform the mapping from
+ * third party identifier to a Matrix identifier. The other is documented in the*
+ * `joining rooms section`_.
+ *
+ * This API invites a user to participate in a particular room.
+ * They do not start participating in the room until they actually join the
+ * room.
+ *
+ * Only users currently in a particular room can invite other users to
+ * join that room.
+ *
+ * If the identity server did know the Matrix user identifier for the
+ * third party identifier, the homeserver will append a ``m.room.member``
+ * event to the room.
+ *
+ * If the identity server does not know a Matrix user identifier for the
+ * passed third party identifier, the homeserver will issue an invitation
+ * which can be accepted upon providing proof of ownership of the third
+ * party identifier. This is achieved by the identity server generating a
+ * token, which it gives to the inviting homeserver. The homeserver will
+ * add an ``m.room.third_party_invite`` event into the graph for the room,
+ * containing that token.
+ *
+ * When the invitee binds the invited third party identifier to a Matrix
+ * user ID, the identity server will give the user a list of pending
+ * invitations, each containing:
+ *
+ * - The room ID to which they were invited
+ *
+ * - The token given to the homeserver
+ *
+ * - A signature of the token, signed with the identity server's private key
+ *
+ * - The matrix user ID who invited them to the room
+ *
+ * If a token is requested from the identity server, the homeserver will
+ * append a ``m.room.third_party_invite`` event to the room.
+ *
+ * .. _joining rooms section: `invite-by-user-id-endpoint`_
+ */
+class InviteBy3PIDJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Invite a user to participate in a particular room.
+ *
+ * \param roomId
+ * The room identifier (not alias) to which to invite the user.
+ *
+ * \param idServer
+ * The hostname+port of the identity server which should be used for third party identifier lookups.
+ *
+ * \param idAccessToken
+ * An access token previously registered with the identity server. Servers
+ * can treat this as optional to distinguish between r0.5-compatible clients
+ * and this specification version.
+ *
+ * \param medium
+ * The kind of address being passed in the address field, for example ``email``.
+ *
+ * \param address
+ * The invitee's third party identifier.
+ */
+ explicit InviteBy3PIDJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string roomId , std::string idServer , std::string idAccessToken , std::string medium , std::string address );
+
+
+
+
+ static BaseJob::Body buildBody(std::string roomId, std::string idServer, std::string idAccessToken, std::string medium, std::string address);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/to_device.cpp b/src/csapi/to_device.cpp
new file mode 100644
index 0000000..045ec20
--- /dev/null
+++ b/src/csapi/to_device.cpp
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "to_device.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body SendToDeviceJob::buildBody(std::string eventType, std::string txnId, immer::map<std::string, immer::map<std::string, JsonWrap>> messages)
+ {
+ // ignore unused param
+ (void)(eventType);(void)(txnId);(void)(messages);
+
+ json _data
+ ;
+
+
+ addToJsonIfNeeded(_data, "messages"s, messages);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+SendToDeviceJob::SendToDeviceJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string eventType, std::string txnId, immer::map<std::string, immer::map<std::string, JsonWrap>> messages)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/sendToDevice/" + eventType + "/" + txnId,
+ PUT,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(eventType, txnId, messages)
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/to_device.hpp b/src/csapi/to_device.hpp
new file mode 100644
index 0000000..5876083
--- /dev/null
+++ b/src/csapi/to_device.hpp
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Send an event to a given set of devices.
+ *
+ * This endpoint is used to send send-to-device events to a set of
+ * client devices.
+ */
+class SendToDeviceJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Send an event to a given set of devices.
+ *
+ * \param eventType
+ * The type of event to send.
+ *
+ * \param txnId
+ * The transaction ID for this event. Clients should generate an
+ * ID unique across requests with the same access token; it will be
+ * used by the server to ensure idempotency of requests.
+ *
+ * \param messages
+ * The messages to send. A map from user ID, to a map from
+ * device ID to message body. The device ID may also be `*`,
+ * meaning all known devices for the user.
+ */
+ explicit SendToDeviceJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string eventType , std::string txnId , immer::map<std::string, immer::map<std::string, JsonWrap>> messages = {});
+
+
+
+
+ static BaseJob::Body buildBody(std::string eventType, std::string txnId, immer::map<std::string, immer::map<std::string, JsonWrap>> messages);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/typing.cpp b/src/csapi/typing.cpp
new file mode 100644
index 0000000..1330eb1
--- /dev/null
+++ b/src/csapi/typing.cpp
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "typing.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body SetTypingJob::buildBody(std::string userId, std::string roomId, bool typing, std::optional<int> timeout)
+ {
+ // ignore unused param
+ (void)(userId);(void)(roomId);(void)(typing);(void)(timeout);
+
+ json _data
+ ;
+
+ _data["typing"s] = typing;
+
+
+ addToJsonIfNeeded(_data, "timeout"s, timeout);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+SetTypingJob::SetTypingJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId, std::string roomId, bool typing, std::optional<int> timeout)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/rooms/" + roomId + "/typing/" + userId,
+ PUT,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(userId, roomId, typing, timeout)
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/typing.hpp b/src/csapi/typing.hpp
new file mode 100644
index 0000000..ebc8773
--- /dev/null
+++ b/src/csapi/typing.hpp
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Informs the server that the user has started or stopped typing.
+ *
+ * This tells the server that the user is typing for the next N
+ * milliseconds where N is the value specified in the ``timeout`` key.
+ * Alternatively, if ``typing`` is ``false``, it tells the server that the
+ * user has stopped typing.
+ */
+class SetTypingJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /*! \brief Informs the server that the user has started or stopped typing.
+ *
+ * \param userId
+ * The user who has started to type.
+ *
+ * \param roomId
+ * The room in which the user is typing.
+ *
+ * \param typing
+ * Whether the user is typing or not. If ``false``, the ``timeout``
+ * key can be omitted.
+ *
+ * \param timeout
+ * The length of time in milliseconds to mark this user as typing.
+ */
+ explicit SetTypingJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string userId , std::string roomId , bool typing , std::optional<int> timeout = std::nullopt);
+
+
+
+
+ static BaseJob::Body buildBody(std::string userId, std::string roomId, bool typing, std::optional<int> timeout);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/users.cpp b/src/csapi/users.cpp
new file mode 100644
index 0000000..e14a32e
--- /dev/null
+++ b/src/csapi/users.cpp
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "users.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body SearchUserDirectoryJob::buildBody(std::string searchTerm, std::optional<int> limit)
+ {
+ // ignore unused param
+ (void)(searchTerm);(void)(limit);
+
+ json _data
+ ;
+
+ _data["search_term"s] = searchTerm;
+
+
+ addToJsonIfNeeded(_data, "limit"s, limit);
+ return BaseJob::JsonBody(_data);
+
+
+ };
+
+SearchUserDirectoryJob::SearchUserDirectoryJob(
+ std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string searchTerm, std::optional<int> limit)
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/user_directory/search",
+ POST,
+ _accessToken,
+ ReturnType::Json,
+ buildBody(searchTerm, limit)
+ )
+ {
+
+
+ //addExpectedKey("results");
+ //addExpectedKey("limited");
+ }
+
+
+
+ immer::array<SearchUserDirectoryJob::User> SearchUserDirectoryJob::results(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("results"s)) {
+ return
+ jsonBody(r).get()["results"s]
+ /*.get<immer::array<User>>()*/;}
+ else { return immer::array<User>( );}
+ }
+
+
+ bool SearchUserDirectoryJob::limited(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("limited"s)) {
+ return
+ jsonBody(r).get()["limited"s]
+ /*.get<bool>()*/;}
+ else { return bool( );}
+ }
+
+}
diff --git a/src/csapi/users.hpp b/src/csapi/users.hpp
new file mode 100644
index 0000000..61297e8
--- /dev/null
+++ b/src/csapi/users.hpp
@@ -0,0 +1,105 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Searches the user directory.
+ *
+ * Performs a search for users. The homeserver may
+ * determine which subset of users are searched, however the homeserver
+ * MUST at a minimum consider the users the requesting user shares a
+ * room with and those who reside in public rooms (known to the homeserver).
+ * The search MUST consider local users to the homeserver, and SHOULD
+ * query remote users as part of the search.
+ *
+ * The search is performed case-insensitively on user IDs and display
+ * names preferably using a collation determined based upon the
+ * ``Accept-Language`` header provided in the request, if present.
+ */
+class SearchUserDirectoryJob : public BaseJob {
+public:
+ // Inner data structures
+
+/// Performs a search for users. The homeserver may
+/// determine which subset of users are searched, however the homeserver
+/// MUST at a minimum consider the users the requesting user shares a
+/// room with and those who reside in public rooms (known to the homeserver).
+/// The search MUST consider local users to the homeserver, and SHOULD
+/// query remote users as part of the search.
+///
+/// The search is performed case-insensitively on user IDs and display
+/// names preferably using a collation determined based upon the
+/// ``Accept-Language`` header provided in the request, if present.
+ struct User
+ {
+/// The user's matrix user ID.
+ std::string userId;
+/// The display name of the user, if one exists.
+ std::string displayName;
+/// The avatar url, as an MXC, if one exists.
+ std::string avatarUrl;
+
+ };
+
+
+// Construction/destruction
+
+ /*! \brief Searches the user directory.
+ *
+ * \param searchTerm
+ * The term to search for
+ *
+ * \param limit
+ * The maximum number of results to return. Defaults to 10.
+ */
+ explicit SearchUserDirectoryJob(std::string serverUrl
+ , std::string _accessToken
+ ,
+ std::string searchTerm , std::optional<int> limit = std::nullopt);
+
+
+ // Result properties
+
+
+
+
+/// Ordered by rank and then whether or not profile info is available.
+static immer::array<User> results(Response r);
+
+
+/// Indicates if the result list has been truncated by the limit.
+static bool limited(Response r);
+
+
+
+ static BaseJob::Body buildBody(std::string searchTerm, std::optional<int> limit);
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+ template<>
+ struct adl_serializer<SearchUserDirectoryJob::User> {
+
+ static void from_json(const json &jo, SearchUserDirectoryJob::User& result)
+ {
+
+ result.userId = jo.at("user_id"s);
+ result.displayName = jo.at("display_name"s);
+ result.avatarUrl = jo.at("avatar_url"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/versions.cpp b/src/csapi/versions.cpp
new file mode 100644
index 0000000..a60d6ec
--- /dev/null
+++ b/src/csapi/versions.cpp
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "versions.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body GetVersionsJob::buildBody()
+ {
+ // ignore unused param
+
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetVersionsJob::GetVersionsJob(
+ std::string serverUrl
+
+
+ )
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client") + "/versions",
+ GET,
+ {} ,
+ ReturnType::Json,
+ buildBody()
+ )
+ {
+
+
+ //addExpectedKey("versions");
+ }
+
+
+
+ immer::array<std::string> GetVersionsJob::versions(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("versions"s)) {
+ return
+ jsonBody(r).get()["versions"s]
+ /*.get<immer::array<std::string>>()*/;}
+ else { return immer::array<std::string>( );}
+ }
+
+
+ immer::map<std::string, bool> GetVersionsJob::unstableFeatures(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("unstable_features"s)) {
+ return
+ jsonBody(r).get()["unstable_features"s]
+ /*.get<immer::map<std::string, bool>>()*/;}
+ else { return immer::map<std::string, bool>( );}
+ }
+
+}
diff --git a/src/csapi/versions.hpp b/src/csapi/versions.hpp
new file mode 100644
index 0000000..661f6df
--- /dev/null
+++ b/src/csapi/versions.hpp
@@ -0,0 +1,76 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Gets the versions of the specification supported by the server.
+ *
+ * Gets the versions of the specification supported by the server.
+ *
+ * Values will take the form ``rX.Y.Z``.
+ *
+ * Only the latest ``Z`` value will be reported for each supported ``X.Y`` value.
+ * i.e. if the server implements ``r0.0.0``, ``r0.0.1``, and ``r1.2.0``, it will report ``r0.0.1`` and ``r1.2.0``.
+ *
+ * The server may additionally advertise experimental features it supports
+ * through ``unstable_features``. These features should be namespaced and
+ * may optionally include version information within their name if desired.
+ * Features listed here are not for optionally toggling parts of the Matrix
+ * specification and should only be used to advertise support for a feature
+ * which has not yet landed in the spec. For example, a feature currently
+ * undergoing the proposal process may appear here and eventually be taken
+ * off this list once the feature lands in the spec and the server deems it
+ * reasonable to do so. Servers may wish to keep advertising features here
+ * after they've been released into the spec to give clients a chance to
+ * upgrade appropriately. Additionally, clients should avoid using unstable
+ * features in their stable releases.
+ */
+class GetVersionsJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /// Gets the versions of the specification supported by the server.
+ explicit GetVersionsJob(std::string serverUrl
+
+
+ );
+
+
+ // Result properties
+
+
+
+
+/// The supported versions.
+static immer::array<std::string> versions(Response r);
+
+
+/// Experimental features the server supports. Features not listed here,
+/// or the lack of this property all together, indicate that a feature is
+/// not supported.
+static immer::map<std::string, bool> unstableFeatures(Response r);
+
+
+
+ static BaseJob::Body buildBody();
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/voip.cpp b/src/csapi/voip.cpp
new file mode 100644
index 0000000..32d9620
--- /dev/null
+++ b/src/csapi/voip.cpp
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "voip.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body GetTurnServerJob::buildBody()
+ {
+ // ignore unused param
+
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetTurnServerJob::GetTurnServerJob(
+ std::string serverUrl
+ , std::string _accessToken
+
+ )
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/voip/turnServer",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody()
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/voip.hpp b/src/csapi/voip.hpp
new file mode 100644
index 0000000..c005980
--- /dev/null
+++ b/src/csapi/voip.hpp
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Obtain TURN server credentials.
+ *
+ * This API provides credentials for the client to use when initiating
+ * calls.
+ */
+class GetTurnServerJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /// Obtain TURN server credentials.
+ explicit GetTurnServerJob(std::string serverUrl
+ , std::string _accessToken
+
+ );
+
+
+ // Result properties
+
+
+/// The TURN server credentials.
+ static JsonWrap data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<JsonWrap>()
+ ;
+ }
+
+
+
+
+ static BaseJob::Body buildBody();
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/wellknown.cpp b/src/csapi/wellknown.cpp
new file mode 100644
index 0000000..8723abe
--- /dev/null
+++ b/src/csapi/wellknown.cpp
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "wellknown.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body GetWellknownJob::buildBody()
+ {
+ // ignore unused param
+
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetWellknownJob::GetWellknownJob(
+ std::string serverUrl
+
+
+ )
+ : BaseJob(std::move(serverUrl),
+ std::string("/.well-known") + "/matrix/client",
+ GET,
+ {} ,
+ ReturnType::Json,
+ buildBody()
+ )
+ {
+
+
+ }
+
+
+}
diff --git a/src/csapi/wellknown.hpp b/src/csapi/wellknown.hpp
new file mode 100644
index 0000000..1d57bd8
--- /dev/null
+++ b/src/csapi/wellknown.hpp
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+#include "csapi/definitions/wellknown/full.hpp"
+
+namespace Kazv {
+
+/*! \brief Gets Matrix server discovery information about the domain.
+ *
+ * Gets discovery information about the domain. The file may include
+ * additional keys, which MUST follow the Java package naming convention,
+ * e.g. ``com.example.myapp.property``. This ensures property names are
+ * suitably namespaced for each application and reduces the risk of
+ * clashes.
+ *
+ * Note that this endpoint is not necessarily handled by the homeserver,
+ * but by another webserver, to be used for discovering the homeserver URL.
+ */
+class GetWellknownJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /// Gets Matrix server discovery information about the domain.
+ explicit GetWellknownJob(std::string serverUrl
+
+
+ );
+
+
+ // Result properties
+
+
+/// Server discovery information.
+ static DiscoveryInformation data(Response r)
+ {
+ return
+
+ std::move(jsonBody(r).get()).get<DiscoveryInformation>()
+ ;
+ }
+
+
+
+
+ static BaseJob::Body buildBody();
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/csapi/whoami.cpp b/src/csapi/whoami.cpp
new file mode 100644
index 0000000..bfefa08
--- /dev/null
+++ b/src/csapi/whoami.cpp
@@ -0,0 +1,51 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "whoami.hpp"
+
+namespace Kazv
+{
+
+
+ BaseJob::Body GetTokenOwnerJob::buildBody()
+ {
+ // ignore unused param
+
+
+
+ return BaseJob::EmptyBody{};
+
+ };
+
+GetTokenOwnerJob::GetTokenOwnerJob(
+ std::string serverUrl
+ , std::string _accessToken
+
+ )
+ : BaseJob(std::move(serverUrl),
+ std::string("/_matrix/client/r0") + "/account/whoami",
+ GET,
+ _accessToken,
+ ReturnType::Json,
+ buildBody()
+ )
+ {
+
+
+ //addExpectedKey("user_id");
+ }
+
+
+
+ std::string GetTokenOwnerJob::userId(Response r)
+ {
+ if (jsonBody(r).get()
+ .contains("user_id"s)) {
+ return
+ jsonBody(r).get()["user_id"s]
+ /*.get<std::string>()*/;}
+ else { return std::string( );}
+ }
+
+}
diff --git a/src/csapi/whoami.hpp b/src/csapi/whoami.hpp
new file mode 100644
index 0000000..1883a5d
--- /dev/null
+++ b/src/csapi/whoami.hpp
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "basejob.hpp"
+
+
+namespace Kazv {
+
+/*! \brief Gets information about the owner of an access token.
+ *
+ * Gets information about the owner of a given access token.
+ *
+ * Note that, as with the rest of the Client-Server API,
+ * Application Services may masquerade as users within their
+ * namespace by giving a ``user_id`` query parameter. In this
+ * situation, the server should verify that the given ``user_id``
+ * is registered by the appservice, and return it in the response
+ * body.
+ */
+class GetTokenOwnerJob : public BaseJob {
+public:
+
+
+// Construction/destruction
+
+ /// Gets information about the owner of an access token.
+ explicit GetTokenOwnerJob(std::string serverUrl
+ , std::string _accessToken
+
+ );
+
+
+ // Result properties
+
+
+
+
+/// The user id that owns the access token.
+static std::string userId(Response r);
+
+
+
+ static BaseJob::Body buildBody();
+ };
+
+ }
+ namespace nlohmann
+ {
+ using namespace Kazv;
+
+ }
+
+ namespace Kazv
+ {
+
+} // namespace Kazv
diff --git a/src/descendent.hpp b/src/descendent.hpp
index 973531d..74620b7 100644
--- a/src/descendent.hpp
+++ b/src/descendent.hpp
@@ -1,46 +1,48 @@
#pragma once
#include <memory>
namespace Kazv
{
template<typename T>
class Descendent
{
struct concept
{
virtual ~concept() = default;
virtual const T *ptr() const = 0;
virtual T *ptr() = 0;
virtual std::unique_ptr<concept> clone() const = 0;
};
template<typename U>
struct model : public concept
{
model(U x) : instance(std::move(x)) {}
const T *ptr() const { return &instance; }
T *ptr() { return &instance; }
// or std::unique_ptr<model<U> >(new model<U>(U(instance))) if you do not have C++14
std::unique_ptr<concept> clone() const { return std::make_unique<model<U> >(U(instance)); }
U instance;
};
std::unique_ptr<concept> m_d;
public:
+ Descendent() : m_d(std::make_unique<model<T>>(T())) {}
+
template<typename U>
Descendent(U x) : m_d(std::make_unique<model<U> >(std::move(x))) {}
Descendent(const Descendent & that) : m_d(std::move(that.m_d->clone())) {}
Descendent(Descendent && that) : m_d(std::move(that.m_d)) {}
Descendent & operator=(const Descendent &that) { Descendent t(that); *this = std::move(t); return *this; }
Descendent & operator=(Descendent && that) { m_d = std::move(that.m_d); return *this; }
const T *data() const { return m_d->ptr(); }
const T *constData() const { return m_d->ptr(); }
T *data() { return m_d->ptr(); }
const T *operator->() const { return m_d->ptr(); }
T *operator->() { return m_d->ptr(); }
};
}
diff --git a/src/identity/definitions/request_email_validation.hpp b/src/identity/definitions/request_email_validation.hpp
new file mode 100644
index 0000000..30bb221
--- /dev/null
+++ b/src/identity/definitions/request_email_validation.hpp
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+
+struct RequestEmailValidation
+{
+
+/// A unique string generated by the client, and used to identify the
+/// validation attempt. It must be a string consisting of the characters
+/// ``[0-9a-zA-Z.=_-]``. Its length must not exceed 255 characters and it
+/// must not be empty.
+ std::string clientSecret;
+
+/// The email address to validate.
+ std::string email;
+
+/// The server will only send an email if the ``send_attempt``
+/// is a number greater than the most recent one which it has seen,
+/// scoped to that ``email`` + ``client_secret`` pair. This is to
+/// avoid repeatedly sending the same email in the case of request
+/// retries between the POSTing user and the identity server.
+/// The client should increment this value if they desire a new
+/// email (e.g. a reminder) to be sent. If they do not, the server
+/// should respond with success but not resend the email.
+ int sendAttempt;
+
+/// Optional. When the validation is completed, the identity server will
+/// redirect the user to this URL. This option is ignored when submitting
+/// 3PID validation information through a POST request.
+ std::string nextLink;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<RequestEmailValidation> {
+ static void to_json(json& jo, const RequestEmailValidation &pod)
+ {
+
+
+ jo["client_secret"s] = pod.clientSecret;
+
+ jo["email"s] = pod.email;
+
+ jo["send_attempt"s] = pod.sendAttempt;
+
+
+ addToJsonIfNeeded(jo, "next_link"s, pod.nextLink);
+ }
+ static void from_json(const json &jo, RequestEmailValidation& result)
+ {
+
+ result.clientSecret = jo.at("client_secret"s);
+ result.email = jo.at("email"s);
+ result.sendAttempt = jo.at("send_attempt"s);
+ result.nextLink = jo.at("next_link"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/identity/definitions/request_msisdn_validation.hpp b/src/identity/definitions/request_msisdn_validation.hpp
new file mode 100644
index 0000000..6a61f44
--- /dev/null
+++ b/src/identity/definitions/request_msisdn_validation.hpp
@@ -0,0 +1,79 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "types.hpp"
+
+
+namespace Kazv {
+
+struct RequestMsisdnValidation
+{
+
+/// A unique string generated by the client, and used to identify the
+/// validation attempt. It must be a string consisting of the characters
+/// ``[0-9a-zA-Z.=_-]``. Its length must not exceed 255 characters and it
+/// must not be empty.
+ std::string clientSecret;
+
+/// The two-letter uppercase ISO-3166-1 alpha-2 country code that the
+/// number in ``phone_number`` should be parsed as if it were dialled from.
+ std::string country;
+
+/// The phone number to validate.
+ std::string phoneNumber;
+
+/// The server will only send an SMS if the ``send_attempt`` is a
+/// number greater than the most recent one which it has seen,
+/// scoped to that ``country`` + ``phone_number`` + ``client_secret``
+/// triple. This is to avoid repeatedly sending the same SMS in
+/// the case of request retries between the POSTing user and the
+/// identity server. The client should increment this value if
+/// they desire a new SMS (e.g. a reminder) to be sent.
+ int sendAttempt;
+
+/// Optional. When the validation is completed, the identity server will
+/// redirect the user to this URL. This option is ignored when submitting
+/// 3PID validation information through a POST request.
+ std::string nextLink;
+};
+
+}
+namespace nlohmann
+{
+using namespace Kazv;
+template<>
+struct adl_serializer<RequestMsisdnValidation> {
+ static void to_json(json& jo, const RequestMsisdnValidation &pod)
+ {
+
+
+ jo["client_secret"s] = pod.clientSecret;
+
+ jo["country"s] = pod.country;
+
+ jo["phone_number"s] = pod.phoneNumber;
+
+ jo["send_attempt"s] = pod.sendAttempt;
+
+
+ addToJsonIfNeeded(jo, "next_link"s, pod.nextLink);
+ }
+ static void from_json(const json &jo, RequestMsisdnValidation& result)
+ {
+
+ result.clientSecret = jo.at("client_secret"s);
+ result.country = jo.at("country"s);
+ result.phoneNumber = jo.at("phone_number"s);
+ result.sendAttempt = jo.at("send_attempt"s);
+ result.nextLink = jo.at("next_link"s);
+
+ }
+};
+ }
+
+ namespace Kazv
+ {
+} // namespace Kazv
diff --git a/src/types.hpp b/src/types.hpp
index be01609..45e8297 100644
--- a/src/types.hpp
+++ b/src/types.hpp
@@ -1,68 +1,178 @@
#pragma once
#include <string>
+#include <variant>
#include <nlohmann/json.hpp>
#include <immer/array.hpp>
+#include <immer/map.hpp>
+#include <boost/hana/type.hpp>
+#include <lager/util.hpp>
+
+#include "descendent.hpp"
namespace Kazv
{
using json = nlohmann::json;
using Bytes = std::string;
enum Status : bool
{
FAIL,
SUCC,
};
class JsonWrap
{
// Cannot use box here, because it causes the resulting json
// to be wrapped into an array.
// https://github.com/arximboldi/immer/issues/155
immer::array<json> m_d;
public:
+ JsonWrap() = default;
JsonWrap(json&& j) : m_d(1, std::move(j)) {}
JsonWrap(const json& j) : m_d(1, j) {}
auto get() const { return m_d.at(0); }
+ operator json() const { return m_d.at(0); }
};
- template<class T,
- std::enable_if_t<std::is_same_v<decltype(std::declval<T>().empty()), bool>,
- int> = 0>
- inline void addToJsonIfNeeded(json &j, std::string name, T &&arg)
+ namespace detail
{
- if (! arg.empty()) {
- j[name] = std::forward<T>(arg);
- }
- };
+ auto hasEmptyMethod = boost::hana::is_valid(
+ [](auto &&x) -> decltype((void)x.empty()) {});
+ template<class U>
+ struct AddToJsonIfNeededT
+ {
+ template<class T>
+ static void call(json &j, std::string name, T &&arg) {
+ if constexpr (detail::hasEmptyMethod(arg)) {
+ if (! arg.empty()) {
+ j[name] = std::forward<T>(arg);
+ }
+ } else {
+ j[name] = std::forward<T>(arg);
+ }
+ }
+ };
- template<class T>
- inline void addToJsonIfNeeded(json &j, std::string name, T &&arg)
- {
- j[name] = std::forward<T>(arg);
- };
+ template<class U>
+ struct AddToJsonIfNeededT<std::optional<U>>
+ {
+ template<class T>
+ static void call(json &j, std::string name, T &&arg) {
+ if (arg.has_value()) {
+ j[name] = std::forward<T>(arg).value();
+ }
+ }
+ };
+
+ }
template<class T>
- inline void addToJsonIfNeeded(json &j, std::string name, std::optional<T> &&arg)
+ inline void addToJsonIfNeeded(json &j, std::string name, T &&arg)
{
- if (arg.has_value()) {
- j[name] = std::forward<T>(arg).value();
- }
+ detail::AddToJsonIfNeededT<std::decay_t<T>>::call(j, name, std::forward<T>(arg));
};
// Provide a non-destructive way to add the map
// to json.
- template<class MapT>
+ template<class MapT,
+ // disallow json object here
+ std::enable_if_t<!std::is_same_v<std::decay_t<MapT>, json>
+ && !std::is_same_v<std::decay_t<MapT>, JsonWrap>, int> = 0>
inline void addPropertyMapToJson(json &j, MapT &&arg)
{
for (auto kv : std::forward<MapT>(arg)) {
auto [k, v] = kv;
j[k] = v;
}
};
+ inline void addPropertyMapToJson(json &j, const json &arg)
+ {
+ for (auto kv : arg.items()) {
+ auto [k, v] = kv;
+ j[k] = v;
+ }
+ };
+ using EventList = immer::array<JsonWrap>;
+
using namespace std::string_literals;
+
+ struct Null {};
+ using Variant = std::variant<std::string, JsonWrap, Null>;
+}
+
+namespace nlohmann {
+ template <class T, class V>
+ struct adl_serializer<immer::map<T, V>> {
+ static void to_json(json& j, immer::map<T, V> map) {
+ for (auto [k, v] : map) {
+ j[k] = v;
+ }
+ }
+
+ static void from_json(const json& j, immer::map<T, V> &m) {
+ immer::map<T, V> ret;
+ if (j.is_object()) {
+ for (const auto &[k, v] : j.items()) {
+ ret = std::move(ret).set(k, v);
+ }
+ }
+ m = ret;
+ }
+ };
+
+ template <class T>
+ struct adl_serializer<immer::array<T>> {
+ static void to_json(json& j, immer::array<T> arr) {
+ for (auto i : arr) {
+ j.push_back(i);
+ }
+ }
+
+ static void from_json(const json& j, immer::array<T> &a) {
+ immer::array<T> ret;
+ if (j.is_object()) {
+ for (const auto &i : j) {
+ ret = std::move(ret).push_back(i);
+ }
+ }
+ a = ret;
+ }
+ };
+
+ template <>
+ struct adl_serializer<Kazv::JsonWrap> {
+ static void to_json(json& j, Kazv::JsonWrap w) {
+ j = w.get();
+ }
+
+ static void from_json(const json& j, Kazv::JsonWrap &w) {
+ w = Kazv::JsonWrap(j);
+ }
+ };
+
+ template <>
+ struct adl_serializer<Kazv::Variant> {
+ static void to_json(json& j, const Kazv::Variant &var) {
+ std::visit(lager::visitor{
+ [&j](std::string i) { j = i; },
+ [&j](Kazv::JsonWrap i) { j = i; },
+ [&j](Kazv::Null) { j = nullptr; }
+ }, var);
+ }
+
+ static void from_json(const json& j, Kazv::Variant &var) {
+ if (j.is_string()) {
+ var = j.get<std::string>();
+ } else if (j.is_null()) {
+ var = Kazv::Null{};
+ } else { // is object
+ var = Kazv::Variant(Kazv::JsonWrap(j));
+ }
+ }
+ };
+
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Nov 2, 9:55 AM (1 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1804340
Default Alt Text
(536 KB)

Event Timeline