/**
 * 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 "petstatus.h"
#include "qoaihelpers.h"

using namespace Qt::StringLiterals;
using namespace QtOpenApiCommon;

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

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

PetStatus::~PetStatus()
{
}

void PetStatus::initializeModel()
{
    m_valueIsSet = false;
    m_valueIsValid = false;
    m_value = ePetStatus::INVALID_VALUE_OPENAPI_GENERATED;
}

void PetStatus::fromJson(const QString &jsonString)
{
    if (jsonString.compare(u"available"_s, Qt::CaseInsensitive) == 0) {
        m_value = ePetStatus::AVAILABLE;
        m_valueIsSet = m_valueIsValid = true;
    }
    else if (jsonString.compare(u"pending"_s, Qt::CaseInsensitive) == 0) {
        m_value = ePetStatus::PENDING;
        m_valueIsSet = m_valueIsValid = true;
    }
    else if (jsonString.compare(u"sold"_s, Qt::CaseInsensitive) == 0) {
        m_value = ePetStatus::SOLD;
        m_valueIsSet = m_valueIsValid = true;
    } else {
        m_value = ePetStatus::INVALID_VALUE_OPENAPI_GENERATED;
        m_valueIsSet = m_valueIsValid = false;
    }
}

void PetStatus::fromJsonValue(const QJsonValue &json)
{
    fromJson(json.toString());
}

QString PetStatus::asJson() const
{
    QString val;
    switch (m_value) {
        case ePetStatus::AVAILABLE:
            val = u"available"_s;
            break;
        case ePetStatus::PENDING:
            val = u"pending"_s;
            break;
        case ePetStatus::SOLD:
            val = u"sold"_s;
            break;
        default:
            break;
    }
    return val;
}

QJsonValue PetStatus::asJsonValue() const
{
    return QJsonValue(asJson());
}

PetStatus::ePetStatus PetStatus::getValue() const
{
    return m_value;
}

void PetStatus::setValue(PetStatus::ePetStatus value)
{
    m_value = value;
    m_valueIsSet = true;
    m_valueIsValid = true;
}
bool PetStatus::isSet() const
{
    return m_valueIsSet;
}

bool PetStatus::isValid() const
{
    return m_valueIsValid;
}

} // namespace QtOpenAPI
