libQuotient
A Qt library for building matrix clients
third_party_lookup.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 #include <Quotient/application-service/definitions/location.h>
8 #include <Quotient/application-service/definitions/protocol.h>
9 #include <Quotient/application-service/definitions/user.h>
10 
11 namespace Quotient {
12 
13 //! \brief Retrieve metadata about all protocols that a homeserver supports.
14 //!
15 //! Fetches the overall metadata about protocols supported by the
16 //! homeserver. Includes both the available protocols and all fields
17 //! required for queries against each protocol.
18 class QUOTIENT_API GetProtocolsJob : public BaseJob {
19 public:
20  explicit GetProtocolsJob();
21 
22  //! \brief Construct a URL without creating a full-fledged job object
23  //!
24  //! This function can be used when a URL for GetProtocolsJob
25  //! is necessary but the job itself isn't.
26  static QUrl makeRequestUrl(const HomeserverData& hsData);
27 
28  // Result properties
29 
30  //! The protocols supported by the homeserver.
31  QHash<QString, ThirdPartyProtocol> protocols() const
32  {
33  return fromJson<QHash<QString, ThirdPartyProtocol>>(jsonData());
34  }
35 };
36 
37 inline auto collectResponse(const GetProtocolsJob* job) { return job->protocols(); }
38 
39 //! \brief Retrieve metadata about a specific protocol that the homeserver supports.
40 //!
41 //! Fetches the metadata from the homeserver about a particular third-party protocol.
42 class QUOTIENT_API GetProtocolMetadataJob : public BaseJob {
43 public:
44  //! \param protocol
45  //! The name of the protocol.
46  explicit GetProtocolMetadataJob(const QString& protocol);
47 
48  //! \brief Construct a URL without creating a full-fledged job object
49  //!
50  //! This function can be used when a URL for GetProtocolMetadataJob
51  //! is necessary but the job itself isn't.
52  static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& protocol);
53 
54  // Result properties
55 
56  //! The protocol was found and metadata returned.
57  ThirdPartyProtocol data() const { return fromJson<ThirdPartyProtocol>(jsonData()); }
58 };
59 
60 inline auto collectResponse(const GetProtocolMetadataJob* job) { return job->data(); }
61 
62 //! \brief Retrieve Matrix-side portals rooms leading to a third-party location.
63 //!
64 //! Requesting this endpoint with a valid protocol name results in a list
65 //! of successful mapping results in a JSON array. Each result contains
66 //! objects to represent the Matrix room or rooms that represent a portal
67 //! to this third-party network. Each has the Matrix room alias string,
68 //! an identifier for the particular third-party network protocol, and an
69 //! object containing the network-specific fields that comprise this
70 //! identifier. It should attempt to canonicalise the identifier as much
71 //! as reasonably possible given the network type.
72 class QUOTIENT_API QueryLocationByProtocolJob : public BaseJob {
73 public:
74  //! \param protocol
75  //! The protocol used to communicate to the third-party network.
76  //!
77  //! \param searchFields
78  //! One or more custom fields to help identify the third-party
79  //! location.
80  explicit QueryLocationByProtocolJob(const QString& protocol, const QString& searchFields = {});
81 
82  //! \brief Construct a URL without creating a full-fledged job object
83  //!
84  //! This function can be used when a URL for QueryLocationByProtocolJob
85  //! is necessary but the job itself isn't.
86  static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& protocol,
87  const QString& searchFields = {});
88 
89  // Result properties
90 
91  //! At least one portal room was found.
92  QVector<ThirdPartyLocation> data() const
93  {
94  return fromJson<QVector<ThirdPartyLocation>>(jsonData());
95  }
96 };
97 
98 inline auto collectResponse(const QueryLocationByProtocolJob* job) { return job->data(); }
99 
100 //! \brief Retrieve the Matrix User ID of a corresponding third-party user.
101 //!
102 //! Retrieve a Matrix User ID linked to a user on the third-party service, given
103 //! a set of user parameters.
104 class QUOTIENT_API QueryUserByProtocolJob : public BaseJob {
105 public:
106  //! \param protocol
107  //! The name of the protocol.
108  //!
109  //! \param fields
110  //! One or more custom fields that are passed to the AS to help identify the user.
111  explicit QueryUserByProtocolJob(const QString& protocol,
112  const QHash<QString, QString>& fields = {});
113 
114  //! \brief Construct a URL without creating a full-fledged job object
115  //!
116  //! This function can be used when a URL for QueryUserByProtocolJob
117  //! is necessary but the job itself isn't.
118  static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& protocol,
119  const QHash<QString, QString>& fields = {});
120 
121  // Result properties
122 
123  //! The Matrix User IDs found with the given parameters.
124  QVector<ThirdPartyUser> data() const { return fromJson<QVector<ThirdPartyUser>>(jsonData()); }
125 };
126 
127 inline auto collectResponse(const QueryUserByProtocolJob* job) { return job->data(); }
128 
129 //! \brief Reverse-lookup third-party locations given a Matrix room alias.
130 //!
131 //! Retrieve an array of third-party network locations from a Matrix room
132 //! alias.
133 class QUOTIENT_API QueryLocationByAliasJob : public BaseJob {
134 public:
135  //! \param alias
136  //! The Matrix room alias to look up.
137  explicit QueryLocationByAliasJob(const QString& alias);
138 
139  //! \brief Construct a URL without creating a full-fledged job object
140  //!
141  //! This function can be used when a URL for QueryLocationByAliasJob
142  //! is necessary but the job itself isn't.
143  static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& alias);
144 
145  // Result properties
146 
147  //! All found third-party locations.
148  QVector<ThirdPartyLocation> data() const
149  {
150  return fromJson<QVector<ThirdPartyLocation>>(jsonData());
151  }
152 };
153 
154 inline auto collectResponse(const QueryLocationByAliasJob* job) { return job->data(); }
155 
156 //! \brief Reverse-lookup third-party users given a Matrix User ID.
157 //!
158 //! Retrieve an array of third-party users from a Matrix User ID.
159 class QUOTIENT_API QueryUserByIDJob : public BaseJob {
160 public:
161  //! \param userid
162  //! The Matrix User ID to look up.
163  explicit QueryUserByIDJob(const QString& userid);
164 
165  //! \brief Construct a URL without creating a full-fledged job object
166  //!
167  //! This function can be used when a URL for QueryUserByIDJob
168  //! is necessary but the job itself isn't.
169  static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userid);
170 
171  // Result properties
172 
173  //! An array of third-party users.
174  QVector<ThirdPartyUser> data() const { return fromJson<QVector<ThirdPartyUser>>(jsonData()); }
175 };
176 
177 inline auto collectResponse(const QueryUserByIDJob* job) { return job->data(); }
178 
179 } // namespace Quotient