aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/tags.h
blob: f4250674be89fc85d0142c0366fe844ec330c8b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/******************************************************************************
 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
 */

#pragma once

#include "jobs/basejob.h"

namespace Quotient {

/*! \brief List the tags for a room.
 *
 * List the tags set by a user on a room.
 */
class QUOTIENT_API GetRoomTagsJob : public BaseJob {
public:
    // Inner data structures

    /// List the tags set by a user on a room.
    struct Tag {
        /// A number in a range `[0,1]` describing a relative
        /// position of the room under the given tag.
        Omittable<float> order;
        /// List the tags set by a user on a room.
        QVariantHash additionalProperties;
    };

    // Construction/destruction

    /*! \brief List the tags for a room.
     *
     * \param userId
     *   The id of the user to get tags for. The access token must be
     *   authorized to make requests for this user ID.
     *
     * \param roomId
     *   The ID of the room to get tags for.
     */
    explicit GetRoomTagsJob(const QString& userId, const QString& roomId);

    /*! \brief Construct a URL without creating a full-fledged job object
     *
     * This function can be used when a URL for GetRoomTagsJob
     * is necessary but the job itself isn't.
     */
    static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId,
                               const QString& roomId);

    // Result properties

    /// List the tags set by a user on a room.
    QHash<QString, Tag> tags() const
    {
        return loadFromJson<QHash<QString, Tag>>("tags"_ls);
    }
};

template <>
struct JsonObjectConverter<GetRoomTagsJob::Tag> {
    static void fillFrom(QJsonObject jo, GetRoomTagsJob::Tag& result)
    {
        fromJson(jo.take("order"_ls), result.order);
        fromJson(jo, result.additionalProperties);
    }
};

/*! \brief Add a tag to a room.
 *
 * Add a tag to the room.
 */
class QUOTIENT_API SetRoomTagJob : public BaseJob {
public:
    /*! \brief Add a tag to a room.
     *
     * \param userId
     *   The id of the user to add a tag for. The access token must be
     *   authorized to make requests for this user ID.
     *
     * \param roomId
     *   The ID of the room to add a tag to.
     *
     * \param tag
     *   The tag to add.
     *
     * \param order
     *   A number in a range `[0,1]` describing a relative
     *   position of the room under the given tag.
     *
     * \param additionalProperties
     *   Add a tag to the room.
     */
    explicit SetRoomTagJob(const QString& userId, const QString& roomId,
                           const QString& tag, Omittable<float> order = none,
                           const QVariantHash& additionalProperties = {});
};

/*! \brief Remove a tag from the room.
 *
 * Remove a tag from the room.
 */
class QUOTIENT_API DeleteRoomTagJob : public BaseJob {
public:
    /*! \brief Remove a tag from the room.
     *
     * \param userId
     *   The id of the user to remove a tag for. The access token must be
     *   authorized to make requests for this user ID.
     *
     * \param roomId
     *   The ID of the room to remove a tag from.
     *
     * \param tag
     *   The tag to remove.
     */
    explicit DeleteRoomTagJob(const QString& userId, const QString& roomId,
                              const QString& tag);

    /*! \brief Construct a URL without creating a full-fledged job object
     *
     * This function can be used when a URL for DeleteRoomTagJob
     * is necessary but the job itself isn't.
     */
    static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId,
                               const QString& roomId, const QString& tag);
};

} // namespace Quotient