libQuotient
A Qt library for building matrix clients
profile.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 the user's display name.
10 //!
11 //! This API sets the given user's display name. You must have permission to
12 //! set this user's display name, e.g. you need to have their `access_token`.
13 class QUOTIENT_API SetDisplayNameJob : public BaseJob {
14 public:
15  //! \param userId
16  //! The user whose display name to set.
17  //!
18  //! \param displayname
19  //! The new display name for this user.
20  explicit SetDisplayNameJob(const QString& userId, const QString& displayname);
21 };
22 
23 //! \brief Get the user's display name.
24 //!
25 //! Get the user's display name. This API may be used to fetch the user's
26 //! own displayname or to query the name of other users; either locally or
27 //! on remote homeservers.
28 class QUOTIENT_API GetDisplayNameJob : public BaseJob {
29 public:
30  //! \param userId
31  //! The user whose display name to get.
32  explicit GetDisplayNameJob(const QString& userId);
33 
34  //! \brief Construct a URL without creating a full-fledged job object
35  //!
36  //! This function can be used when a URL for GetDisplayNameJob
37  //! is necessary but the job itself isn't.
38  static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userId);
39 
40  // Result properties
41 
42  //! The user's display name if they have set one, otherwise not present.
43  QString displayname() const { return loadFromJson<QString>("displayname"_L1); }
44 };
45 
46 inline auto collectResponse(const GetDisplayNameJob* job) { return job->displayname(); }
47 
48 //! \brief Set the user's avatar URL.
49 //!
50 //! This API sets the given user's avatar URL. You must have permission to
51 //! set this user's avatar URL, e.g. you need to have their `access_token`.
52 class QUOTIENT_API SetAvatarUrlJob : public BaseJob {
53 public:
54  //! \param userId
55  //! The user whose avatar URL to set.
56  //!
57  //! \param avatarUrl
58  //! The new avatar URL for this user.
59  explicit SetAvatarUrlJob(const QString& userId, const QUrl& avatarUrl);
60 };
61 
62 //! \brief Get the user's avatar URL.
63 //!
64 //! Get the user's avatar URL. This API may be used to fetch the user's
65 //! own avatar URL or to query the URL of other users; either locally or
66 //! on remote homeservers.
67 class QUOTIENT_API GetAvatarUrlJob : public BaseJob {
68 public:
69  //! \param userId
70  //! The user whose avatar URL to get.
71  explicit GetAvatarUrlJob(const QString& userId);
72 
73  //! \brief Construct a URL without creating a full-fledged job object
74  //!
75  //! This function can be used when a URL for GetAvatarUrlJob
76  //! is necessary but the job itself isn't.
77  static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userId);
78 
79  // Result properties
80 
81  //! The user's avatar URL if they have set one, otherwise not present.
82  QUrl avatarUrl() const { return loadFromJson<QUrl>("avatar_url"_L1); }
83 };
84 
85 inline auto collectResponse(const GetAvatarUrlJob* job) { return job->avatarUrl(); }
86 
87 //! \brief Get this user's profile information.
88 //!
89 //! Get the combined profile information for this user. This API may be used
90 //! to fetch the user's own profile information or other users; either
91 //! locally or on remote homeservers.
92 class QUOTIENT_API GetUserProfileJob : public BaseJob {
93 public:
94  //! \param userId
95  //! The user whose profile information to get.
96  explicit GetUserProfileJob(const QString& userId);
97 
98  //! \brief Construct a URL without creating a full-fledged job object
99  //!
100  //! This function can be used when a URL for GetUserProfileJob
101  //! is necessary but the job itself isn't.
102  static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userId);
103 
104  // Result properties
105 
106  //! The user's avatar URL if they have set one, otherwise not present.
107  QUrl avatarUrl() const { return loadFromJson<QUrl>("avatar_url"_L1); }
108 
109  //! The user's display name if they have set one, otherwise not present.
110  QString displayname() const { return loadFromJson<QString>("displayname"_L1); }
111 
112  struct Response {
113  //! The user's avatar URL if they have set one, otherwise not present.
114  QUrl avatarUrl{};
115 
116  //! The user's display name if they have set one, otherwise not present.
117  QString displayname{};
118  };
119 };
120 
121 template <std::derived_from<GetUserProfileJob> JobT>
122 constexpr inline auto doCollectResponse<JobT> =
123  [](JobT* j) -> GetUserProfileJob::Response { return { j->avatarUrl(), j->displayname() }; };
124 
125 } // namespace Quotient