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

namespace nymea::api {

RuleActionParam RuleActionParam::fromJson(const QJsonObject &object) {
    RuleActionParam value;
    if (object.contains(QStringLiteral("eventParamTypeId"))) {
        value.eventParamTypeId = QUuid((object.value(QStringLiteral("eventParamTypeId"))).toString());
    }
    if (object.contains(QStringLiteral("eventTypeId"))) {
        value.eventTypeId = QUuid((object.value(QStringLiteral("eventTypeId"))).toString());
    }
    if (object.contains(QStringLiteral("paramName"))) {
        value.paramName = (object.value(QStringLiteral("paramName"))).toString();
    }
    if (object.contains(QStringLiteral("paramTypeId"))) {
        value.paramTypeId = QUuid((object.value(QStringLiteral("paramTypeId"))).toString());
    }
    if (object.contains(QStringLiteral("stateThingId"))) {
        value.stateThingId = QUuid((object.value(QStringLiteral("stateThingId"))).toString());
    }
    if (object.contains(QStringLiteral("stateTypeId"))) {
        value.stateTypeId = QUuid((object.value(QStringLiteral("stateTypeId"))).toString());
    }
    if (object.contains(QStringLiteral("value"))) {
        value.value = object.value(QStringLiteral("value"));
    }
    return value;
}

QJsonObject RuleActionParam::toJson() const {
    QJsonObject object;
    if (eventParamTypeId.has_value()) {
        object.insert(QStringLiteral("eventParamTypeId"), QJsonValue((*eventParamTypeId).toString()));
    }
    if (eventTypeId.has_value()) {
        object.insert(QStringLiteral("eventTypeId"), QJsonValue((*eventTypeId).toString()));
    }
    if (paramName.has_value()) {
        object.insert(QStringLiteral("paramName"), QJsonValue(*paramName));
    }
    if (paramTypeId.has_value()) {
        object.insert(QStringLiteral("paramTypeId"), QJsonValue((*paramTypeId).toString()));
    }
    if (stateThingId.has_value()) {
        object.insert(QStringLiteral("stateThingId"), QJsonValue((*stateThingId).toString()));
    }
    if (stateTypeId.has_value()) {
        object.insert(QStringLiteral("stateTypeId"), QJsonValue((*stateTypeId).toString()));
    }
    if (value.has_value()) {
        object.insert(QStringLiteral("value"), *value);
    }
    return object;
}

} // namespace nymea::api
