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

namespace nymea::api {

NetworkManagerGetWirelessAccessPointsResponse NetworkManagerGetWirelessAccessPointsResponse::fromJson(const QJsonObject &object) {
    NetworkManagerGetWirelessAccessPointsResponse value;
    if (object.contains(QStringLiteral("networkManagerError"))) {
        value.networkManagerError = parseNetworkManagerError(object.value(QStringLiteral("networkManagerError")));
    }
    if (object.contains(QStringLiteral("wirelessAccessPoints"))) {
        value.wirelessAccessPoints = ([&]() { QList<WirelessAccessPoint> list; for (const QJsonValue &item : (object.value(QStringLiteral("wirelessAccessPoints"))).toArray()) { list.append(WirelessAccessPoint::fromJson((item).toObject())); } return list; }());
    }
    return value;
}

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

} // namespace nymea::api
