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

namespace nymea::api {

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

QJsonObject IntegrationsExecuteBrowserItemActionParams::toJson() const {
    QJsonObject object;
    object.insert(QStringLiteral("actionTypeId"), QJsonValue((actionTypeId).toString()));
    object.insert(QStringLiteral("itemId"), QJsonValue(itemId));
    if (params.has_value()) {
        object.insert(QStringLiteral("params"), ([&]() { QJsonArray array; for (const auto &item : *params) { array.append(QJsonValue((item).toJson())); } return QJsonValue(array); }()));
    }
    object.insert(QStringLiteral("thingId"), QJsonValue((thingId).toString()));
    return object;
}

} // namespace nymea::api
