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

namespace nymea::api {

UsersGetTokensResponse UsersGetTokensResponse::fromJson(const QJsonObject &object) {
    UsersGetTokensResponse value;
    if (object.contains(QStringLiteral("error"))) {
        value.error = parseUserError(object.value(QStringLiteral("error")));
    }
    if (object.contains(QStringLiteral("tokenInfoList"))) {
        value.tokenInfoList = ([&]() { QList<TokenInfo> list; for (const QJsonValue &item : (object.value(QStringLiteral("tokenInfoList"))).toArray()) { list.append(TokenInfo::fromJson((item).toObject())); } return list; }());
    }
    return value;
}

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

} // namespace nymea::api
