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

namespace nymea::api {

TokenInfo TokenInfo::fromJson(const QJsonObject &object) {
    TokenInfo value;
    if (object.contains(QStringLiteral("creationTime"))) {
        value.creationTime = jsonValueToUnsignedInteger(object.value(QStringLiteral("creationTime")));
    }
    if (object.contains(QStringLiteral("deviceName"))) {
        value.deviceName = (object.value(QStringLiteral("deviceName"))).toString();
    }
    if (object.contains(QStringLiteral("id"))) {
        value.id = QUuid((object.value(QStringLiteral("id"))).toString());
    }
    if (object.contains(QStringLiteral("username"))) {
        value.username = (object.value(QStringLiteral("username"))).toString();
    }
    return value;
}

QJsonObject TokenInfo::toJson() const {
    QJsonObject object;
    object.insert(QStringLiteral("creationTime"), QJsonValue(static_cast<qint64>(creationTime)));
    object.insert(QStringLiteral("deviceName"), QJsonValue(deviceName));
    object.insert(QStringLiteral("id"), QJsonValue((id).toString()));
    object.insert(QStringLiteral("username"), QJsonValue(username));
    return object;
}

} // namespace nymea::api
