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

namespace nymea::api {

ConfigurationUploadAndRestoreBackupResponse ConfigurationUploadAndRestoreBackupResponse::fromJson(const QJsonObject &object) {
    ConfigurationUploadAndRestoreBackupResponse value;
    if (object.contains(QStringLiteral("configurationError"))) {
        value.configurationError = parseConfigurationError(object.value(QStringLiteral("configurationError")));
    }
    if (object.contains(QStringLiteral("fileName"))) {
        value.fileName = (object.value(QStringLiteral("fileName"))).toString();
    }
    if (object.contains(QStringLiteral("size"))) {
        value.size = jsonValueToInteger(object.value(QStringLiteral("size")));
    }
    if (object.contains(QStringLiteral("transferId"))) {
        value.transferId = (object.value(QStringLiteral("transferId"))).toString();
    }
    if (object.contains(QStringLiteral("transferToken"))) {
        value.transferToken = (object.value(QStringLiteral("transferToken"))).toString();
    }
    return value;
}

QJsonObject ConfigurationUploadAndRestoreBackupResponse::toJson() const {
    QJsonObject object;
    object.insert(QStringLiteral("configurationError"), QJsonValue(toString(configurationError)));
    if (fileName.has_value()) {
        object.insert(QStringLiteral("fileName"), QJsonValue(*fileName));
    }
    if (size.has_value()) {
        object.insert(QStringLiteral("size"), QJsonValue(static_cast<qint64>(*size)));
    }
    if (transferId.has_value()) {
        object.insert(QStringLiteral("transferId"), QJsonValue(*transferId));
    }
    if (transferToken.has_value()) {
        object.insert(QStringLiteral("transferToken"), QJsonValue(*transferToken));
    }
    return object;
}

} // namespace nymea::api
