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

namespace nymea::api {

TagsGetTagsResponse TagsGetTagsResponse::fromJson(const QJsonObject &object) {
    TagsGetTagsResponse value;
    if (object.contains(QStringLiteral("tags"))) {
        value.tags = ([&]() { QList<Tag> list; for (const QJsonValue &item : (object.value(QStringLiteral("tags"))).toArray()) { list.append(Tag::fromJson((item).toObject())); } return list; }());
    }
    if (object.contains(QStringLiteral("tagError"))) {
        value.tagError = parseTagError(object.value(QStringLiteral("tagError")));
    }
    return value;
}

QJsonObject TagsGetTagsResponse::toJson() const {
    QJsonObject object;
    if (tags.has_value()) {
        object.insert(QStringLiteral("tags"), ([&]() { QJsonArray array; for (const auto &item : *tags) { array.append(QJsonValue((item).toJson())); } return QJsonValue(array); }()));
    }
    object.insert(QStringLiteral("tagError"), QJsonValue(toString(tagError)));
    return object;
}

} // namespace nymea::api
