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

namespace nymea::api {

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

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

} // namespace nymea::api
