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

namespace nymea::api {

SystemGetUpdateStatusResponse SystemGetUpdateStatusResponse::fromJson(const QJsonObject &object) {
    SystemGetUpdateStatusResponse value;
    if (object.contains(QStringLiteral("busy"))) {
        value.busy = (object.value(QStringLiteral("busy"))).toBool();
    }
    if (object.contains(QStringLiteral("updateProgress"))) {
        value.updateProgress = jsonValueToInteger(object.value(QStringLiteral("updateProgress")));
    }
    if (object.contains(QStringLiteral("updateRunning"))) {
        value.updateRunning = (object.value(QStringLiteral("updateRunning"))).toBool();
    }
    return value;
}

QJsonObject SystemGetUpdateStatusResponse::toJson() const {
    QJsonObject object;
    object.insert(QStringLiteral("busy"), QJsonValue(busy));
    if (updateProgress.has_value()) {
        object.insert(QStringLiteral("updateProgress"), QJsonValue(static_cast<qint64>(*updateProgress)));
    }
    object.insert(QStringLiteral("updateRunning"), QJsonValue(updateRunning));
    return object;
}

} // namespace nymea::api
