/**
 * Deepin官网
 * deepin的官方网站后台接口
 *
 * The version of the OpenAPI document: 1.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.
 */

#ifndef DH_OBJECT_H
#define DH_OBJECT_H

#include <QJsonDocument>
#include <QJsonObject>
#include <QMetaType>

namespace DeepinHomeAPI {

class DHObject {
public:
    DHObject() {}

    DHObject(QString jsonString) {
        fromJson(jsonString);
    }

    virtual ~DHObject() {}

    virtual QJsonObject asJsonObject() const {
        return jObj;
    }

    virtual QString asJson() const {
        QJsonDocument doc(jObj);
        return doc.toJson(QJsonDocument::Compact);
    }

    virtual void fromJson(QString jsonString) {
        QJsonDocument doc = QJsonDocument::fromJson(jsonString.toUtf8());
        jObj = doc.object();
    }

    virtual void fromJsonObject(QJsonObject json) {
        jObj = json;
    }

    virtual bool isSet() const {
        return false;
    }

    virtual bool isValid() const {
        return true;
    }

private:
    QJsonObject jObj;
};

inline bool operator==(const DHObject& left, const DHObject& right){  
    return (left.asJsonObject() == right.asJsonObject());  
}

inline uint qHash(const DHObject& obj, uint seed = 0) noexcept{
    return qHash(obj.asJsonObject(), seed);
}

} // namespace DeepinHomeAPI

Q_DECLARE_METATYPE(DeepinHomeAPI::DHObject)

#endif // DH_OBJECT_H
