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 class QJsonArray;
0022 
0023 namespace KContacts {
0024 class PhoneNumber;
0025 }
0026 
0027 namespace KGAPI2::People
0028 {
0029 class FieldMetadata;
0030 
0031 /**
0032  * A person's phone number.
0033  *
0034  * @see https://developers.google.com/people/api/rest/v1/people#phonenumber
0035  * @since 5.23.0
0036  **/
0037 class KGAPIPEOPLE_EXPORT PhoneNumber
0038 {
0039 public:
0040     /** Constructs a new PhoneNumber **/
0041     explicit PhoneNumber();
0042     PhoneNumber(const PhoneNumber &);
0043     PhoneNumber(PhoneNumber &&) noexcept;
0044     PhoneNumber &operator=(const PhoneNumber &);
0045     PhoneNumber &operator=(PhoneNumber &&) noexcept;
0046     /** Destructor. **/
0047     ~PhoneNumber();
0048 
0049     bool operator==(const PhoneNumber &) const;
0050     bool operator!=(const PhoneNumber &) const;
0051 
0052     [[nodiscard]] static PhoneNumber fromJSON(const QJsonObject &);
0053     [[nodiscard]] static QList<PhoneNumber> fromJSONArray(const QJsonArray &data);
0054     [[nodiscard]] QJsonValue toJSON() const;
0055 
0056     [[nodiscard]] static PhoneNumber fromKContactsPhoneNumber(const KContacts::PhoneNumber &phoneNumber);
0057     [[nodiscard]] static QList<PhoneNumber> fromKContactsPhoneNumberList(const QList<KContacts::PhoneNumber> &phoneNumberList);
0058     [[nodiscard]] KContacts::PhoneNumber toKContactsPhoneNumber() const;
0059 
0060     /** The phone number. **/
0061     [[nodiscard]] QString value() const;
0062     /** Sets value of the value property. **/
0063     void setValue(const QString &value);
0064 
0065     /** Output only. The type of the phone number translated and formatted in the viewer's account locale or the `Accept-Language` HTTP header locale. **/
0066     [[nodiscard]] QString formattedType() const;
0067 
0068     /** Output only. The canonicalized [ITU-T E.164](https://law.resource.org/pub/us/cfr/ibr/004/itu-t.E.164.1.2008.pdf) form of the phone number. **/
0069     [[nodiscard]] QString canonicalForm() const;
0070 
0071     /** The type of the phone number. The type can be custom or one of these predefined values: * `home` * `work` * `mobile` * `homeFax` * `workFax` *
0072      * `otherFax` * `pager` * `workMobile` * `workPager` * `main` * `googleVoice` * `other` **/
0073     [[nodiscard]] QString type() const;
0074     /** Sets value of the type property. **/
0075     void setType(const QString &value);
0076 
0077     /** Metadata about the phone number. **/
0078     [[nodiscard]] FieldMetadata metadata() const;
0079     /** Sets value of the metadata property. **/
0080     void setMetadata(const FieldMetadata &value);
0081 
0082 private:
0083     class Private;
0084     QSharedDataPointer<Private> d;
0085 }; // PhoneNumber
0086 
0087 } // namespace KGAPI2::People