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

namespace nymea::api {

LoggingGetLogEntriesResponse LoggingGetLogEntriesResponse::fromJson(const QJsonObject &object) {
    LoggingGetLogEntriesResponse value;
    if (object.contains(QStringLiteral("count"))) {
        value.count = jsonValueToInteger(object.value(QStringLiteral("count")));
    }
    if (object.contains(QStringLiteral("logEntries"))) {
        value.logEntries = ([&]() { QList<LogEntry> list; for (const QJsonValue &item : (object.value(QStringLiteral("logEntries"))).toArray()) { list.append(LogEntry::fromJson((item).toObject())); } return list; }());
    }
    if (object.contains(QStringLiteral("offset"))) {
        value.offset = jsonValueToInteger(object.value(QStringLiteral("offset")));
    }
    return value;
}

QJsonObject LoggingGetLogEntriesResponse::toJson() const {
    QJsonObject object;
    object.insert(QStringLiteral("count"), QJsonValue(static_cast<qint64>(count)));
    if (logEntries.has_value()) {
        object.insert(QStringLiteral("logEntries"), ([&]() { QJsonArray array; for (const auto &item : *logEntries) { array.append(QJsonValue((item).toJson())); } return QJsonValue(array); }()));
    }
    object.insert(QStringLiteral("offset"), QJsonValue(static_cast<qint64>(offset)));
    return object;
}

} // namespace nymea::api
