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

namespace nymea::api {

ZigbeeAdapter ZigbeeAdapter::fromJson(const QJsonObject &object) {
    ZigbeeAdapter value;
    if (object.contains(QStringLiteral("backend"))) {
        value.backend = (object.value(QStringLiteral("backend"))).toString();
    }
    if (object.contains(QStringLiteral("baudRate"))) {
        value.baudRate = jsonValueToInteger(object.value(QStringLiteral("baudRate")));
    }
    if (object.contains(QStringLiteral("description"))) {
        value.description = (object.value(QStringLiteral("description"))).toString();
    }
    if (object.contains(QStringLiteral("hardwareRecognized"))) {
        value.hardwareRecognized = (object.value(QStringLiteral("hardwareRecognized"))).toBool();
    }
    if (object.contains(QStringLiteral("name"))) {
        value.name = (object.value(QStringLiteral("name"))).toString();
    }
    if (object.contains(QStringLiteral("serialNumber"))) {
        value.serialNumber = (object.value(QStringLiteral("serialNumber"))).toString();
    }
    if (object.contains(QStringLiteral("serialPort"))) {
        value.serialPort = (object.value(QStringLiteral("serialPort"))).toString();
    }
    return value;
}

QJsonObject ZigbeeAdapter::toJson() const {
    QJsonObject object;
    object.insert(QStringLiteral("backend"), QJsonValue(backend));
    object.insert(QStringLiteral("baudRate"), QJsonValue(static_cast<qint64>(baudRate)));
    object.insert(QStringLiteral("description"), QJsonValue(description));
    object.insert(QStringLiteral("hardwareRecognized"), QJsonValue(hardwareRecognized));
    object.insert(QStringLiteral("name"), QJsonValue(name));
    object.insert(QStringLiteral("serialNumber"), QJsonValue(serialNumber));
    object.insert(QStringLiteral("serialPort"), QJsonValue(serialPort));
    return object;
}

} // namespace nymea::api
