/**
 * OpenAPI Petstore
 * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
 *
 * The version of the OpenAPI document: 1.0.0
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

#include "OAIUser.h"

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

#include "OAIHelpers.h"

namespace OpenAPI {

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

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

OAIUser::~OAIUser() {}

void OAIUser::initializeModel() {

    m_id_isSet = false;
    m_id_isValid = false;

    m_username_isSet = false;
    m_username_isValid = false;

    m_first_name_isSet = false;
    m_first_name_isValid = false;

    m_last_name_isSet = false;
    m_last_name_isValid = false;

    m_email_isSet = false;
    m_email_isValid = false;

    m_password_isSet = false;
    m_password_isValid = false;

    m_phone_isSet = false;
    m_phone_isValid = false;

    m_user_status_isSet = false;
    m_user_status_isValid = false;
}

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

void OAIUser::fromJsonObject(QJsonObject json) {

    m_id_isValid = ::OpenAPI::fromJsonValue(id, json[QString("id")]);
    m_id_isSet = !json[QString("id")].isNull() && m_id_isValid;

    m_username_isValid = ::OpenAPI::fromJsonValue(username, json[QString("username")]);
    m_username_isSet = !json[QString("username")].isNull() && m_username_isValid;

    m_first_name_isValid = ::OpenAPI::fromJsonValue(first_name, json[QString("firstName")]);
    m_first_name_isSet = !json[QString("firstName")].isNull() && m_first_name_isValid;

    m_last_name_isValid = ::OpenAPI::fromJsonValue(last_name, json[QString("lastName")]);
    m_last_name_isSet = !json[QString("lastName")].isNull() && m_last_name_isValid;

    m_email_isValid = ::OpenAPI::fromJsonValue(email, json[QString("email")]);
    m_email_isSet = !json[QString("email")].isNull() && m_email_isValid;

    m_password_isValid = ::OpenAPI::fromJsonValue(password, json[QString("password")]);
    m_password_isSet = !json[QString("password")].isNull() && m_password_isValid;

    m_phone_isValid = ::OpenAPI::fromJsonValue(phone, json[QString("phone")]);
    m_phone_isSet = !json[QString("phone")].isNull() && m_phone_isValid;

    m_user_status_isValid = ::OpenAPI::fromJsonValue(user_status, json[QString("userStatus")]);
    m_user_status_isSet = !json[QString("userStatus")].isNull() && m_user_status_isValid;
}

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

QJsonObject OAIUser::asJsonObject() const {
    QJsonObject obj;
    if (m_id_isSet) {
        obj.insert(QString("id"), ::OpenAPI::toJsonValue(id));
    }
    if (m_username_isSet) {
        obj.insert(QString("username"), ::OpenAPI::toJsonValue(username));
    }
    if (m_first_name_isSet) {
        obj.insert(QString("firstName"), ::OpenAPI::toJsonValue(first_name));
    }
    if (m_last_name_isSet) {
        obj.insert(QString("lastName"), ::OpenAPI::toJsonValue(last_name));
    }
    if (m_email_isSet) {
        obj.insert(QString("email"), ::OpenAPI::toJsonValue(email));
    }
    if (m_password_isSet) {
        obj.insert(QString("password"), ::OpenAPI::toJsonValue(password));
    }
    if (m_phone_isSet) {
        obj.insert(QString("phone"), ::OpenAPI::toJsonValue(phone));
    }
    if (m_user_status_isSet) {
        obj.insert(QString("userStatus"), ::OpenAPI::toJsonValue(user_status));
    }
    return obj;
}

qint64 OAIUser::getId() const {
    return id;
}
void OAIUser::setId(const qint64 &id) {
    this->id = id;
    this->m_id_isSet = true;
}

bool OAIUser::is_id_Set() const{
    return m_id_isSet;
}

bool OAIUser::is_id_Valid() const{
    return m_id_isValid;
}

QString OAIUser::getUsername() const {
    return username;
}
void OAIUser::setUsername(const QString &username) {
    this->username = username;
    this->m_username_isSet = true;
}

bool OAIUser::is_username_Set() const{
    return m_username_isSet;
}

bool OAIUser::is_username_Valid() const{
    return m_username_isValid;
}

QString OAIUser::getFirstName() const {
    return first_name;
}
void OAIUser::setFirstName(const QString &first_name) {
    this->first_name = first_name;
    this->m_first_name_isSet = true;
}

bool OAIUser::is_first_name_Set() const{
    return m_first_name_isSet;
}

bool OAIUser::is_first_name_Valid() const{
    return m_first_name_isValid;
}

QString OAIUser::getLastName() const {
    return last_name;
}
void OAIUser::setLastName(const QString &last_name) {
    this->last_name = last_name;
    this->m_last_name_isSet = true;
}

bool OAIUser::is_last_name_Set() const{
    return m_last_name_isSet;
}

bool OAIUser::is_last_name_Valid() const{
    return m_last_name_isValid;
}

QString OAIUser::getEmail() const {
    return email;
}
void OAIUser::setEmail(const QString &email) {
    this->email = email;
    this->m_email_isSet = true;
}

bool OAIUser::is_email_Set() const{
    return m_email_isSet;
}

bool OAIUser::is_email_Valid() const{
    return m_email_isValid;
}

QString OAIUser::getPassword() const {
    return password;
}
void OAIUser::setPassword(const QString &password) {
    this->password = password;
    this->m_password_isSet = true;
}

bool OAIUser::is_password_Set() const{
    return m_password_isSet;
}

bool OAIUser::is_password_Valid() const{
    return m_password_isValid;
}

QString OAIUser::getPhone() const {
    return phone;
}
void OAIUser::setPhone(const QString &phone) {
    this->phone = phone;
    this->m_phone_isSet = true;
}

bool OAIUser::is_phone_Set() const{
    return m_phone_isSet;
}

bool OAIUser::is_phone_Valid() const{
    return m_phone_isValid;
}

qint32 OAIUser::getUserStatus() const {
    return user_status;
}
void OAIUser::setUserStatus(const qint32 &user_status) {
    this->user_status = user_status;
    this->m_user_status_isSet = true;
}

bool OAIUser::is_user_status_Set() const{
    return m_user_status_isSet;
}

bool OAIUser::is_user_status_Valid() const{
    return m_user_status_isValid;
}

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

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

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

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

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

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

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

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

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

} // namespace OpenAPI
