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

using namespace Qt::StringLiterals;
using namespace QtOpenApiCommon;

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

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

User::~User()
{
}

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

    m_username = {};
    m_usernameIsSet = false;
    // If value isn't set AND isn't required
    // it's counted as valid
    m_usernameIsValid = !false;

    m_firstName = {};
    m_firstNameIsSet = false;
    // If value isn't set AND isn't required
    // it's counted as valid
    m_firstNameIsValid = !false;

    m_lastName = {};
    m_lastNameIsSet = false;
    // If value isn't set AND isn't required
    // it's counted as valid
    m_lastNameIsValid = !false;

    m_email = {};
    m_emailIsSet = false;
    // If value isn't set AND isn't required
    // it's counted as valid
    m_emailIsValid = !false;

    m_password = {};
    m_passwordIsSet = false;
    // If value isn't set AND isn't required
    // it's counted as valid
    m_passwordIsValid = !false;

    m_phone = {};
    m_phoneIsSet = false;
    // If value isn't set AND isn't required
    // it's counted as valid
    m_phoneIsValid = !false;

    m_userStatus = {};
    m_userStatusIsSet = false;
    // If value isn't set AND isn't required
    // it's counted as valid
    m_userStatusIsValid = !false;
}

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

void User::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_username, jsonObject[u"username"_s]);
        if (result) {
            m_usernameIsValid = m_usernameIsSet = result;
        } else {
            m_usernameIsValid = !false;
            m_usernameIsSet = result;
        }
    }
    {
        const bool result = ::QtOpenApiCommon::fromJsonValue(m_firstName, jsonObject[u"firstName"_s]);
        if (result) {
            m_firstNameIsValid = m_firstNameIsSet = result;
        } else {
            m_firstNameIsValid = !false;
            m_firstNameIsSet = result;
        }
    }
    {
        const bool result = ::QtOpenApiCommon::fromJsonValue(m_lastName, jsonObject[u"lastName"_s]);
        if (result) {
            m_lastNameIsValid = m_lastNameIsSet = result;
        } else {
            m_lastNameIsValid = !false;
            m_lastNameIsSet = result;
        }
    }
    {
        const bool result = ::QtOpenApiCommon::fromJsonValue(m_email, jsonObject[u"email"_s]);
        if (result) {
            m_emailIsValid = m_emailIsSet = result;
        } else {
            m_emailIsValid = !false;
            m_emailIsSet = result;
        }
    }
    {
        const bool result = ::QtOpenApiCommon::fromJsonValue(m_password, jsonObject[u"password"_s]);
        if (result) {
            m_passwordIsValid = m_passwordIsSet = result;
        } else {
            m_passwordIsValid = !false;
            m_passwordIsSet = result;
        }
    }
    {
        const bool result = ::QtOpenApiCommon::fromJsonValue(m_phone, jsonObject[u"phone"_s]);
        if (result) {
            m_phoneIsValid = m_phoneIsSet = result;
        } else {
            m_phoneIsValid = !false;
            m_phoneIsSet = result;
        }
    }
    {
        const bool result = ::QtOpenApiCommon::fromJsonValue(m_userStatus, jsonObject[u"userStatus"_s]);
        if (result) {
            m_userStatusIsValid = m_userStatusIsSet = result;
        } else {
            m_userStatusIsValid = !false;
            m_userStatusIsSet = result;
        }
    }
}

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

QJsonValue User::asJsonValue() const
{
    QJsonObject obj;
    if (m_idIsSet) {
        obj.insert(u"id"_s, ::QtOpenApiCommon::toJsonValue(m_id));
    }
    if (m_usernameIsSet) {
        obj.insert(u"username"_s, ::QtOpenApiCommon::toJsonValue(m_username));
    }
    if (m_firstNameIsSet) {
        obj.insert(u"firstName"_s, ::QtOpenApiCommon::toJsonValue(m_firstName));
    }
    if (m_lastNameIsSet) {
        obj.insert(u"lastName"_s, ::QtOpenApiCommon::toJsonValue(m_lastName));
    }
    if (m_emailIsSet) {
        obj.insert(u"email"_s, ::QtOpenApiCommon::toJsonValue(m_email));
    }
    if (m_passwordIsSet) {
        obj.insert(u"password"_s, ::QtOpenApiCommon::toJsonValue(m_password));
    }
    if (m_phoneIsSet) {
        obj.insert(u"phone"_s, ::QtOpenApiCommon::toJsonValue(m_phone));
    }
    if (m_userStatusIsSet) {
        obj.insert(u"userStatus"_s, ::QtOpenApiCommon::toJsonValue(m_userStatus));
    }
    return obj;
}

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

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

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

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

QString User::getUsername() const
{
    return m_username;
}

void User::setUsername(const QString &username)
{
    m_username = username;
    m_usernameIsValid = true;
    m_usernameIsSet = true;
}

bool User::isUsernameValueSet() const
{
    return m_usernameIsSet;
}

bool User::isUsernameValueValid() const
{
    return m_usernameIsValid;
}

QString User::getFirstName() const
{
    return m_firstName;
}

void User::setFirstName(const QString &firstName)
{
    m_firstName = firstName;
    m_firstNameIsValid = true;
    m_firstNameIsSet = true;
}

bool User::isFirstNameValueSet() const
{
    return m_firstNameIsSet;
}

bool User::isFirstNameValueValid() const
{
    return m_firstNameIsValid;
}

QString User::getLastName() const
{
    return m_lastName;
}

void User::setLastName(const QString &lastName)
{
    m_lastName = lastName;
    m_lastNameIsValid = true;
    m_lastNameIsSet = true;
}

bool User::isLastNameValueSet() const
{
    return m_lastNameIsSet;
}

bool User::isLastNameValueValid() const
{
    return m_lastNameIsValid;
}

QString User::getEmail() const
{
    return m_email;
}

void User::setEmail(const QString &email)
{
    m_email = email;
    m_emailIsValid = true;
    m_emailIsSet = true;
}

bool User::isEmailValueSet() const
{
    return m_emailIsSet;
}

bool User::isEmailValueValid() const
{
    return m_emailIsValid;
}

QString User::getPassword() const
{
    return m_password;
}

void User::setPassword(const QString &password)
{
    m_password = password;
    m_passwordIsValid = true;
    m_passwordIsSet = true;
}

bool User::isPasswordValueSet() const
{
    return m_passwordIsSet;
}

bool User::isPasswordValueValid() const
{
    return m_passwordIsValid;
}

QString User::getPhone() const
{
    return m_phone;
}

void User::setPhone(const QString &phone)
{
    m_phone = phone;
    m_phoneIsValid = true;
    m_phoneIsSet = true;
}

bool User::isPhoneValueSet() const
{
    return m_phoneIsSet;
}

bool User::isPhoneValueValid() const
{
    return m_phoneIsValid;
}

qint32 User::getUserStatus() const
{
    return m_userStatus;
}

void User::setUserStatus(const qint32 &userStatus)
{
    m_userStatus = userStatus;
    m_userStatusIsValid = true;
    m_userStatusIsSet = true;
}

bool User::isUserStatusValueSet() const
{
    return m_userStatusIsSet;
}

bool User::isUserStatusValueValid() const
{
    return m_userStatusIsValid;
}

bool User::isSet() const
{
    bool isObjectUpdated = false;
    do {
        if (m_idIsSet) {
            isObjectUpdated = true;
            break;
        }
        if (m_usernameIsSet) {
            isObjectUpdated = true;
            break;
        }
        if (m_firstNameIsSet) {
            isObjectUpdated = true;
            break;
        }
        if (m_lastNameIsSet) {
            isObjectUpdated = true;
            break;
        }
        if (m_emailIsSet) {
            isObjectUpdated = true;
            break;
        }
        if (m_passwordIsSet) {
            isObjectUpdated = true;
            break;
        }
        if (m_phoneIsSet) {
            isObjectUpdated = true;
            break;
        }
        if (m_userStatusIsSet) {
            isObjectUpdated = true;
            break;
        }
    } while (false);
    return isObjectUpdated;
}

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

} // namespace QtOpenAPI
