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

namespace nymea::api {

ZigbeeGetNodesResponse ZigbeeGetNodesResponse::fromJson(const QJsonObject &object) {
    ZigbeeGetNodesResponse value;
    if (object.contains(QStringLiteral("zigbeeNodes"))) {
        value.zigbeeNodes = ([&]() { QList<ZigbeeNode> list; for (const QJsonValue &item : (object.value(QStringLiteral("zigbeeNodes"))).toArray()) { list.append(ZigbeeNode::fromJson((item).toObject())); } return list; }());
    }
    if (object.contains(QStringLiteral("zigbeeError"))) {
        value.zigbeeError = parseZigbeeError(object.value(QStringLiteral("zigbeeError")));
    }
    return value;
}

QJsonObject ZigbeeGetNodesResponse::toJson() const {
    QJsonObject object;
    if (zigbeeNodes.has_value()) {
        object.insert(QStringLiteral("zigbeeNodes"), ([&]() { QJsonArray array; for (const auto &item : *zigbeeNodes) { array.append(QJsonValue((item).toJson())); } return QJsonValue(array); }()));
    }
    object.insert(QStringLiteral("zigbeeError"), QJsonValue(toString(zigbeeError)));
    return object;
}

} // namespace nymea::api
