/**
 * linglong仓库
 * 玲珑仓库接口
 *
 * The version of the OpenAPI document: 1.0.0
 * Contact: wurongjie@deepin.org
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

#include "Request_Auth.h"

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

#include "Helpers.h"

namespace linglong {
namespace api {
namespace client {

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

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

Request_Auth::~Request_Auth() {}

void Request_Auth::initializeModel() {

    m_password_isSet = false;
    m_password_isValid = false;

    m_username_isSet = false;
    m_username_isValid = false;
}

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

void Request_Auth::fromJsonObject(QJsonObject json) {

    m_password_isValid = ::linglong::api::client::fromJsonValue(m_password, json[QString("password")]);
    m_password_isSet = !json[QString("password")].isNull() && m_password_isValid;

    m_username_isValid = ::linglong::api::client::fromJsonValue(m_username, json[QString("username")]);
    m_username_isSet = !json[QString("username")].isNull() && m_username_isValid;
}

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

QJsonObject Request_Auth::asJsonObject() const {
    QJsonObject obj;
    if (m_password_isSet) {
        obj.insert(QString("password"), ::linglong::api::client::toJsonValue(m_password));
    }
    if (m_username_isSet) {
        obj.insert(QString("username"), ::linglong::api::client::toJsonValue(m_username));
    }
    return obj;
}

QString Request_Auth::getPassword() const {
    return m_password;
}
void Request_Auth::setPassword(const QString &password) {
    m_password = password;
    m_password_isSet = true;
}

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

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

QString Request_Auth::getUsername() const {
    return m_username;
}
void Request_Auth::setUsername(const QString &username) {
    m_username = username;
    m_username_isSet = true;
}

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

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

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

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

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

} // namespace linglong
} // namespace api
} // namespace client
