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

namespace nymea::api {

IntegrationsGetIOConnectionsResponse IntegrationsGetIOConnectionsResponse::fromJson(const QJsonObject &object) {
    IntegrationsGetIOConnectionsResponse value;
    if (object.contains(QStringLiteral("ioConnections"))) {
        value.ioConnections = ([&]() { QList<IOConnection> list; for (const QJsonValue &item : (object.value(QStringLiteral("ioConnections"))).toArray()) { list.append(IOConnection::fromJson((item).toObject())); } return list; }());
    }
    if (object.contains(QStringLiteral("thingError"))) {
        value.thingError = parseThingError(object.value(QStringLiteral("thingError")));
    }
    return value;
}

QJsonObject IntegrationsGetIOConnectionsResponse::toJson() const {
    QJsonObject object;
    if (ioConnections.has_value()) {
        object.insert(QStringLiteral("ioConnections"), ([&]() { QJsonArray array; for (const auto &item : *ioConnections) { array.append(QJsonValue((item).toJson())); } return QJsonValue(array); }()));
    }
    object.insert(QStringLiteral("thingError"), QJsonValue(toString(thingError)));
    return object;
}

} // namespace nymea::api
