File indexing completed on 2024-05-12 05:22:29

0001 /*
0002  * SPDX-FileCopyrightText: 2021 Daniel Vrátil <dvratil@kde.org>
0003  * SPDX-FileCopyrightText: 2022 Claudio Cambra <claudio.cambra@kde.org>
0004  *
0005  * SPDX-License-Identifier: LGPL-2.1-only
0006  * SPDX-License-Identifier: LGPL-3.0-only
0007  * SPDX-License-Identifier: LicenseRef-KDE-Accepted-LGPL
0008  */
0009 
0010 #pragma once
0011 
0012 #include <QSharedDataPointer>
0013 #include "kgapipeople_export.h"
0014 
0015 #include <QList>
0016 #include <QString>
0017 
0018 #include <optional>
0019 
0020 class QJsonObject;
0021 class QJsonValue;
0022 
0023 namespace KGAPI2::People
0024 {
0025 class Source;
0026 
0027 /**
0028  * The metadata about a person.
0029  *
0030  * @see https://developers.google.com/people/api/rest/v1/people#personmetadata
0031  * @since 5.23.0
0032  **/
0033 class KGAPIPEOPLE_EXPORT PersonMetadata
0034 {
0035 public:
0036     enum class ObjectType {
0037         OBJECT_TYPE_UNSPECIFIED, ///< Unspecified.
0038         PERSON, ///< Person.
0039         PAGE, ///< [Currents Page.](https://workspace.google.com/products/currents/)
0040     };
0041 
0042     /** Constructs a new PersonMetadata **/
0043     explicit PersonMetadata();
0044     PersonMetadata(const PersonMetadata &);
0045     PersonMetadata(PersonMetadata &&) noexcept;
0046     PersonMetadata &operator=(const PersonMetadata &);
0047     PersonMetadata &operator=(PersonMetadata &&) noexcept;
0048     /** Destructor. **/
0049     ~PersonMetadata();
0050 
0051     bool operator==(const PersonMetadata &) const;
0052     bool operator!=(const PersonMetadata &) const;
0053 
0054     [[nodiscard]] static PersonMetadata fromJSON(const QJsonObject &);
0055     [[nodiscard]] QJsonValue toJSON() const;
0056 
0057     /** Output only. Resource names of people linked to this resource. **/
0058     [[nodiscard]] QList<QString> linkedPeopleResourceNames() const;
0059 
0060     /** Output only. **DEPRECATED** (Please use `person.metadata.sources.profileMetadata.objectType` instead) The type of the person object. **/
0061     [[nodiscard]] PersonMetadata::ObjectType objectType() const;
0062 
0063     /** Output only. Any former resource names this person has had. Populated only for `people.connections.list` requests that include a sync token. The
0064      * resource name may change when adding or removing fields that link a contact and profile such as a verified email, verified phone number, or profile URL.
0065      * **/
0066     [[nodiscard]] QList<QString> previousResourceNames() const;
0067 
0068     /** Output only. True if the person resource has been deleted. Populated only for `people.connections.list` and `otherContacts.list` sync requests. **/
0069     [[nodiscard]] bool deleted() const;
0070 
0071     /** The sources of data for the person. **/
0072     [[nodiscard]] QList<Source> sources() const;
0073     /** Sets value of the sources property. **/
0074     void setSources(const QList<Source> &value);
0075     /** Appends the given @c value to the list of sources. **/
0076     void addSource(const Source &value);
0077     /** Removes the given @c value from the list of sources if it exists. **/
0078     void removeSource(const Source &value);
0079     /** Clears the list of sources. **/
0080     void clearSources();
0081 
0082 private:
0083     class Private;
0084     QSharedDataPointer<Private> d;
0085 }; // PersonMetadata
0086 
0087 } // namespace KGAPI2::People