From 49022915fde72b83d9f18944c268110b01fa3469 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 4 May 2018 23:04:04 +0900 Subject: New home for the generated code - lib/csapi --- lib/csapi/admin.cpp | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 lib/csapi/admin.cpp (limited to 'lib/csapi/admin.cpp') diff --git a/lib/csapi/admin.cpp b/lib/csapi/admin.cpp new file mode 100644 index 00000000..b325d746 --- /dev/null +++ b/lib/csapi/admin.cpp @@ -0,0 +1,100 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "admin.h" + +#include + +using namespace QMatrixClient; + +static const auto basePath = QStringLiteral("/_matrix/client/r0"); + +namespace QMatrixClient +{ + // Converters + + template <> struct FromJson + { + GetWhoIsJob::ConnectionInfo operator()(const QJsonValue& jv) + { + const auto& o = jv.toObject(); + GetWhoIsJob::ConnectionInfo result; + result.ip = + fromJson(o.value("ip")); + result.lastSeen = + fromJson(o.value("last_seen")); + result.userAgent = + fromJson(o.value("user_agent")); + + return result; + } + }; + + template <> struct FromJson + { + GetWhoIsJob::SessionInfo operator()(const QJsonValue& jv) + { + const auto& o = jv.toObject(); + GetWhoIsJob::SessionInfo result; + result.connections = + fromJson>(o.value("connections")); + + return result; + } + }; + + template <> struct FromJson + { + GetWhoIsJob::DeviceInfo operator()(const QJsonValue& jv) + { + const auto& o = jv.toObject(); + GetWhoIsJob::DeviceInfo result; + result.sessions = + fromJson>(o.value("sessions")); + + return result; + } + }; +} // namespace QMatrixClient + +class GetWhoIsJob::Private +{ + public: + QString userId; + QHash devices; +}; + +QUrl GetWhoIsJob::makeRequestUrl(QUrl baseUrl, const QString& userId) +{ + return BaseJob::makeRequestUrl(std::move(baseUrl), + basePath % "/admin/whois/" % userId); +} + +GetWhoIsJob::GetWhoIsJob(const QString& userId) + : BaseJob(HttpVerb::Get, "GetWhoIsJob", + basePath % "/admin/whois/" % userId) + , d(new Private) +{ +} + +GetWhoIsJob::~GetWhoIsJob() = default; + +const QString& GetWhoIsJob::userId() const +{ + return d->userId; +} + +const QHash& GetWhoIsJob::devices() const +{ + return d->devices; +} + +BaseJob::Status GetWhoIsJob::parseJson(const QJsonDocument& data) +{ + auto json = data.object(); + d->userId = fromJson(json.value("user_id")); + d->devices = fromJson>(json.value("devices")); + return Success; +} + -- cgit v1.2.3