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

namespace nymea::api {

ZigbeeNetwork ZigbeeNetwork::fromJson(const QJsonObject &object) {
    ZigbeeNetwork value;
    if (object.contains(QStringLiteral("backend"))) {
        value.backend = (object.value(QStringLiteral("backend"))).toString();
    }
    if (object.contains(QStringLiteral("baudRate"))) {
        value.baudRate = jsonValueToUnsignedInteger(object.value(QStringLiteral("baudRate")));
    }
    if (object.contains(QStringLiteral("channel"))) {
        value.channel = jsonValueToUnsignedInteger(object.value(QStringLiteral("channel")));
    }
    if (object.contains(QStringLiteral("channelMask"))) {
        value.channelMask = jsonValueToUnsignedInteger(object.value(QStringLiteral("channelMask")));
    }
    if (object.contains(QStringLiteral("enabled"))) {
        value.enabled = (object.value(QStringLiteral("enabled"))).toBool();
    }
    if (object.contains(QStringLiteral("firmwareVersion"))) {
        value.firmwareVersion = (object.value(QStringLiteral("firmwareVersion"))).toString();
    }
    if (object.contains(QStringLiteral("macAddress"))) {
        value.macAddress = (object.value(QStringLiteral("macAddress"))).toString();
    }
    if (object.contains(QStringLiteral("networkState"))) {
        value.networkState = parseZigbeeNetworkState(object.value(QStringLiteral("networkState")));
    }
    if (object.contains(QStringLiteral("networkUuid"))) {
        value.networkUuid = QUuid((object.value(QStringLiteral("networkUuid"))).toString());
    }
    if (object.contains(QStringLiteral("panId"))) {
        value.panId = jsonValueToUnsignedInteger(object.value(QStringLiteral("panId")));
    }
    if (object.contains(QStringLiteral("permitJoiningDuration"))) {
        value.permitJoiningDuration = jsonValueToUnsignedInteger(object.value(QStringLiteral("permitJoiningDuration")));
    }
    if (object.contains(QStringLiteral("permitJoiningEnabled"))) {
        value.permitJoiningEnabled = (object.value(QStringLiteral("permitJoiningEnabled"))).toBool();
    }
    if (object.contains(QStringLiteral("permitJoiningRemaining"))) {
        value.permitJoiningRemaining = jsonValueToUnsignedInteger(object.value(QStringLiteral("permitJoiningRemaining")));
    }
    if (object.contains(QStringLiteral("serialPort"))) {
        value.serialPort = (object.value(QStringLiteral("serialPort"))).toString();
    }
    return value;
}

QJsonObject ZigbeeNetwork::toJson() const {
    QJsonObject object;
    object.insert(QStringLiteral("backend"), QJsonValue(backend));
    object.insert(QStringLiteral("baudRate"), QJsonValue(static_cast<qint64>(baudRate)));
    object.insert(QStringLiteral("channel"), QJsonValue(static_cast<qint64>(channel)));
    object.insert(QStringLiteral("channelMask"), QJsonValue(static_cast<qint64>(channelMask)));
    object.insert(QStringLiteral("enabled"), QJsonValue(enabled));
    object.insert(QStringLiteral("firmwareVersion"), QJsonValue(firmwareVersion));
    object.insert(QStringLiteral("macAddress"), QJsonValue(macAddress));
    object.insert(QStringLiteral("networkState"), QJsonValue(toString(networkState)));
    object.insert(QStringLiteral("networkUuid"), QJsonValue((networkUuid).toString()));
    object.insert(QStringLiteral("panId"), QJsonValue(static_cast<qint64>(panId)));
    object.insert(QStringLiteral("permitJoiningDuration"), QJsonValue(static_cast<qint64>(permitJoiningDuration)));
    object.insert(QStringLiteral("permitJoiningEnabled"), QJsonValue(permitJoiningEnabled));
    object.insert(QStringLiteral("permitJoiningRemaining"), QJsonValue(static_cast<qint64>(permitJoiningRemaining)));
    object.insert(QStringLiteral("serialPort"), QJsonValue(serialPort));
    return object;
}

} // namespace nymea::api
