File indexing completed on 2024-05-12 05:22:26
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 { 0025 class Email; 0026 } 0027 0028 namespace KGAPI2::People 0029 { 0030 class FieldMetadata; 0031 0032 /** 0033 * A person's email address. 0034 * 0035 * @see https://developers.google.com/people/api/rest/v1/people#emailaddress 0036 * @since 5.23.0 0037 **/ 0038 class KGAPIPEOPLE_EXPORT EmailAddress 0039 { 0040 public: 0041 /** Constructs a new EmailAddress **/ 0042 explicit EmailAddress(); 0043 EmailAddress(const EmailAddress &); 0044 EmailAddress(EmailAddress &&) noexcept; 0045 EmailAddress &operator=(const EmailAddress &); 0046 EmailAddress &operator=(EmailAddress &&) noexcept; 0047 /** Destructor. **/ 0048 ~EmailAddress(); 0049 0050 bool operator==(const EmailAddress &) const; 0051 bool operator!=(const EmailAddress &) const; 0052 0053 [[nodiscard]] static EmailAddress fromJSON(const QJsonObject &obj); 0054 [[nodiscard]] static QList<EmailAddress> fromJSONArray(const QJsonArray &data); 0055 [[nodiscard]] QJsonValue toJSON() const; 0056 0057 [[nodiscard]] static EmailAddress fromKContactsEmail(const KContacts::Email &email); 0058 [[nodiscard]] static QList<EmailAddress> fromKContactsEmailList(const QList<KContacts::Email> &emailList); 0059 [[nodiscard]] KContacts::Email toKContactsEmail() const; 0060 0061 /** The email address. **/ 0062 [[nodiscard]] QString value() const; 0063 /** Sets value of the value property. **/ 0064 void setValue(const QString &value); 0065 0066 /** Metadata about the email address. **/ 0067 [[nodiscard]] FieldMetadata metadata() const; 0068 /** Sets value of the metadata property. **/ 0069 void setMetadata(const FieldMetadata &value); 0070 0071 /** The type of the email address. The type can be custom or one of these predefined values: * `home` * `work` * `other` **/ 0072 [[nodiscard]] QString type() const; 0073 /** Sets value of the type property. **/ 0074 void setType(const QString &value); 0075 0076 /** The display name of the email. **/ 0077 [[nodiscard]] QString displayName() const; 0078 /** Sets value of the displayName property. **/ 0079 void setDisplayName(const QString &value); 0080 0081 /** Output only. The type of the email address translated and formatted in the viewer's account locale or the `Accept-Language` HTTP header locale. **/ 0082 [[nodiscard]] QString formattedType() const; 0083 0084 private: 0085 class Private; 0086 QSharedDataPointer<Private> d; 0087 }; // EmailAddress 0088 0089 } // namespace KGAPI2::People