Kgapi

domainmembership.cpp
1/*
2 * SPDX-FileCopyrightText: 2021 Daniel Vrátil <dvratil@kde.org>
3 * SPDX-FileCopyrightText: 2022 Claudio Cambra <claudio.cambra@kde.org>
4 *
5 * SPDX-License-Identifier: LGPL-2.1-only
6 * SPDX-License-Identifier: LGPL-3.0-only
7 * SPDX-License-Identifier: LicenseRef-KDE-Accepted-LGPL
8 */
9
10#include "domainmembership.h"
11
12#include <QJsonArray>
13#include <QJsonObject>
14#include <QJsonValue>
15#include <QSharedData>
16
17#include <algorithm>
18
19namespace KGAPI2::People
20{
21class DomainMembership::Private : public QSharedData
22{
23public:
24 explicit Private() = default;
25 Private(const Private &) = default;
26 Private(Private &&) noexcept = delete;
27 Private &operator=(const Private &) = delete;
28 Private &operator=(Private &&) noexcept = delete;
29 ~Private() = default;
30
31 bool operator==(const Private &other) const
32 {
33 return inViewerDomain == other.inViewerDomain;
34 }
35
36 bool operator!=(const Private &other) const
37 {
38 return !(*this == other);
39 }
40
41 bool inViewerDomain{};
42};
43
45 : d(new Private)
46{
47}
48
51DomainMembership &DomainMembership::operator=(const DomainMembership &) = default;
52DomainMembership &DomainMembership::operator=(DomainMembership &&) noexcept = default;
54
55bool DomainMembership::operator==(const DomainMembership &other) const
56{
57 return *d == *other.d;
58}
59
60bool DomainMembership::operator!=(const DomainMembership &other) const
61{
62 return !(*this == other);
63}
64
66{
67 return d->inViewerDomain;
68}
69
71{
72 d->inViewerDomain = value;
73}
74
75DomainMembership DomainMembership::fromJSON(const QJsonObject &obj)
76{
77 DomainMembership domainMembership;
78
79 if(!obj.isEmpty()) {
80 domainMembership.setInViewerDomain(obj.value(QStringLiteral("inViewerDomain")).toBool());
81 }
82
83 return domainMembership;
84}
85
86QJsonValue DomainMembership::toJSON() const
87{
88 return QJsonObject {
89 { QStringLiteral("inViewerDomain"), d->inViewerDomain }
90 };
91}
92
93} // namespace KGAPI2::People
A Google Workspace Domain membership.
bool inViewerDomain() const
True if the person is in the viewer's Google Workspace domain.
void setInViewerDomain(bool value)
Sets value of the inViewerDomain property.
DomainMembership()
Constructs a new DomainMembership.
bool isEmpty() const const
QJsonValue value(QLatin1StringView key) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:54:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.