libQuotient
A Qt library for building matrix clients
account-data.h
Go to the documentation of this file.
1 // THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
2 
3 #pragma once
4 
5 #include <Quotient/jobs/basejob.h>
6 
7 namespace Quotient {
8 
9 //! \brief Set some account data for the user.
10 //!
11 //! Set some account data for the client. This config is only visible to the user
12 //! that set the account data. The config will be available to clients through the
13 //! top-level `account_data` field in the homeserver response to
14 //! [/sync](#get_matrixclientv3sync).
15 class QUOTIENT_API SetAccountDataJob : public BaseJob {
16 public:
17  //! \param userId
18  //! The ID of the user to set account data for. The access token must be
19  //! authorized to make requests for this user ID.
20  //!
21  //! \param type
22  //! The event type of the account data to set. Custom types should be
23  //! namespaced to avoid clashes.
24  //!
25  //! \param content
26  //! The content of the account data.
27  explicit SetAccountDataJob(const QString& userId, const QString& type,
28  const QJsonObject& content = {});
29 };
30 
31 //! \brief Get some account data for the user.
32 //!
33 //! Get some account data for the client. This config is only visible to the user
34 //! that set the account data.
35 class QUOTIENT_API GetAccountDataJob : public BaseJob {
36 public:
37  //! \param userId
38  //! The ID of the user to get account data for. The access token must be
39  //! authorized to make requests for this user ID.
40  //!
41  //! \param type
42  //! The event type of the account data to get. Custom types should be
43  //! namespaced to avoid clashes.
44  explicit GetAccountDataJob(const QString& userId, const QString& type);
45 
46  //! \brief Construct a URL without creating a full-fledged job object
47  //!
48  //! This function can be used when a URL for GetAccountDataJob
49  //! is necessary but the job itself isn't.
50  static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userId,
51  const QString& type);
52 
53  // Result properties
54 
55  //! The account data content for the given type.
56  QJsonObject data() const { return fromJson<QJsonObject>(jsonData()); }
57 };
58 
59 inline auto collectResponse(const GetAccountDataJob* job) { return job->data(); }
60 
61 //! \brief Set some account data for the user that is specific to a room.
62 //!
63 //! Set some account data for the client on a given room. This config is only
64 //! visible to the user that set the account data. The config will be delivered to
65 //! clients in the per-room entries via [/sync](#get_matrixclientv3sync).
66 class QUOTIENT_API SetAccountDataPerRoomJob : public BaseJob {
67 public:
68  //! \param userId
69  //! The ID of the user to set account data for. The access token must be
70  //! authorized to make requests for this user ID.
71  //!
72  //! \param roomId
73  //! The ID of the room to set account data on.
74  //!
75  //! \param type
76  //! The event type of the account data to set. Custom types should be
77  //! namespaced to avoid clashes.
78  //!
79  //! \param content
80  //! The content of the account data.
81  explicit SetAccountDataPerRoomJob(const QString& userId, const QString& roomId,
82  const QString& type, const QJsonObject& content = {});
83 };
84 
85 //! \brief Get some account data for the user that is specific to a room.
86 //!
87 //! Get some account data for the client on a given room. This config is only
88 //! visible to the user that set the account data.
89 class QUOTIENT_API GetAccountDataPerRoomJob : public BaseJob {
90 public:
91  //! \param userId
92  //! The ID of the user to get account data for. The access token must be
93  //! authorized to make requests for this user ID.
94  //!
95  //! \param roomId
96  //! The ID of the room to get account data for.
97  //!
98  //! \param type
99  //! The event type of the account data to get. Custom types should be
100  //! namespaced to avoid clashes.
101  explicit GetAccountDataPerRoomJob(const QString& userId, const QString& roomId,
102  const QString& type);
103 
104  //! \brief Construct a URL without creating a full-fledged job object
105  //!
106  //! This function can be used when a URL for GetAccountDataPerRoomJob
107  //! is necessary but the job itself isn't.
108  static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userId,
109  const QString& roomId, const QString& type);
110 
111  // Result properties
112 
113  //! The account data content for the given type.
114  QJsonObject data() const { return fromJson<QJsonObject>(jsonData()); }
115 };
116 
117 inline auto collectResponse(const GetAccountDataPerRoomJob* job) { return job->data(); }
118 
119 } // namespace Quotient