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 KGAPI2::People
0024 {
0025 class FieldMetadata;
0026 
0027 /**
0028  * A person's photo. A picture shown next to the person's name to help others
0029  * recognize the person.
0030  *
0031  * @see https://developers.google.com/people/api/rest/v1/people#photo
0032  * @since 5.23.0
0033  **/
0034 class KGAPIPEOPLE_EXPORT Photo
0035 {
0036 public:
0037     /** Constructs a new Photo **/
0038     explicit Photo();
0039     Photo(const Photo &);
0040     Photo(Photo &&) noexcept;
0041     Photo &operator=(const Photo &);
0042     Photo &operator=(Photo &&) noexcept;
0043     /** Destructor. **/
0044     ~Photo();
0045 
0046     bool operator==(const Photo &) const;
0047     bool operator!=(const Photo &) const;
0048 
0049     [[nodiscard]] static Photo fromJSON(const QJsonObject &);
0050     [[nodiscard]] static QList<Photo> fromJSONArray(const QJsonArray &data);
0051     [[nodiscard]] QJsonValue toJSON() const;
0052 
0053     /** Metadata about the photo. **/
0054     [[nodiscard]] FieldMetadata metadata() const;
0055     /** Sets value of the metadata property. **/
0056     void setMetadata(const FieldMetadata &value);
0057 
0058     /** True if the photo is a default photo; false if the photo is a user-provided photo. **/
0059     [[nodiscard]] bool isDefault() const;
0060     /** Sets value of the isDefault property. **/
0061     void setIsDefault(bool value);
0062 
0063     /** The URL of the photo. You can change the desired size by appending a query parameter `sz={size}` at the end of the url, where {size} is the size in
0064      * pixels. Example: https://lh3.googleusercontent.com/-T_wVWLlmg7w/AAAAAAAAAAI/AAAAAAAABa8/00gzXvDBYqw/s100/photo.jpg?sz=50 **/
0065     [[nodiscard]] QString url() const;
0066     /** Sets value of the url property. **/
0067     void setUrl(const QString &value);
0068 
0069 private:
0070     class Private;
0071     QSharedDataPointer<Private> d;
0072 }; // Photo
0073 
0074 } // namespace KGAPI2::People