diff options
Diffstat (limited to 'lib/csapi/definitions')
-rw-r--r-- | lib/csapi/definitions/client_device.cpp | 34 | ||||
-rw-r--r-- | lib/csapi/definitions/client_device.h | 31 |
2 files changed, 65 insertions, 0 deletions
diff --git a/lib/csapi/definitions/client_device.cpp b/lib/csapi/definitions/client_device.cpp new file mode 100644 index 00000000..60b3617c --- /dev/null +++ b/lib/csapi/definitions/client_device.cpp @@ -0,0 +1,34 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "client_device.h" + +using namespace QMatrixClient; + +QJsonObject QMatrixClient::toJson(const Device& pod) +{ + QJsonObject _json; + addToJson<>(_json, "device_id", pod.deviceId); + addToJson<IfNotEmpty>(_json, "display_name", pod.displayName); + addToJson<IfNotEmpty>(_json, "last_seen_ip", pod.lastSeenIp); + addToJson<IfNotEmpty>(_json, "last_seen_ts", pod.lastSeenTs); + return _json; +} + +Device FromJson<Device>::operator()(const QJsonValue& jv) +{ + const auto& _json = jv.toObject(); + Device result; + result.deviceId = + fromJson<QString>(_json.value("device_id")); + result.displayName = + fromJson<QString>(_json.value("display_name")); + result.lastSeenIp = + fromJson<QString>(_json.value("last_seen_ip")); + result.lastSeenTs = + fromJson<qint64>(_json.value("last_seen_ts")); + + return result; +} + diff --git a/lib/csapi/definitions/client_device.h b/lib/csapi/definitions/client_device.h new file mode 100644 index 00000000..4c09e13c --- /dev/null +++ b/lib/csapi/definitions/client_device.h @@ -0,0 +1,31 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + + +#include "converters.h" + +#include "converters.h" + +namespace QMatrixClient +{ + // Data structures + + struct Device + { + QString deviceId; + QString displayName; + QString lastSeenIp; + Omittable<qint64> lastSeenTs; + }; + + QJsonObject toJson(const Device& pod); + + template <> struct FromJson<Device> + { + Device operator()(const QJsonValue& jv); + }; + +} // namespace QMatrixClient |