File indexing completed on 2024-12-08 04:33:21

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "libruqola_private_export.h"
0010 #include "roles/roleinfo.h"
0011 #include <QDebug>
0012 #include <QString>
0013 
0014 class LIBRUQOLACORE_TESTS_EXPORT Permission
0015 {
0016 public:
0017     Permission();
0018 
0019     bool parsePermission(const QJsonObject &replyObject, const QVector<RoleInfo> &roleInfo = {}, bool restApi = true);
0020     [[nodiscard]] QStringList roles() const;
0021     void setRoles(const QStringList &newRoles);
0022 
0023     [[nodiscard]] qint64 updatedAt() const;
0024     void setUpdatedAt(qint64 newUpdatedAt);
0025 
0026     [[nodiscard]] bool isValid() const;
0027 
0028     [[nodiscard]] const QString &identifier() const;
0029     void setIdentifier(const QString &newIdentifier);
0030 
0031     [[nodiscard]] const QStringList &rolesStr() const;
0032 
0033     [[nodiscard]] bool operator==(const Permission &other) const;
0034 
0035 private:
0036     qint64 mUpdatedAt = -1;
0037     QStringList mRolesStr;
0038     QStringList mRoles;
0039     QString mIdentifier;
0040 };
0041 Q_DECLARE_METATYPE(Permission)
0042 Q_DECLARE_TYPEINFO(Permission, Q_RELOCATABLE_TYPE);
0043 LIBRUQOLACORE_EXPORT QDebug operator<<(QDebug d, const Permission &t);