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

namespace nymea::api {

IntegrationsStateChangedNotificationParams IntegrationsStateChangedNotificationParams::fromJson(const QJsonObject &object) {
    IntegrationsStateChangedNotificationParams value;
    if (object.contains(QStringLiteral("maxValue"))) {
        value.maxValue = object.value(QStringLiteral("maxValue"));
    }
    if (object.contains(QStringLiteral("minValue"))) {
        value.minValue = object.value(QStringLiteral("minValue"));
    }
    if (object.contains(QStringLiteral("possibleValues"))) {
        value.possibleValues = ([&]() { QList<QJsonValue> list; for (const QJsonValue &item : (object.value(QStringLiteral("possibleValues"))).toArray()) { list.append(item); } return list; }());
    }
    if (object.contains(QStringLiteral("stateTypeId"))) {
        value.stateTypeId = QUuid((object.value(QStringLiteral("stateTypeId"))).toString());
    }
    if (object.contains(QStringLiteral("thingId"))) {
        value.thingId = QUuid((object.value(QStringLiteral("thingId"))).toString());
    }
    if (object.contains(QStringLiteral("value"))) {
        value.value = object.value(QStringLiteral("value"));
    }
    return value;
}

QJsonObject IntegrationsStateChangedNotificationParams::toJson() const {
    QJsonObject object;
    object.insert(QStringLiteral("maxValue"), maxValue);
    object.insert(QStringLiteral("minValue"), minValue);
    object.insert(QStringLiteral("possibleValues"), ([&]() { QJsonArray array; for (const auto &item : possibleValues) { array.append(item); } return QJsonValue(array); }()));
    object.insert(QStringLiteral("stateTypeId"), QJsonValue((stateTypeId).toString()));
    object.insert(QStringLiteral("thingId"), QJsonValue((thingId).toString()));
    object.insert(QStringLiteral("value"), value);
    return object;
}

} // namespace nymea::api
