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

namespace nymea::api {

NetworkManagerCreateWiredConnectionParams NetworkManagerCreateWiredConnectionParams::fromJson(const QJsonObject &object) {
    NetworkManagerCreateWiredConnectionParams value;
    if (object.contains(QStringLiteral("interface"))) {
        value.interface = (object.value(QStringLiteral("interface"))).toString();
    }
    if (object.contains(QStringLiteral("dns"))) {
        value.dns = (object.value(QStringLiteral("dns"))).toString();
    }
    if (object.contains(QStringLiteral("gateway"))) {
        value.gateway = (object.value(QStringLiteral("gateway"))).toString();
    }
    if (object.contains(QStringLiteral("ip"))) {
        value.ip = (object.value(QStringLiteral("ip"))).toString();
    }
    if (object.contains(QStringLiteral("prefix"))) {
        value.prefix = jsonValueToUnsignedInteger(object.value(QStringLiteral("prefix")));
    }
    if (object.contains(QStringLiteral("type"))) {
        value.type = parseWiredNetworkConnectionType(object.value(QStringLiteral("type")));
    }
    return value;
}

QJsonObject NetworkManagerCreateWiredConnectionParams::toJson() const {
    QJsonObject object;
    object.insert(QStringLiteral("interface"), QJsonValue(interface));
    if (dns.has_value()) {
        object.insert(QStringLiteral("dns"), QJsonValue(*dns));
    }
    if (gateway.has_value()) {
        object.insert(QStringLiteral("gateway"), QJsonValue(*gateway));
    }
    if (ip.has_value()) {
        object.insert(QStringLiteral("ip"), QJsonValue(*ip));
    }
    if (prefix.has_value()) {
        object.insert(QStringLiteral("prefix"), QJsonValue(static_cast<qint64>(*prefix)));
    }
    object.insert(QStringLiteral("type"), QJsonValue(toString(type)));
    return object;
}

} // namespace nymea::api
