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

namespace nymea::api {

IOConnection IOConnection::fromJson(const QJsonObject &object) {
    IOConnection value;
    if (object.contains(QStringLiteral("id"))) {
        value.id = QUuid((object.value(QStringLiteral("id"))).toString());
    }
    if (object.contains(QStringLiteral("inputStateTypeId"))) {
        value.inputStateTypeId = QUuid((object.value(QStringLiteral("inputStateTypeId"))).toString());
    }
    if (object.contains(QStringLiteral("inputThingId"))) {
        value.inputThingId = QUuid((object.value(QStringLiteral("inputThingId"))).toString());
    }
    if (object.contains(QStringLiteral("inverted"))) {
        value.inverted = (object.value(QStringLiteral("inverted"))).toBool();
    }
    if (object.contains(QStringLiteral("outputStateTypeId"))) {
        value.outputStateTypeId = QUuid((object.value(QStringLiteral("outputStateTypeId"))).toString());
    }
    if (object.contains(QStringLiteral("outputThingId"))) {
        value.outputThingId = QUuid((object.value(QStringLiteral("outputThingId"))).toString());
    }
    return value;
}

QJsonObject IOConnection::toJson() const {
    QJsonObject object;
    object.insert(QStringLiteral("id"), QJsonValue((id).toString()));
    object.insert(QStringLiteral("inputStateTypeId"), QJsonValue((inputStateTypeId).toString()));
    object.insert(QStringLiteral("inputThingId"), QJsonValue((inputThingId).toString()));
    object.insert(QStringLiteral("inverted"), QJsonValue(inverted));
    object.insert(QStringLiteral("outputStateTypeId"), QJsonValue((outputStateTypeId).toString()));
    object.insert(QStringLiteral("outputThingId"), QJsonValue((outputThingId).toString()));
    return object;
}

} // namespace nymea::api
