Kgapi

contactgroupmembership.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 "contactgroupmembership.h"
11#include "peopleservice.h"
12
13#include <QJsonArray>
14#include <QJsonObject>
15#include <QJsonValue>
16#include <QSharedData>
17
18#include <algorithm>
19
20namespace KGAPI2::People
21{
22class ContactGroupMembership::Private : public QSharedData
23{
24public:
25 explicit Private() = default;
26 Private(const Private &) = default;
27 Private(Private &&) noexcept = delete;
28 Private &operator=(const Private &) = delete;
29 Private &operator=(Private &&) noexcept = delete;
30 ~Private() = default;
31
32 bool operator==(const Private &other) const
33 {
34 return contactGroupResourceName == other.contactGroupResourceName && contactGroupId == other.contactGroupId;
35 }
36
37 bool operator!=(const Private &other) const
38 {
39 return !(*this == other);
40 }
41
42 QString contactGroupResourceName{};
43 QString contactGroupId{};
44};
45
50
56
57bool ContactGroupMembership::operator==(const ContactGroupMembership &other) const
58{
59 return *d == *other.d;
60}
61
62bool ContactGroupMembership::operator!=(const ContactGroupMembership &other) const
63{
64 return !(*this == other);
65}
66
68{
69 return d->contactGroupResourceName;
70}
71
73{
74 d->contactGroupResourceName = value;
75}
77{
78 return d->contactGroupId;
79}
80
81ContactGroupMembership ContactGroupMembership::fromJSON(const QJsonObject &obj)
82{
83 ContactGroupMembership contactGroupMembership;
84
85 if(!obj.isEmpty()) {
86 contactGroupMembership.d->contactGroupId = obj.value(QStringLiteral("contactGroupId")).toString();
87 contactGroupMembership.d->contactGroupResourceName = obj.value(QStringLiteral("contactGroupResourceName")).toString();
88 }
89
90 return contactGroupMembership;
91}
92
93QJsonValue ContactGroupMembership::toJSON() const
94{
95 QJsonObject obj;
96
97 PeopleUtils::addValueToJsonObjectIfValid(obj, "contactGroupResourceName", d->contactGroupResourceName);
98 // Output only -> PeopleUtils::addValueToJsonObjectIfValid(obj, "contactGroupId", d->contactGroupId);
99 return obj;
100}
101
102} // namespace KGAPI2::People
A Google contact group membership.
ContactGroupMembership()
Constructs a new ContactGroupMembership.
QString contactGroupResourceName() const
The resource name for the contact group, assigned by the server.
void setContactGroupResourceName(const QString &value)
Sets value of the contactGroupResourceName property.
bool isEmpty() const const
QJsonValue value(QLatin1StringView key) const const
QString toString() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:59:23 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.