// 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 "zwavenetwork.h"

namespace nymea::api {

ZWaveNetwork ZWaveNetwork::fromJson(const QJsonObject &object) {
    ZWaveNetwork value;
    if (object.contains(QStringLiteral("homeId"))) {
        value.homeId = jsonValueToUnsignedInteger(object.value(QStringLiteral("homeId")));
    }
    if (object.contains(QStringLiteral("isBridgeController"))) {
        value.isBridgeController = (object.value(QStringLiteral("isBridgeController"))).toBool();
    }
    if (object.contains(QStringLiteral("isPrimaryController"))) {
        value.isPrimaryController = (object.value(QStringLiteral("isPrimaryController"))).toBool();
    }
    if (object.contains(QStringLiteral("isStaticUpdateController"))) {
        value.isStaticUpdateController = (object.value(QStringLiteral("isStaticUpdateController"))).toBool();
    }
    if (object.contains(QStringLiteral("isZWavePlus"))) {
        value.isZWavePlus = (object.value(QStringLiteral("isZWavePlus"))).toBool();
    }
    if (object.contains(QStringLiteral("networkState"))) {
        value.networkState = parseZWaveNetworkState(object.value(QStringLiteral("networkState")));
    }
    if (object.contains(QStringLiteral("networkUuid"))) {
        value.networkUuid = QUuid((object.value(QStringLiteral("networkUuid"))).toString());
    }
    if (object.contains(QStringLiteral("serialPort"))) {
        value.serialPort = (object.value(QStringLiteral("serialPort"))).toString();
    }
    if (object.contains(QStringLiteral("waitingForNodeAddition"))) {
        value.waitingForNodeAddition = (object.value(QStringLiteral("waitingForNodeAddition"))).toBool();
    }
    if (object.contains(QStringLiteral("waitingForNodeRemoval"))) {
        value.waitingForNodeRemoval = (object.value(QStringLiteral("waitingForNodeRemoval"))).toBool();
    }
    return value;
}

QJsonObject ZWaveNetwork::toJson() const {
    QJsonObject object;
    object.insert(QStringLiteral("homeId"), QJsonValue(static_cast<qint64>(homeId)));
    object.insert(QStringLiteral("isBridgeController"), QJsonValue(isBridgeController));
    object.insert(QStringLiteral("isPrimaryController"), QJsonValue(isPrimaryController));
    object.insert(QStringLiteral("isStaticUpdateController"), QJsonValue(isStaticUpdateController));
    object.insert(QStringLiteral("isZWavePlus"), QJsonValue(isZWavePlus));
    object.insert(QStringLiteral("networkState"), QJsonValue(toString(networkState)));
    object.insert(QStringLiteral("networkUuid"), QJsonValue((networkUuid).toString()));
    object.insert(QStringLiteral("serialPort"), QJsonValue(serialPort));
    object.insert(QStringLiteral("waitingForNodeAddition"), QJsonValue(waitingForNodeAddition));
    object.insert(QStringLiteral("waitingForNodeRemoval"), QJsonValue(waitingForNodeRemoval));
    return object;
}

} // namespace nymea::api
