// 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 "OAIOdata_error.h"

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

#include "OAIHelpers.h"

namespace OpenAPI {

class OAIOdata_errorPrivate {
    friend class OAIOdata_error;

     OAIOdata_error_main error;
     bool error_isSet;
     bool error_isValid;
};

OAIOdata_error::OAIOdata_error()
    : d_ptr()
{
}

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

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

OAIOdata_error::~OAIOdata_error() = default;

void OAIOdata_error::initializeModel() {
    if (d_ptr == nullptr) {
        d_ptr.reset(new OAIOdata_errorPrivate{});

        Q_D(OAIOdata_error);


        d->error_isSet = false;
        d->error_isValid = false;
    }
}

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

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

    Q_D(OAIOdata_error);

    d->error_isValid = ::OpenAPI::fromJsonValue(d->error, json[QString("error")]);
    d->error_isSet = !json[QString("error")].isNull() && d->error_isValid;
}

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

QJsonObject OAIOdata_error::asJsonObject() const {
    Q_D(const OAIOdata_error);
    if(!d){
        return {};
    }
    QJsonObject obj;
    if (d->error.isSet()) {
        obj.insert(QString("error"), ::OpenAPI::toJsonValue(d->error));
    }
    return obj;
}

OAIOdata_error_main OAIOdata_error::getError() const {
    Q_D(const OAIOdata_error);
    if(!d){
        return {};
    }
    return d->error;
}
void OAIOdata_error::setError(const OAIOdata_error_main &error) {
    Q_D(OAIOdata_error);
    Q_ASSERT(d);

    d->error = error;
    d->error_isSet = true;
}

bool OAIOdata_error::is_error_Set() const{
    Q_D(const OAIOdata_error);
    if(!d){
        return false;
    }

    return d->error_isSet;
}

bool OAIOdata_error::is_error_Valid() const{
    Q_D(const OAIOdata_error);
    if(!d){
        return false;
    }
    return d->error_isValid;
}

bool OAIOdata_error::isSet() const {
    Q_D(const OAIOdata_error);
    if(!d){
        return false;
    }
    bool isObjectUpdated = false;
    do {
        if (d->error.isSet()) {
            isObjectUpdated = true;
            break;
        }
    } while (false);
    return isObjectUpdated;
}

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

} // namespace OpenAPI
