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

namespace nymea::api {

ZigbeeRoutingTableRecord ZigbeeRoutingTableRecord::fromJson(const QJsonObject &object) {
    ZigbeeRoutingTableRecord value;
    if (object.contains(QStringLiteral("destinationAddress"))) {
        value.destinationAddress = jsonValueToUnsignedInteger(object.value(QStringLiteral("destinationAddress")));
    }
    if (object.contains(QStringLiteral("manyToOne"))) {
        value.manyToOne = (object.value(QStringLiteral("manyToOne"))).toBool();
    }
    if (object.contains(QStringLiteral("memoryConstrained"))) {
        value.memoryConstrained = (object.value(QStringLiteral("memoryConstrained"))).toBool();
    }
    if (object.contains(QStringLiteral("nextHopAddress"))) {
        value.nextHopAddress = jsonValueToUnsignedInteger(object.value(QStringLiteral("nextHopAddress")));
    }
    if (object.contains(QStringLiteral("status"))) {
        value.status = parseZigbeeNodeRouteStatus(object.value(QStringLiteral("status")));
    }
    return value;
}

QJsonObject ZigbeeRoutingTableRecord::toJson() const {
    QJsonObject object;
    object.insert(QStringLiteral("destinationAddress"), QJsonValue(static_cast<qint64>(destinationAddress)));
    object.insert(QStringLiteral("manyToOne"), QJsonValue(manyToOne));
    object.insert(QStringLiteral("memoryConstrained"), QJsonValue(memoryConstrained));
    object.insert(QStringLiteral("nextHopAddress"), QJsonValue(static_cast<qint64>(nextHopAddress)));
    object.insert(QStringLiteral("status"), QJsonValue(toString(status)));
    return object;
}

} // namespace nymea::api
