libQuotient
A Qt library for building matrix clients
whoami.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 Gets information about the owner of an access token.
10 //!
11 //! Gets information about the owner of a given access token.
12 //!
13 //! Note that, as with the rest of the Client-Server API,
14 //! Application Services may masquerade as users within their
15 //! namespace by giving a `user_id` query parameter. In this
16 //! situation, the server should verify that the given `user_id`
17 //! is registered by the appservice, and return it in the response
18 //! body.
19 class QUOTIENT_API GetTokenOwnerJob : public BaseJob {
20 public:
21  explicit GetTokenOwnerJob();
22 
23  //! \brief Construct a URL without creating a full-fledged job object
24  //!
25  //! This function can be used when a URL for GetTokenOwnerJob
26  //! is necessary but the job itself isn't.
27  static QUrl makeRequestUrl(const HomeserverData& hsData);
28 
29  // Result properties
30 
31  //! The user ID that owns the access token.
32  QString userId() const { return loadFromJson<QString>("user_id"_L1); }
33 
34  //! Device ID associated with the access token. If no device
35  //! is associated with the access token (such as in the case
36  //! of application services) then this field can be omitted.
37  //! Otherwise this is required.
38  QString deviceId() const { return loadFromJson<QString>("device_id"_L1); }
39 
40  //! When `true`, the user is a [Guest User](#guest-access). When
41  //! not present or `false`, the user is presumed to be a non-guest
42  //! user.
43  std::optional<bool> isGuest() const { return loadFromJson<std::optional<bool>>("is_guest"_L1); }
44 
45  struct Response {
46  //! The user ID that owns the access token.
47  QString userId{};
48 
49  //! Device ID associated with the access token. If no device
50  //! is associated with the access token (such as in the case
51  //! of application services) then this field can be omitted.
52  //! Otherwise this is required.
53  QString deviceId{};
54 
55  //! When `true`, the user is a [Guest User](#guest-access). When
56  //! not present or `false`, the user is presumed to be a non-guest
57  //! user.
58  std::optional<bool> isGuest{};
59  };
60 };
61 
62 template <std::derived_from<GetTokenOwnerJob> JobT>
63 constexpr inline auto doCollectResponse<JobT> = [](JobT* j) -> GetTokenOwnerJob::Response {
64  return { j->userId(), j->deviceId(), j->isGuest() };
65 };
66 
67 } // namespace Quotient