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

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 class QJsonArray;
0022 
0023 namespace KGAPI2::People
0024 {
0025 class FieldMetadata;
0026 
0027 /**
0028  * A person's nickname.
0029  *
0030  * @see https://developers.google.com/people/api/rest/v1/people#nickname
0031  * @since 5.23.0
0032  **/
0033 class KGAPIPEOPLE_EXPORT Nickname
0034 {
0035 public:
0036     enum class Type {
0037         DEFAULT, ///< Generic nickname.
0038         MAIDEN_NAME, ///< Maiden name or birth family name. Used when the person's family name has changed as a result of marriage.
0039         INITIALS, ///< Initials.
0040         GPLUS, ///< Google+ profile nickname.
0041         OTHER_NAME, ///< A professional affiliation or other name; for example, `Dr. Smith.`
0042         ALTERNATE_NAME, ///< Alternate name person is known by.
0043         SHORT_NAME, ///< A shorter version of the person's name.
0044     };
0045 
0046     /** Constructs a new Nickname **/
0047     explicit Nickname();
0048     Nickname(const Nickname &);
0049     Nickname(Nickname &&) noexcept;
0050     Nickname &operator=(const Nickname &);
0051     Nickname &operator=(Nickname &&) noexcept;
0052     /** Destructor. **/
0053     ~Nickname();
0054 
0055     bool operator==(const Nickname &) const;
0056     bool operator!=(const Nickname &) const;
0057 
0058     [[nodiscard]] static Nickname fromJSON(const QJsonObject &);
0059     [[nodiscard]] static QList<Nickname> fromJSONArray(const QJsonArray &data);
0060     [[nodiscard]] QJsonValue toJSON() const;
0061 
0062     /** The nickname. **/
0063     [[nodiscard]] QString value() const;
0064     /** Sets value of the value property. **/
0065     void setValue(const QString &value);
0066 
0067     /** The type of the nickname. **/
0068     [[nodiscard]] Nickname::Type type() const;
0069     /** Sets value of the type property. **/
0070     void setType(Nickname::Type value);
0071 
0072     /** Metadata about the nickname. **/
0073     [[nodiscard]] FieldMetadata metadata() const;
0074     /** Sets value of the metadata property. **/
0075     void setMetadata(const FieldMetadata &value);
0076 
0077 private:
0078     class Private;
0079     QSharedDataPointer<Private> d;
0080 }; // Nickname
0081 
0082 } // namespace KGAPI2::People