/**
 * Deepin官网
 * deepin的官方网站后台接口
 *
 * The version of the OpenAPI document: 1.0
 * Contact: wurongjie@deepin.org
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

#include "DHHandlers_ClientBBSTokenResponse.h"

#include <QDebug>
#include <QJsonArray>
#include <QJsonDocument>
#include <QObject>

#include "DHHelpers.h"

namespace DeepinHomeAPI {

DHHandlers_ClientBBSTokenResponse::DHHandlers_ClientBBSTokenResponse(QString json) {
    this->initializeModel();
    this->fromJson(json);
}

DHHandlers_ClientBBSTokenResponse::DHHandlers_ClientBBSTokenResponse() {
    this->initializeModel();
}

DHHandlers_ClientBBSTokenResponse::~DHHandlers_ClientBBSTokenResponse() {}

void DHHandlers_ClientBBSTokenResponse::initializeModel() {

    m_access_token_isSet = false;
    m_access_token_isValid = false;

    m_expiry_isSet = false;
    m_expiry_isValid = false;

    m_refresh_token_isSet = false;
    m_refresh_token_isValid = false;

    m_token_type_isSet = false;
    m_token_type_isValid = false;
}

void DHHandlers_ClientBBSTokenResponse::fromJson(QString jsonString) {
    QByteArray array(jsonString.toStdString().c_str());
    QJsonDocument doc = QJsonDocument::fromJson(array);
    QJsonObject jsonObject = doc.object();
    this->fromJsonObject(jsonObject);
}

void DHHandlers_ClientBBSTokenResponse::fromJsonObject(QJsonObject json) {

    m_access_token_isValid = ::DeepinHomeAPI::fromJsonValue(access_token, json[QString("access_token")]);
    m_access_token_isSet = !json[QString("access_token")].isNull() && m_access_token_isValid;

    m_expiry_isValid = ::DeepinHomeAPI::fromJsonValue(expiry, json[QString("expiry")]);
    m_expiry_isSet = !json[QString("expiry")].isNull() && m_expiry_isValid;

    m_refresh_token_isValid = ::DeepinHomeAPI::fromJsonValue(refresh_token, json[QString("refresh_token")]);
    m_refresh_token_isSet = !json[QString("refresh_token")].isNull() && m_refresh_token_isValid;

    m_token_type_isValid = ::DeepinHomeAPI::fromJsonValue(token_type, json[QString("token_type")]);
    m_token_type_isSet = !json[QString("token_type")].isNull() && m_token_type_isValid;
}

QString DHHandlers_ClientBBSTokenResponse::asJson() const {
    QJsonObject obj = this->asJsonObject();
    QJsonDocument doc(obj);
    QByteArray bytes = doc.toJson();
    return QString(bytes);
}

QJsonObject DHHandlers_ClientBBSTokenResponse::asJsonObject() const {
    QJsonObject obj;
    if (m_access_token_isSet) {
        obj.insert(QString("access_token"), ::DeepinHomeAPI::toJsonValue(access_token));
    }
    if (m_expiry_isSet) {
        obj.insert(QString("expiry"), ::DeepinHomeAPI::toJsonValue(expiry));
    }
    if (m_refresh_token_isSet) {
        obj.insert(QString("refresh_token"), ::DeepinHomeAPI::toJsonValue(refresh_token));
    }
    if (m_token_type_isSet) {
        obj.insert(QString("token_type"), ::DeepinHomeAPI::toJsonValue(token_type));
    }
    return obj;
}

QString DHHandlers_ClientBBSTokenResponse::getAccessToken() const {
    return access_token;
}
void DHHandlers_ClientBBSTokenResponse::setAccessToken(const QString &access_token) {
    this->access_token = access_token;
    this->m_access_token_isSet = true;
}

bool DHHandlers_ClientBBSTokenResponse::is_access_token_Set() const{
    return m_access_token_isSet;
}

bool DHHandlers_ClientBBSTokenResponse::is_access_token_Valid() const{
    return m_access_token_isValid;
}

QString DHHandlers_ClientBBSTokenResponse::getExpiry() const {
    return expiry;
}
void DHHandlers_ClientBBSTokenResponse::setExpiry(const QString &expiry) {
    this->expiry = expiry;
    this->m_expiry_isSet = true;
}

bool DHHandlers_ClientBBSTokenResponse::is_expiry_Set() const{
    return m_expiry_isSet;
}

bool DHHandlers_ClientBBSTokenResponse::is_expiry_Valid() const{
    return m_expiry_isValid;
}

QString DHHandlers_ClientBBSTokenResponse::getRefreshToken() const {
    return refresh_token;
}
void DHHandlers_ClientBBSTokenResponse::setRefreshToken(const QString &refresh_token) {
    this->refresh_token = refresh_token;
    this->m_refresh_token_isSet = true;
}

bool DHHandlers_ClientBBSTokenResponse::is_refresh_token_Set() const{
    return m_refresh_token_isSet;
}

bool DHHandlers_ClientBBSTokenResponse::is_refresh_token_Valid() const{
    return m_refresh_token_isValid;
}

QString DHHandlers_ClientBBSTokenResponse::getTokenType() const {
    return token_type;
}
void DHHandlers_ClientBBSTokenResponse::setTokenType(const QString &token_type) {
    this->token_type = token_type;
    this->m_token_type_isSet = true;
}

bool DHHandlers_ClientBBSTokenResponse::is_token_type_Set() const{
    return m_token_type_isSet;
}

bool DHHandlers_ClientBBSTokenResponse::is_token_type_Valid() const{
    return m_token_type_isValid;
}

bool DHHandlers_ClientBBSTokenResponse::isSet() const {
    bool isObjectUpdated = false;
    do {
        if (m_access_token_isSet) {
            isObjectUpdated = true;
            break;
        }

        if (m_expiry_isSet) {
            isObjectUpdated = true;
            break;
        }

        if (m_refresh_token_isSet) {
            isObjectUpdated = true;
            break;
        }

        if (m_token_type_isSet) {
            isObjectUpdated = true;
            break;
        }
    } while (false);
    return isObjectUpdated;
}

bool DHHandlers_ClientBBSTokenResponse::isValid() const {
    // only required properties are required for the object to be considered valid
    return true;
}

} // namespace DeepinHomeAPI
