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

namespace nymea::api {

ZigbeeBindingTableRecord ZigbeeBindingTableRecord::fromJson(const QJsonObject &object) {
    ZigbeeBindingTableRecord value;
    if (object.contains(QStringLiteral("clusterId"))) {
        value.clusterId = jsonValueToUnsignedInteger(object.value(QStringLiteral("clusterId")));
    }
    if (object.contains(QStringLiteral("destinationAddress"))) {
        value.destinationAddress = (object.value(QStringLiteral("destinationAddress"))).toString();
    }
    if (object.contains(QStringLiteral("destinationEndpointId"))) {
        value.destinationEndpointId = jsonValueToUnsignedInteger(object.value(QStringLiteral("destinationEndpointId")));
    }
    if (object.contains(QStringLiteral("destinationGroupAddress"))) {
        value.destinationGroupAddress = jsonValueToUnsignedInteger(object.value(QStringLiteral("destinationGroupAddress")));
    }
    if (object.contains(QStringLiteral("sourceAddress"))) {
        value.sourceAddress = (object.value(QStringLiteral("sourceAddress"))).toString();
    }
    if (object.contains(QStringLiteral("sourceEndpointId"))) {
        value.sourceEndpointId = jsonValueToUnsignedInteger(object.value(QStringLiteral("sourceEndpointId")));
    }
    return value;
}

QJsonObject ZigbeeBindingTableRecord::toJson() const {
    QJsonObject object;
    object.insert(QStringLiteral("clusterId"), QJsonValue(static_cast<qint64>(clusterId)));
    if (destinationAddress.has_value()) {
        object.insert(QStringLiteral("destinationAddress"), QJsonValue(*destinationAddress));
    }
    if (destinationEndpointId.has_value()) {
        object.insert(QStringLiteral("destinationEndpointId"), QJsonValue(static_cast<qint64>(*destinationEndpointId)));
    }
    if (destinationGroupAddress.has_value()) {
        object.insert(QStringLiteral("destinationGroupAddress"), QJsonValue(static_cast<qint64>(*destinationGroupAddress)));
    }
    object.insert(QStringLiteral("sourceAddress"), QJsonValue(sourceAddress));
    object.insert(QStringLiteral("sourceEndpointId"), QJsonValue(static_cast<qint64>(sourceEndpointId)));
    return object;
}

} // namespace nymea::api
