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

namespace nymea::api {

JSONRPCSetNotificationStatusParams JSONRPCSetNotificationStatusParams::fromJson(const QJsonObject &object) {
    JSONRPCSetNotificationStatusParams value;
    if (object.contains(QStringLiteral("enabled"))) {
        value.enabled = (object.value(QStringLiteral("enabled"))).toBool();
    }
    if (object.contains(QStringLiteral("namespaces"))) {
        value.namespaces = ([&]() { QStringList list; for (const QJsonValue &item : (object.value(QStringLiteral("namespaces"))).toArray()) { list.append(item.toString()); } return list; }());
    }
    return value;
}

QJsonObject JSONRPCSetNotificationStatusParams::toJson() const {
    QJsonObject object;
    if (enabled.has_value()) {
        object.insert(QStringLiteral("enabled"), QJsonValue(*enabled));
    }
    if (namespaces.has_value()) {
        object.insert(QStringLiteral("namespaces"), ([&]() { QJsonArray array; for (const QString &item : *namespaces) { array.append(item); } return QJsonValue(array); }()));
    }
    return object;
}

} // namespace nymea::api
