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

using namespace Qt::StringLiterals;
using namespace QtOpenApiCommon;

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

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

Order::~Order()
{
}

void Order::initializeModel()
{
    m_id = {};
    m_idIsSet = false;
    // If value isn't set AND isn't required
    // it's counted as valid
    m_idIsValid = !false;

    m_petId = {};
    m_petIdIsSet = false;
    // If value isn't set AND isn't required
    // it's counted as valid
    m_petIdIsValid = !false;

    m_quantity = {};
    m_quantityIsSet = false;
    // If value isn't set AND isn't required
    // it's counted as valid
    m_quantityIsValid = !false;

    m_shipDate = {};
    m_shipDateIsSet = false;
    // If value isn't set AND isn't required
    // it's counted as valid
    m_shipDateIsValid = !false;

    m_status = {};
    m_statusIsSet = false;
    // If value isn't set AND isn't required
    // it's counted as valid
    m_statusIsValid = !false;

    m_complete = {};
    m_completeIsSet = false;
    // If value isn't set AND isn't required
    // it's counted as valid
    m_completeIsValid = !false;
}

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

void Order::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_id, jsonObject[u"id"_s]);
        if (result) {
            m_idIsValid = m_idIsSet = result;
        } else {
            m_idIsValid = !false;
            m_idIsSet = result;
        }
    }
    {
        const bool result = ::QtOpenApiCommon::fromJsonValue(m_petId, jsonObject[u"petId"_s]);
        if (result) {
            m_petIdIsValid = m_petIdIsSet = result;
        } else {
            m_petIdIsValid = !false;
            m_petIdIsSet = result;
        }
    }
    {
        const bool result = ::QtOpenApiCommon::fromJsonValue(m_quantity, jsonObject[u"quantity"_s]);
        if (result) {
            m_quantityIsValid = m_quantityIsSet = result;
        } else {
            m_quantityIsValid = !false;
            m_quantityIsSet = result;
        }
    }
    {
        const bool result = ::QtOpenApiCommon::fromJsonValue(m_shipDate, jsonObject[u"shipDate"_s]);
        if (result) {
            m_shipDateIsValid = m_shipDateIsSet = result;
        } else {
            m_shipDateIsValid = !false;
            m_shipDateIsSet = result;
        }
    }
    {
        const bool result = ::QtOpenApiCommon::fromJsonValue(m_status, jsonObject[u"status"_s]);
        if (result) {
            m_statusIsValid = m_statusIsSet = result;
        } else {
            m_statusIsValid = !false;
            m_statusIsSet = result;
        }
    }
    {
        const bool result = ::QtOpenApiCommon::fromJsonValue(m_complete, jsonObject[u"complete"_s]);
        if (result) {
            m_completeIsValid = m_completeIsSet = result;
        } else {
            m_completeIsValid = !false;
            m_completeIsSet = result;
        }
    }
}

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

QJsonValue Order::asJsonValue() const
{
    QJsonObject obj;
    if (m_idIsSet) {
        obj.insert(u"id"_s, ::QtOpenApiCommon::toJsonValue(m_id));
    }
    if (m_petIdIsSet) {
        obj.insert(u"petId"_s, ::QtOpenApiCommon::toJsonValue(m_petId));
    }
    if (m_quantityIsSet) {
        obj.insert(u"quantity"_s, ::QtOpenApiCommon::toJsonValue(m_quantity));
    }
    if (m_shipDateIsSet) {
        obj.insert(u"shipDate"_s, ::QtOpenApiCommon::toJsonValue(m_shipDate));
    }
    if (m_statusIsSet) {
        obj.insert(u"status"_s, ::QtOpenApiCommon::toJsonValue(m_status));
    }
    if (m_completeIsSet) {
        obj.insert(u"complete"_s, ::QtOpenApiCommon::toJsonValue(m_complete));
    }
    return obj;
}

qint64 Order::getId() const
{
    return m_id;
}

void Order::setId(const qint64 &id)
{
    m_id = id;
    m_idIsValid = true;
    m_idIsSet = true;
}

bool Order::isIdValueSet() const
{
    return m_idIsSet;
}

bool Order::isIdValueValid() const
{
    return m_idIsValid;
}

qint64 Order::getPetId() const
{
    return m_petId;
}

void Order::setPetId(const qint64 &petId)
{
    m_petId = petId;
    m_petIdIsValid = true;
    m_petIdIsSet = true;
}

bool Order::isPetIdValueSet() const
{
    return m_petIdIsSet;
}

bool Order::isPetIdValueValid() const
{
    return m_petIdIsValid;
}

qint32 Order::getQuantity() const
{
    return m_quantity;
}

void Order::setQuantity(const qint32 &quantity)
{
    m_quantity = quantity;
    m_quantityIsValid = true;
    m_quantityIsSet = true;
}

bool Order::isQuantityValueSet() const
{
    return m_quantityIsSet;
}

bool Order::isQuantityValueValid() const
{
    return m_quantityIsValid;
}

QDateTime Order::getShipDate() const
{
    return m_shipDate;
}

void Order::setShipDate(const QDateTime &shipDate)
{
    m_shipDate = shipDate;
    m_shipDateIsValid = true;
    m_shipDateIsSet = true;
}

bool Order::isShipDateValueSet() const
{
    return m_shipDateIsSet;
}

bool Order::isShipDateValueValid() const
{
    return m_shipDateIsValid;
}

QString Order::getStatus() const
{
    return m_status;
}

void Order::setStatus(const QString &status)
{
    m_status = status;
    m_statusIsValid = true;
    m_statusIsSet = true;
}

bool Order::isStatusValueSet() const
{
    return m_statusIsSet;
}

bool Order::isStatusValueValid() const
{
    return m_statusIsValid;
}

bool Order::isComplete() const
{
    return m_complete;
}

void Order::setComplete(const bool &complete)
{
    m_complete = complete;
    m_completeIsValid = true;
    m_completeIsSet = true;
}

bool Order::isCompleteValueSet() const
{
    return m_completeIsSet;
}

bool Order::isCompleteValueValid() const
{
    return m_completeIsValid;
}

bool Order::isSet() const
{
    bool isObjectUpdated = false;
    do {
        if (m_idIsSet) {
            isObjectUpdated = true;
            break;
        }
        if (m_petIdIsSet) {
            isObjectUpdated = true;
            break;
        }
        if (m_quantityIsSet) {
            isObjectUpdated = true;
            break;
        }
        if (m_shipDateIsSet) {
            isObjectUpdated = true;
            break;
        }
        if (m_statusIsSet) {
            isObjectUpdated = true;
            break;
        }
        if (m_completeIsSet) {
            isObjectUpdated = true;
            break;
        }
    } while (false);
    return isObjectUpdated;
}

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

} // namespace QtOpenAPI
