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

namespace nymea::api {

SystemSetTimeParams SystemSetTimeParams::fromJson(const QJsonObject &object) {
    SystemSetTimeParams value;
    if (object.contains(QStringLiteral("automaticTime"))) {
        value.automaticTime = (object.value(QStringLiteral("automaticTime"))).toBool();
    }
    if (object.contains(QStringLiteral("time"))) {
        value.time = jsonValueToUnsignedInteger(object.value(QStringLiteral("time")));
    }
    if (object.contains(QStringLiteral("timeZone"))) {
        value.timeZone = (object.value(QStringLiteral("timeZone"))).toString();
    }
    return value;
}

QJsonObject SystemSetTimeParams::toJson() const {
    QJsonObject object;
    if (automaticTime.has_value()) {
        object.insert(QStringLiteral("automaticTime"), QJsonValue(*automaticTime));
    }
    if (time.has_value()) {
        object.insert(QStringLiteral("time"), QJsonValue(static_cast<qint64>(*time)));
    }
    if (timeZone.has_value()) {
        object.insert(QStringLiteral("timeZone"), QJsonValue(*timeZone));
    }
    return object;
}

} // namespace nymea::api
