// model-body.mustache

// licenseInfo.mustache

/**
 * Libre Graph API
 * Libre Graph is a free API for cloud collaboration inspired by the MS Graph API.
 *
 * The version of the OpenAPI document: v1.0.4
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

#include "OAIAppRoleAssignment.h"

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

#include "OAIHelpers.h"

namespace OpenAPI {

class OAIAppRoleAssignmentPrivate {
    friend class OAIAppRoleAssignment;

     QString id;
     bool id_isSet;
     bool id_isValid;

     QDateTime deleted_date_time;
     bool deleted_date_time_isSet;
     bool deleted_date_time_isValid;

     QString app_role_id;
     bool app_role_id_isSet;
     bool app_role_id_isValid;

     QDateTime created_date_time;
     bool created_date_time_isSet;
     bool created_date_time_isValid;

     QString principal_display_name;
     bool principal_display_name_isSet;
     bool principal_display_name_isValid;

     QString principal_id;
     bool principal_id_isSet;
     bool principal_id_isValid;

     QString principal_type;
     bool principal_type_isSet;
     bool principal_type_isValid;

     QString resource_display_name;
     bool resource_display_name_isSet;
     bool resource_display_name_isValid;

     QString resource_id;
     bool resource_id_isSet;
     bool resource_id_isValid;
};

OAIAppRoleAssignment::OAIAppRoleAssignment()
    : d_ptr()
{
}

OAIAppRoleAssignment::OAIAppRoleAssignment(const OAIAppRoleAssignment& other)
    : d_ptr(other.d_ptr)
{
}

OAIAppRoleAssignment::OAIAppRoleAssignment(QString json)
    : d_ptr(nullptr)
{
    this->fromJson(json);
}

OAIAppRoleAssignment::~OAIAppRoleAssignment() = default;

void OAIAppRoleAssignment::initializeModel() {
    if (d_ptr == nullptr) {
        d_ptr.reset(new OAIAppRoleAssignmentPrivate{});

        Q_D(OAIAppRoleAssignment);


        d->id_isSet = false;
        d->id_isValid = false;

        d->deleted_date_time_isSet = false;
        d->deleted_date_time_isValid = false;

        d->app_role_id_isSet = false;
        d->app_role_id_isValid = false;

        d->created_date_time_isSet = false;
        d->created_date_time_isValid = false;

        d->principal_display_name_isSet = false;
        d->principal_display_name_isValid = false;

        d->principal_id_isSet = false;
        d->principal_id_isValid = false;

        d->principal_type_isSet = false;
        d->principal_type_isValid = false;

        d->resource_display_name_isSet = false;
        d->resource_display_name_isValid = false;

        d->resource_id_isSet = false;
        d->resource_id_isValid = false;
    }
}

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

void OAIAppRoleAssignment::fromJsonObject(QJsonObject json) {
    initializeModel();

    Q_D(OAIAppRoleAssignment);

    d->id_isValid = ::OpenAPI::fromJsonValue(d->id, json[QString("id")]);
    d->id_isSet = !json[QString("id")].isNull() && d->id_isValid;

    d->deleted_date_time_isValid = ::OpenAPI::fromJsonValue(d->deleted_date_time, json[QString("deletedDateTime")]);
    d->deleted_date_time_isSet = !json[QString("deletedDateTime")].isNull() && d->deleted_date_time_isValid;

    d->app_role_id_isValid = ::OpenAPI::fromJsonValue(d->app_role_id, json[QString("appRoleId")]);
    d->app_role_id_isSet = !json[QString("appRoleId")].isNull() && d->app_role_id_isValid;

    d->created_date_time_isValid = ::OpenAPI::fromJsonValue(d->created_date_time, json[QString("createdDateTime")]);
    d->created_date_time_isSet = !json[QString("createdDateTime")].isNull() && d->created_date_time_isValid;

    d->principal_display_name_isValid = ::OpenAPI::fromJsonValue(d->principal_display_name, json[QString("principalDisplayName")]);
    d->principal_display_name_isSet = !json[QString("principalDisplayName")].isNull() && d->principal_display_name_isValid;

    d->principal_id_isValid = ::OpenAPI::fromJsonValue(d->principal_id, json[QString("principalId")]);
    d->principal_id_isSet = !json[QString("principalId")].isNull() && d->principal_id_isValid;

    d->principal_type_isValid = ::OpenAPI::fromJsonValue(d->principal_type, json[QString("principalType")]);
    d->principal_type_isSet = !json[QString("principalType")].isNull() && d->principal_type_isValid;

    d->resource_display_name_isValid = ::OpenAPI::fromJsonValue(d->resource_display_name, json[QString("resourceDisplayName")]);
    d->resource_display_name_isSet = !json[QString("resourceDisplayName")].isNull() && d->resource_display_name_isValid;

    d->resource_id_isValid = ::OpenAPI::fromJsonValue(d->resource_id, json[QString("resourceId")]);
    d->resource_id_isSet = !json[QString("resourceId")].isNull() && d->resource_id_isValid;
}

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

QJsonObject OAIAppRoleAssignment::asJsonObject() const {
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return {};
    }
    QJsonObject obj;
    if (d->id_isSet) {
        obj.insert(QString("id"), ::OpenAPI::toJsonValue(d->id));
    }
    if (d->deleted_date_time_isSet) {
        obj.insert(QString("deletedDateTime"), ::OpenAPI::toJsonValue(d->deleted_date_time));
    }
    if (d->app_role_id_isSet) {
        obj.insert(QString("appRoleId"), ::OpenAPI::toJsonValue(d->app_role_id));
    }
    if (d->created_date_time_isSet) {
        obj.insert(QString("createdDateTime"), ::OpenAPI::toJsonValue(d->created_date_time));
    }
    if (d->principal_display_name_isSet) {
        obj.insert(QString("principalDisplayName"), ::OpenAPI::toJsonValue(d->principal_display_name));
    }
    if (d->principal_id_isSet) {
        obj.insert(QString("principalId"), ::OpenAPI::toJsonValue(d->principal_id));
    }
    if (d->principal_type_isSet) {
        obj.insert(QString("principalType"), ::OpenAPI::toJsonValue(d->principal_type));
    }
    if (d->resource_display_name_isSet) {
        obj.insert(QString("resourceDisplayName"), ::OpenAPI::toJsonValue(d->resource_display_name));
    }
    if (d->resource_id_isSet) {
        obj.insert(QString("resourceId"), ::OpenAPI::toJsonValue(d->resource_id));
    }
    return obj;
}

QString OAIAppRoleAssignment::getId() const {
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return {};
    }
    return d->id;
}
void OAIAppRoleAssignment::setId(const QString &id) {
    Q_D(OAIAppRoleAssignment);
    Q_ASSERT(d);

    d->id = id;
    d->id_isSet = true;
}

bool OAIAppRoleAssignment::is_id_Set() const{
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return false;
    }

    return d->id_isSet;
}

bool OAIAppRoleAssignment::is_id_Valid() const{
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return false;
    }
    return d->id_isValid;
}

QDateTime OAIAppRoleAssignment::getDeletedDateTime() const {
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return {};
    }
    return d->deleted_date_time;
}
void OAIAppRoleAssignment::setDeletedDateTime(const QDateTime &deleted_date_time) {
    Q_D(OAIAppRoleAssignment);
    Q_ASSERT(d);

    d->deleted_date_time = deleted_date_time;
    d->deleted_date_time_isSet = true;
}

bool OAIAppRoleAssignment::is_deleted_date_time_Set() const{
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return false;
    }

    return d->deleted_date_time_isSet;
}

bool OAIAppRoleAssignment::is_deleted_date_time_Valid() const{
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return false;
    }
    return d->deleted_date_time_isValid;
}

QString OAIAppRoleAssignment::getAppRoleId() const {
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return {};
    }
    return d->app_role_id;
}
void OAIAppRoleAssignment::setAppRoleId(const QString &app_role_id) {
    Q_D(OAIAppRoleAssignment);
    Q_ASSERT(d);

    d->app_role_id = app_role_id;
    d->app_role_id_isSet = true;
}

bool OAIAppRoleAssignment::is_app_role_id_Set() const{
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return false;
    }

    return d->app_role_id_isSet;
}

bool OAIAppRoleAssignment::is_app_role_id_Valid() const{
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return false;
    }
    return d->app_role_id_isValid;
}

QDateTime OAIAppRoleAssignment::getCreatedDateTime() const {
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return {};
    }
    return d->created_date_time;
}
void OAIAppRoleAssignment::setCreatedDateTime(const QDateTime &created_date_time) {
    Q_D(OAIAppRoleAssignment);
    Q_ASSERT(d);

    d->created_date_time = created_date_time;
    d->created_date_time_isSet = true;
}

bool OAIAppRoleAssignment::is_created_date_time_Set() const{
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return false;
    }

    return d->created_date_time_isSet;
}

bool OAIAppRoleAssignment::is_created_date_time_Valid() const{
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return false;
    }
    return d->created_date_time_isValid;
}

QString OAIAppRoleAssignment::getPrincipalDisplayName() const {
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return {};
    }
    return d->principal_display_name;
}
void OAIAppRoleAssignment::setPrincipalDisplayName(const QString &principal_display_name) {
    Q_D(OAIAppRoleAssignment);
    Q_ASSERT(d);

    d->principal_display_name = principal_display_name;
    d->principal_display_name_isSet = true;
}

bool OAIAppRoleAssignment::is_principal_display_name_Set() const{
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return false;
    }

    return d->principal_display_name_isSet;
}

bool OAIAppRoleAssignment::is_principal_display_name_Valid() const{
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return false;
    }
    return d->principal_display_name_isValid;
}

QString OAIAppRoleAssignment::getPrincipalId() const {
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return {};
    }
    return d->principal_id;
}
void OAIAppRoleAssignment::setPrincipalId(const QString &principal_id) {
    Q_D(OAIAppRoleAssignment);
    Q_ASSERT(d);

    d->principal_id = principal_id;
    d->principal_id_isSet = true;
}

bool OAIAppRoleAssignment::is_principal_id_Set() const{
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return false;
    }

    return d->principal_id_isSet;
}

bool OAIAppRoleAssignment::is_principal_id_Valid() const{
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return false;
    }
    return d->principal_id_isValid;
}

QString OAIAppRoleAssignment::getPrincipalType() const {
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return {};
    }
    return d->principal_type;
}
void OAIAppRoleAssignment::setPrincipalType(const QString &principal_type) {
    Q_D(OAIAppRoleAssignment);
    Q_ASSERT(d);

    d->principal_type = principal_type;
    d->principal_type_isSet = true;
}

bool OAIAppRoleAssignment::is_principal_type_Set() const{
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return false;
    }

    return d->principal_type_isSet;
}

bool OAIAppRoleAssignment::is_principal_type_Valid() const{
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return false;
    }
    return d->principal_type_isValid;
}

QString OAIAppRoleAssignment::getResourceDisplayName() const {
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return {};
    }
    return d->resource_display_name;
}
void OAIAppRoleAssignment::setResourceDisplayName(const QString &resource_display_name) {
    Q_D(OAIAppRoleAssignment);
    Q_ASSERT(d);

    d->resource_display_name = resource_display_name;
    d->resource_display_name_isSet = true;
}

bool OAIAppRoleAssignment::is_resource_display_name_Set() const{
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return false;
    }

    return d->resource_display_name_isSet;
}

bool OAIAppRoleAssignment::is_resource_display_name_Valid() const{
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return false;
    }
    return d->resource_display_name_isValid;
}

QString OAIAppRoleAssignment::getResourceId() const {
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return {};
    }
    return d->resource_id;
}
void OAIAppRoleAssignment::setResourceId(const QString &resource_id) {
    Q_D(OAIAppRoleAssignment);
    Q_ASSERT(d);

    d->resource_id = resource_id;
    d->resource_id_isSet = true;
}

bool OAIAppRoleAssignment::is_resource_id_Set() const{
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return false;
    }

    return d->resource_id_isSet;
}

bool OAIAppRoleAssignment::is_resource_id_Valid() const{
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return false;
    }
    return d->resource_id_isValid;
}

bool OAIAppRoleAssignment::isSet() const {
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return false;
    }
    bool isObjectUpdated = false;
    do {
        if (d->id_isSet) {
            isObjectUpdated = true;
            break;
        }

        if (d->deleted_date_time_isSet) {
            isObjectUpdated = true;
            break;
        }

        if (d->app_role_id_isSet) {
            isObjectUpdated = true;
            break;
        }

        if (d->created_date_time_isSet) {
            isObjectUpdated = true;
            break;
        }

        if (d->principal_display_name_isSet) {
            isObjectUpdated = true;
            break;
        }

        if (d->principal_id_isSet) {
            isObjectUpdated = true;
            break;
        }

        if (d->principal_type_isSet) {
            isObjectUpdated = true;
            break;
        }

        if (d->resource_display_name_isSet) {
            isObjectUpdated = true;
            break;
        }

        if (d->resource_id_isSet) {
            isObjectUpdated = true;
            break;
        }
    } while (false);
    return isObjectUpdated;
}

bool OAIAppRoleAssignment::isValid() const {
    Q_D(const OAIAppRoleAssignment);
    if(!d){
        return false;
    }
    // only required properties are required for the object to be considered valid
    return d->app_role_id_isValid && d->principal_id_isValid && d->resource_id_isValid && true;
}

} // namespace OpenAPI
