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

namespace nymea::api {

IntegrationPlugin IntegrationPlugin::fromJson(const QJsonObject &object) {
    IntegrationPlugin value;
    if (object.contains(QStringLiteral("displayName"))) {
        value.displayName = (object.value(QStringLiteral("displayName"))).toString();
    }
    if (object.contains(QStringLiteral("id"))) {
        value.id = QUuid((object.value(QStringLiteral("id"))).toString());
    }
    if (object.contains(QStringLiteral("name"))) {
        value.name = (object.value(QStringLiteral("name"))).toString();
    }
    if (object.contains(QStringLiteral("paramTypes"))) {
        value.paramTypes = ([&]() { QList<ParamType> list; for (const QJsonValue &item : (object.value(QStringLiteral("paramTypes"))).toArray()) { list.append(ParamType::fromJson((item).toObject())); } return list; }());
    }
    return value;
}

QJsonObject IntegrationPlugin::toJson() const {
    QJsonObject object;
    object.insert(QStringLiteral("displayName"), QJsonValue(displayName));
    object.insert(QStringLiteral("id"), QJsonValue((id).toString()));
    object.insert(QStringLiteral("name"), QJsonValue(name));
    object.insert(QStringLiteral("paramTypes"), ([&]() { QJsonArray array; for (const auto &item : paramTypes) { array.append(QJsonValue((item).toJson())); } return QJsonValue(array); }()));
    return object;
}

} // namespace nymea::api
