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

namespace nymea::api {

IntegrationsDiscoverThingsParams IntegrationsDiscoverThingsParams::fromJson(const QJsonObject &object) {
    IntegrationsDiscoverThingsParams value;
    if (object.contains(QStringLiteral("discoveryParams"))) {
        value.discoveryParams = ([&]() { QList<Param> list; for (const QJsonValue &item : (object.value(QStringLiteral("discoveryParams"))).toArray()) { list.append(Param::fromJson((item).toObject())); } return list; }());
    }
    if (object.contains(QStringLiteral("thingClassId"))) {
        value.thingClassId = QUuid((object.value(QStringLiteral("thingClassId"))).toString());
    }
    return value;
}

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

} // namespace nymea::api
