// SPDX-License-Identifier: GPL-3.0-or-later

// This file is auto-generated by scripts/generate_nymea_api.py
// Any changes made here will be lost when the files are regenerated.
// Do not edit manually.

#include "zwavenode.h"

namespace nymea::api {

ZWaveNode ZWaveNode::fromJson(const QJsonObject &object) {
    ZWaveNode value;
    if (object.contains(QStringLiteral("deviceType"))) {
        value.deviceType = parseZWaveDeviceType(object.value(QStringLiteral("deviceType")));
    }
    if (object.contains(QStringLiteral("failed"))) {
        value.failed = (object.value(QStringLiteral("failed"))).toBool();
    }
    if (object.contains(QStringLiteral("initialized"))) {
        value.initialized = (object.value(QStringLiteral("initialized"))).toBool();
    }
    if (object.contains(QStringLiteral("isBeamingDevice"))) {
        value.isBeamingDevice = (object.value(QStringLiteral("isBeamingDevice"))).toBool();
    }
    if (object.contains(QStringLiteral("isSecurityDevice"))) {
        value.isSecurityDevice = (object.value(QStringLiteral("isSecurityDevice"))).toBool();
    }
    if (object.contains(QStringLiteral("isZWavePlusDevice"))) {
        value.isZWavePlusDevice = (object.value(QStringLiteral("isZWavePlusDevice"))).toBool();
    }
    if (object.contains(QStringLiteral("linkQuality"))) {
        value.linkQuality = jsonValueToUnsignedInteger(object.value(QStringLiteral("linkQuality")));
    }
    if (object.contains(QStringLiteral("manufacturerId"))) {
        value.manufacturerId = jsonValueToUnsignedInteger(object.value(QStringLiteral("manufacturerId")));
    }
    if (object.contains(QStringLiteral("manufacturerName"))) {
        value.manufacturerName = (object.value(QStringLiteral("manufacturerName"))).toString();
    }
    if (object.contains(QStringLiteral("networkUuid"))) {
        value.networkUuid = QUuid((object.value(QStringLiteral("networkUuid"))).toString());
    }
    if (object.contains(QStringLiteral("nodeId"))) {
        value.nodeId = jsonValueToUnsignedInteger(object.value(QStringLiteral("nodeId")));
    }
    if (object.contains(QStringLiteral("nodeType"))) {
        value.nodeType = parseZWaveNodeType(object.value(QStringLiteral("nodeType")));
    }
    if (object.contains(QStringLiteral("productId"))) {
        value.productId = jsonValueToUnsignedInteger(object.value(QStringLiteral("productId")));
    }
    if (object.contains(QStringLiteral("productName"))) {
        value.productName = (object.value(QStringLiteral("productName"))).toString();
    }
    if (object.contains(QStringLiteral("productType"))) {
        value.productType = jsonValueToUnsignedInteger(object.value(QStringLiteral("productType")));
    }
    if (object.contains(QStringLiteral("reachable"))) {
        value.reachable = (object.value(QStringLiteral("reachable"))).toBool();
    }
    if (object.contains(QStringLiteral("role"))) {
        value.role = parseZWaveNodeRole(object.value(QStringLiteral("role")));
    }
    if (object.contains(QStringLiteral("securityMode"))) {
        value.securityMode = jsonValueToUnsignedInteger(object.value(QStringLiteral("securityMode")));
    }
    if (object.contains(QStringLiteral("sleeping"))) {
        value.sleeping = (object.value(QStringLiteral("sleeping"))).toBool();
    }
    if (object.contains(QStringLiteral("version"))) {
        value.version = (object.value(QStringLiteral("version"))).toString();
    }
    return value;
}

QJsonObject ZWaveNode::toJson() const {
    QJsonObject object;
    object.insert(QStringLiteral("deviceType"), QJsonValue(toString(deviceType)));
    object.insert(QStringLiteral("failed"), QJsonValue(failed));
    object.insert(QStringLiteral("initialized"), QJsonValue(initialized));
    object.insert(QStringLiteral("isBeamingDevice"), QJsonValue(isBeamingDevice));
    object.insert(QStringLiteral("isSecurityDevice"), QJsonValue(isSecurityDevice));
    object.insert(QStringLiteral("isZWavePlusDevice"), QJsonValue(isZWavePlusDevice));
    object.insert(QStringLiteral("linkQuality"), QJsonValue(static_cast<qint64>(linkQuality)));
    object.insert(QStringLiteral("manufacturerId"), QJsonValue(static_cast<qint64>(manufacturerId)));
    object.insert(QStringLiteral("manufacturerName"), QJsonValue(manufacturerName));
    object.insert(QStringLiteral("networkUuid"), QJsonValue((networkUuid).toString()));
    object.insert(QStringLiteral("nodeId"), QJsonValue(static_cast<qint64>(nodeId)));
    object.insert(QStringLiteral("nodeType"), QJsonValue(toString(nodeType)));
    object.insert(QStringLiteral("productId"), QJsonValue(static_cast<qint64>(productId)));
    object.insert(QStringLiteral("productName"), QJsonValue(productName));
    object.insert(QStringLiteral("productType"), QJsonValue(static_cast<qint64>(productType)));
    object.insert(QStringLiteral("reachable"), QJsonValue(reachable));
    object.insert(QStringLiteral("role"), QJsonValue(toString(role)));
    object.insert(QStringLiteral("securityMode"), QJsonValue(static_cast<qint64>(securityMode)));
    object.insert(QStringLiteral("sleeping"), QJsonValue(sleeping));
    object.insert(QStringLiteral("version"), QJsonValue(version));
    return object;
}

} // namespace nymea::api
