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

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 <QString>
0016 
0017 #include <optional>
0018 
0019 class QJsonObject;
0020 class QJsonValue;
0021 
0022 namespace KGAPI2::People
0023 {
0024 class ProfileMetadata;
0025 
0026 /**
0027  * The source of a field.
0028  *
0029  * @see https://developers.google.com/people/api/rest/v1/people#source
0030  * @since 5.23.0
0031  **/
0032 class KGAPIPEOPLE_EXPORT Source
0033 {
0034 public:
0035     enum class Type {
0036         SOURCE_TYPE_UNSPECIFIED, ///< Unspecified.
0037         ACCOUNT, ///< [Google Account](https://accounts.google.com).
0038         PROFILE, ///< [Google profile](https://profiles.google.com). You can view the profile at
0039                  ///< [https://profiles.google.com/](https://profiles.google.com/){id}, where {id} is the source id.
0040         DOMAIN_PROFILE, ///< [Google Workspace domain profile](https://support.google.com/a/answer/1628008).
0041         CONTACT, ///< [Google contact](https://contacts.google.com). You can view the contact at [https://contact.google.com/](https://contact.google.com/){id},
0042                  ///< where {id} is the source id.
0043         OTHER_CONTACT, ///< [Google "Other contact"](https://contacts.google.com/other).
0044         DOMAIN_CONTACT, ///< [Google Workspace domain shared contact](https://support.google.com/a/answer/9281635).
0045     };
0046 
0047     /** Constructs a new Source **/
0048     explicit Source();
0049     Source(const Source &);
0050     Source(Source &&) noexcept;
0051     Source &operator=(const Source &);
0052     Source &operator=(Source &&) noexcept;
0053     /** Destructor. **/
0054     ~Source();
0055 
0056     bool operator==(const Source &) const;
0057     bool operator!=(const Source &) const;
0058 
0059     [[nodiscard]] static Source fromJSON(const QJsonObject &);
0060     [[nodiscard]] QJsonValue toJSON() const;
0061 
0062     /** **Only populated in `person.metadata.sources`.** The [HTTP entity tag](https://en.wikipedia.org/wiki/HTTP_ETag) of the source. Used for web cache
0063      * validation. **/
0064     [[nodiscard]] QString etag() const;
0065     /** Sets value of the etag property. **/
0066     void setEtag(const QString &value);
0067 
0068     /** Output only. **Only populated in `person.metadata.sources`.** Metadata about a source of type PROFILE. **/
0069     [[nodiscard]] ProfileMetadata profileMetadata() const;
0070 
0071     /** The unique identifier within the source type generated by the server. **/
0072     [[nodiscard]] QString id() const;
0073     /** Sets value of the id property. **/
0074     void setId(const QString &value);
0075 
0076     /** Output only. **Only populated in `person.metadata.sources`.** Last update timestamp of this source. **/
0077     [[nodiscard]] QString updateTime() const;
0078 
0079     /** The source type. **/
0080     [[nodiscard]] Source::Type type() const;
0081     /** Sets value of the type property. **/
0082     void setType(Source::Type value);
0083 
0084 private:
0085     class Private;
0086     QSharedDataPointer<Private> d;
0087 }; // Source
0088 
0089 } // namespace KGAPI2::People