aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/device_management.h
blob: 7fb698735fcfa8e125592e00bc2d569c5f180b87 (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
128
129
/******************************************************************************
 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
 */

#pragma once

#include "csapi/definitions/auth_data.h"
#include "csapi/definitions/client_device.h"

#include "jobs/basejob.h"

namespace Quotient {

/*! \brief List registered devices for the current user
 *
 * Gets information about all devices for the current user.
 */
class GetDevicesJob : public BaseJob {
public:
    /// List registered devices for the current user
    explicit GetDevicesJob();

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

    // Result properties

    /// A list of all registered devices for this user.
    QVector<Device> devices() const
    {
        return loadFromJson<QVector<Device>>("devices"_ls);
    }
};

/*! \brief Get a single device
 *
 * Gets information on a single device, by device id.
 */
class GetDeviceJob : public BaseJob {
public:
    /*! \brief Get a single device
     *
     * \param deviceId
     *   The device to retrieve.
     */
    explicit GetDeviceJob(const QString& deviceId);

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

    // Result properties

    /// Device information
    Device device() const { return fromJson<Device>(jsonData()); }
};

/*! \brief Update a device
 *
 * Updates the metadata on the given device.
 */
class UpdateDeviceJob : public BaseJob {
public:
    /*! \brief Update a device
     *
     * \param deviceId
     *   The device to update.
     *
     * \param displayName
     *   The new display name for this device. If not given, the
     *   display name is unchanged.
     */
    explicit UpdateDeviceJob(const QString& deviceId,
                             const QString& displayName = {});
};

/*! \brief Delete a device
 *
 * This API endpoint uses the [User-Interactive Authentication
 * API](/client-server-api/#user-interactive-authentication-api).
 *
 * Deletes the given device, and invalidates any access token associated with it.
 */
class DeleteDeviceJob : public BaseJob {
public:
    /*! \brief Delete a device
     *
     * \param deviceId
     *   The device to delete.
     *
     * \param auth
     *   Additional authentication information for the
     *   user-interactive authentication API.
     */
    explicit DeleteDeviceJob(const QString& deviceId,
                             const Omittable<AuthenticationData>& auth = none);
};

/*! \brief Bulk deletion of devices
 *
 * This API endpoint uses the [User-Interactive Authentication
 * API](/client-server-api/#user-interactive-authentication-api).
 *
 * Deletes the given devices, and invalidates any access token associated with
 * them.
 */
class DeleteDevicesJob : public BaseJob {
public:
    /*! \brief Bulk deletion of devices
     *
     * \param devices
     *   The list of device IDs to delete.
     *
     * \param auth
     *   Additional authentication information for the
     *   user-interactive authentication API.
     */
    explicit DeleteDevicesJob(const QStringList& devices,
                              const Omittable<AuthenticationData>& auth = none);
};

} // namespace Quotient