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

namespace nymea::api {

ZigbeeSetPermitJoinParams ZigbeeSetPermitJoinParams::fromJson(const QJsonObject &object) {
    ZigbeeSetPermitJoinParams value;
    if (object.contains(QStringLiteral("duration"))) {
        value.duration = jsonValueToUnsignedInteger(object.value(QStringLiteral("duration")));
    }
    if (object.contains(QStringLiteral("networkUuid"))) {
        value.networkUuid = QUuid((object.value(QStringLiteral("networkUuid"))).toString());
    }
    if (object.contains(QStringLiteral("shortAddress"))) {
        value.shortAddress = jsonValueToUnsignedInteger(object.value(QStringLiteral("shortAddress")));
    }
    return value;
}

QJsonObject ZigbeeSetPermitJoinParams::toJson() const {
    QJsonObject object;
    object.insert(QStringLiteral("duration"), QJsonValue(static_cast<qint64>(duration)));
    object.insert(QStringLiteral("networkUuid"), QJsonValue((networkUuid).toString()));
    if (shortAddress.has_value()) {
        object.insert(QStringLiteral("shortAddress"), QJsonValue(static_cast<qint64>(*shortAddress)));
    }
    return object;
}

} // namespace nymea::api
