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 KContacts {
0024 class Addressee;
0025 }
0026 
0027 namespace KGAPI2::People
0028 {
0029 class FieldMetadata;
0030 
0031 /**
0032  * A person's name. If the name is a mononym, the family name is empty.
0033  *
0034  * @see https://developers.google.com/people/api/rest/v1/people#name
0035  * @since 5.23.0
0036  **/
0037 class KGAPIPEOPLE_EXPORT Name
0038 {
0039 public:
0040     /** Constructs a new Name **/
0041     explicit Name();
0042     Name(const Name &);
0043     Name(Name &&) noexcept;
0044     Name &operator=(const Name &);
0045     Name &operator=(Name &&) noexcept;
0046     /** Destructor. **/
0047     ~Name();
0048 
0049     bool operator==(const Name &) const;
0050     bool operator!=(const Name &) const;
0051 
0052     [[nodiscard]] static Name fromJSON(const QJsonObject &);
0053     [[nodiscard]] static QList<Name> fromJSONArray(const QJsonArray &data);
0054     [[nodiscard]] QJsonValue toJSON() const;
0055 
0056     [[nodiscard]] static Name fromKContactsAddressee(const KContacts::Addressee &addressee);
0057     void applyToKContactsAddressee(KContacts::Addressee &addressee) const;
0058 
0059     /** The free form name value. **/
0060     [[nodiscard]] QString unstructuredName() const;
0061     /** Sets value of the unstructuredName property. **/
0062     void setUnstructuredName(const QString &value);
0063 
0064     /** The family name. **/
0065     [[nodiscard]] QString familyName() const;
0066     /** Sets value of the familyName property. **/
0067     void setFamilyName(const QString &value);
0068 
0069     /** The middle name(s) spelled as they sound. **/
0070     [[nodiscard]] QString phoneticMiddleName() const;
0071     /** Sets value of the phoneticMiddleName property. **/
0072     void setPhoneticMiddleName(const QString &value);
0073 
0074     /** The middle name(s). **/
0075     [[nodiscard]] QString middleName() const;
0076     /** Sets value of the middleName property. **/
0077     void setMiddleName(const QString &value);
0078 
0079     /** The honorific prefixes, such as `Mrs.` or `Dr.` **/
0080     [[nodiscard]] QString honorificPrefix() const;
0081     /** Sets value of the honorificPrefix property. **/
0082     void setHonorificPrefix(const QString &value);
0083 
0084     /** The given name. **/
0085     [[nodiscard]] QString givenName() const;
0086     /** Sets value of the givenName property. **/
0087     void setGivenName(const QString &value);
0088 
0089     /** The given name spelled as it sounds. **/
0090     [[nodiscard]] QString phoneticGivenName() const;
0091     /** Sets value of the phoneticGivenName property. **/
0092     void setPhoneticGivenName(const QString &value);
0093 
0094     /** The honorific prefixes spelled as they sound. **/
0095     [[nodiscard]] QString phoneticHonorificPrefix() const;
0096     /** Sets value of the phoneticHonorificPrefix property. **/
0097     void setPhoneticHonorificPrefix(const QString &value);
0098 
0099     /** Output only. The display name formatted according to the locale specified by the viewer's account or the `Accept-Language` HTTP header. **/
0100     [[nodiscard]] QString displayName() const;
0101 
0102     /** Output only. The display name with the last name first formatted according to the locale specified by the viewer's account or the `Accept-Language` HTTP
0103      * header. **/
0104     [[nodiscard]] QString displayNameLastFirst() const;
0105 
0106     /** The family name spelled as it sounds. **/
0107     [[nodiscard]] QString phoneticFamilyName() const;
0108     /** Sets value of the phoneticFamilyName property. **/
0109     void setPhoneticFamilyName(const QString &value);
0110 
0111     /** The honorific suffixes, such as `Jr.` **/
0112     [[nodiscard]] QString honorificSuffix() const;
0113     /** Sets value of the honorificSuffix property. **/
0114     void setHonorificSuffix(const QString &value);
0115 
0116     /** The honorific suffixes spelled as they sound. **/
0117     [[nodiscard]] QString phoneticHonorificSuffix() const;
0118     /** Sets value of the phoneticHonorificSuffix property. **/
0119     void setPhoneticHonorificSuffix(const QString &value);
0120 
0121     /** The full name spelled as it sounds. **/
0122     [[nodiscard]] QString phoneticFullName() const;
0123     /** Sets value of the phoneticFullName property. **/
0124     void setPhoneticFullName(const QString &value);
0125 
0126     /** Metadata about the name. **/
0127     [[nodiscard]] FieldMetadata metadata() const;
0128     /** Sets value of the metadata property. **/
0129     void setMetadata(const FieldMetadata &value);
0130 
0131 private:
0132     class Private;
0133     QSharedDataPointer<Private> d;
0134 }; // Name
0135 
0136 } // namespace KGAPI2::People