/**
 * OpenAPI Generated Petstore Client
 *
 * This is a sample of Petstore application.
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

#include "apiresponse.h"
#include "qoaihelpers.h"

using namespace Qt::StringLiterals;
using namespace QtOpenApiCommon;

namespace QtOpenAPI {
ApiResponse::ApiResponse(const QString &json)
{
    this->initializeModel();
    this->fromJson(json);
}

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

ApiResponse::~ApiResponse()
{
}

void ApiResponse::initializeModel()
{
    m_code = {};
    m_codeIsSet = false;
    // If value isn't set AND isn't required
    // it's counted as valid
    m_codeIsValid = !false;

    m_type = {};
    m_typeIsSet = false;
    // If value isn't set AND isn't required
    // it's counted as valid
    m_typeIsValid = !false;

    m_message = {};
    m_messageIsSet = false;
    // If value isn't set AND isn't required
    // it's counted as valid
    m_messageIsValid = !false;
}

void ApiResponse::fromJson(const QString &jsonString)
{
    this->fromJsonValue(QJsonValue::fromJson(jsonString.toUtf8()));
}

void ApiResponse::fromJsonValue(const QJsonValue &json)
{
    Q_UNUSED(json);
    if (!json.isObject() || json.toObject().isEmpty()) {
        initializeModel();
        return;
    }
    const QJsonObject jsonObject = json.toObject();
    {
        const bool result = ::QtOpenApiCommon::fromJsonValue(m_code, jsonObject[u"code"_s]);
        if (result) {
            m_codeIsValid = m_codeIsSet = result;
        } else {
            m_codeIsValid = !false;
            m_codeIsSet = result;
        }
    }
    {
        const bool result = ::QtOpenApiCommon::fromJsonValue(m_type, jsonObject[u"type"_s]);
        if (result) {
            m_typeIsValid = m_typeIsSet = result;
        } else {
            m_typeIsValid = !false;
            m_typeIsSet = result;
        }
    }
    {
        const bool result = ::QtOpenApiCommon::fromJsonValue(m_message, jsonObject[u"message"_s]);
        if (result) {
            m_messageIsValid = m_messageIsSet = result;
        } else {
            m_messageIsValid = !false;
            m_messageIsSet = result;
        }
    }
}

QString ApiResponse::asJson() const
{
    return QString::fromUtf8(this->asJsonValue().toJson(QJsonDocument::Compact));
}

QJsonValue ApiResponse::asJsonValue() const
{
    QJsonObject obj;
    if (m_codeIsSet) {
        obj.insert(u"code"_s, ::QtOpenApiCommon::toJsonValue(m_code));
    }
    if (m_typeIsSet) {
        obj.insert(u"type"_s, ::QtOpenApiCommon::toJsonValue(m_type));
    }
    if (m_messageIsSet) {
        obj.insert(u"message"_s, ::QtOpenApiCommon::toJsonValue(m_message));
    }
    return obj;
}

qint32 ApiResponse::getCode() const
{
    return m_code;
}

void ApiResponse::setCode(const qint32 &code)
{
    m_code = code;
    m_codeIsValid = true;
    m_codeIsSet = true;
}

bool ApiResponse::isCodeValueSet() const
{
    return m_codeIsSet;
}

bool ApiResponse::isCodeValueValid() const
{
    return m_codeIsValid;
}

QString ApiResponse::getType() const
{
    return m_type;
}

void ApiResponse::setType(const QString &type)
{
    m_type = type;
    m_typeIsValid = true;
    m_typeIsSet = true;
}

bool ApiResponse::isTypeValueSet() const
{
    return m_typeIsSet;
}

bool ApiResponse::isTypeValueValid() const
{
    return m_typeIsValid;
}

QString ApiResponse::getMessage() const
{
    return m_message;
}

void ApiResponse::setMessage(const QString &message)
{
    m_message = message;
    m_messageIsValid = true;
    m_messageIsSet = true;
}

bool ApiResponse::isMessageValueSet() const
{
    return m_messageIsSet;
}

bool ApiResponse::isMessageValueValid() const
{
    return m_messageIsValid;
}

bool ApiResponse::isSet() const
{
    bool isObjectUpdated = false;
    do {
        if (m_codeIsSet) {
            isObjectUpdated = true;
            break;
        }
        if (m_typeIsSet) {
            isObjectUpdated = true;
            break;
        }
        if (m_messageIsSet) {
            isObjectUpdated = true;
            break;
        }
    } while (false);
    return isObjectUpdated;
}

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

} // namespace QtOpenAPI
