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

namespace nymea::api {

ZigbeeNeighborTableRecord ZigbeeNeighborTableRecord::fromJson(const QJsonObject &object) {
    ZigbeeNeighborTableRecord value;
    if (object.contains(QStringLiteral("depth"))) {
        value.depth = jsonValueToUnsignedInteger(object.value(QStringLiteral("depth")));
    }
    if (object.contains(QStringLiteral("lqi"))) {
        value.lqi = jsonValueToUnsignedInteger(object.value(QStringLiteral("lqi")));
    }
    if (object.contains(QStringLiteral("networkAddress"))) {
        value.networkAddress = jsonValueToUnsignedInteger(object.value(QStringLiteral("networkAddress")));
    }
    if (object.contains(QStringLiteral("permitJoining"))) {
        value.permitJoining = (object.value(QStringLiteral("permitJoining"))).toBool();
    }
    if (object.contains(QStringLiteral("relationship"))) {
        value.relationship = parseZigbeeNodeRelationship(object.value(QStringLiteral("relationship")));
    }
    return value;
}

QJsonObject ZigbeeNeighborTableRecord::toJson() const {
    QJsonObject object;
    object.insert(QStringLiteral("depth"), QJsonValue(static_cast<qint64>(depth)));
    object.insert(QStringLiteral("lqi"), QJsonValue(static_cast<qint64>(lqi)));
    object.insert(QStringLiteral("networkAddress"), QJsonValue(static_cast<qint64>(networkAddress)));
    object.insert(QStringLiteral("permitJoining"), QJsonValue(permitJoining));
    object.insert(QStringLiteral("relationship"), QJsonValue(toString(relationship)));
    return object;
}

} // namespace nymea::api
