/****************************************************************************** * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN */ #include "admin.h" #include "converters.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& _json = jv.toObject(); GetWhoIsJob::ConnectionInfo result; result.ip = fromJson(_json.value("ip")); result.lastSeen = fromJson(_json.value("last_seen")); result.userAgent = fromJson(_json.value("user_agent")); return result; } }; template <> struct FromJson { GetWhoIsJob::SessionInfo operator()(const QJsonValue& jv) { const auto& _json = jv.toObject(); GetWhoIsJob::SessionInfo result; result.connections = fromJson>(_json.value("connections")); return result; } }; template <> struct FromJson { GetWhoIsJob::DeviceInfo operator()(const QJsonValue& jv) { const auto& _json = jv.toObject(); GetWhoIsJob::DeviceInfo result; result.sessions = fromJson>(_json.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; }