Kgapi

relationshipinterest.cpp
1/*
2 * SPDX-FileCopyrightText: 2021 Daniel Vrátil <dvratil@kde.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 * SPDX-License-Identifier: LGPL-3.0-only
6 * SPDX-License-Identifier: LicenseRef-KDE-Accepted-LGPL
7 */
8
9#include "relationshipinterest.h"
10
11#include "fieldmetadata.h"
12#include "peopleservice.h"
13
14#include <QJsonArray>
15#include <QJsonObject>
16#include <QJsonValue>
17#include <QSharedData>
18
19#include <algorithm>
20
21namespace KGAPI2::People
22{
23class RelationshipInterest::Private : public QSharedData
24{
25public:
26 explicit Private() = default;
27 Private(const Private &) = default;
28 Private(Private &&) noexcept = delete;
29 Private &operator=(const Private &) = delete;
30 Private &operator=(Private &&) noexcept = delete;
31 ~Private() = default;
32
33 bool operator==(const Private &other) const
34 {
35 return formattedValue == other.formattedValue && metadata == other.metadata && value == other.value;
36 }
37
38 bool operator!=(const Private &other) const
39 {
40 return !(*this == other);
41 }
42
43 QString formattedValue{};
44 FieldMetadata metadata{};
45 QString value{};
46};
47
49 : d(new Private)
50{
51}
52
56RelationshipInterest &RelationshipInterest::operator=(RelationshipInterest &&) noexcept = default;
58
59bool RelationshipInterest::operator==(const RelationshipInterest &other) const
60{
61 return *d == *other.d;
62}
63
64bool RelationshipInterest::operator!=(const RelationshipInterest &other) const
65{
66 return !(*this == other);
67}
68
70{
71 return d->formattedValue;
72}
74{
75 return d->metadata;
76}
77
79{
80 d->metadata = value;
81}
83{
84 return d->value;
85}
86
88{
89 d->value = value;
90}
91
92RelationshipInterest RelationshipInterest::fromJSON(const QJsonObject &obj)
93{
94 Q_UNUSED(obj);
95 return RelationshipInterest();
96}
97
98QJsonValue RelationshipInterest::toJSON() const
99{
100 QJsonObject obj;
101
102 // Output only -> PeopleUtils::addValueToJsonObjectIfValid(obj, "formattedValue", d->formattedValue);
103 // Skip, field metadata is only useful for receiving -> PeopleUtils::addValueToJsonObjectIfValid(obj, "metadata", d->metadata.toJSON());
104 PeopleUtils::addValueToJsonObjectIfValid(obj, "value", d->value);
105 return obj;
106}
107
108} // namespace KGAPI2::People
Metadata about a field.
DEPRECATED: No data will be returned A person's relationship interest .
QString formattedValue() const
Output only.
void setMetadata(const FieldMetadata &value)
Sets value of the metadata property.
QString value() const
The kind of relationship the person is looking for.
FieldMetadata metadata() const
Metadata about the relationship interest.
RelationshipInterest()
Constructs a new RelationshipInterest.
void setValue(const QString &value)
Sets value of the value property.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 27 2024 11:55:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.