aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-18 18:42:02 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-18 18:42:02 +0900
commitf3a251404c00787b650e618fb5c257162507c18b (patch)
treea801eb5f444a8b2b3f8d93d2b64e22785bbf3f97 /lib/csapi
parent5e6b4bb975fa9697a6aca001629c65db506a437f (diff)
downloadlibquotient-f3a251404c00787b650e618fb5c257162507c18b.tar.gz
libquotient-f3a251404c00787b650e618fb5c257162507c18b.zip
csapi: third_party_lookup.* and its dependencies in application-service/
As per the latest API definitions.
Diffstat (limited to 'lib/csapi')
-rw-r--r--lib/csapi/third_party_lookup.cpp282
-rw-r--r--lib/csapi/third_party_lookup.h240
2 files changed, 522 insertions, 0 deletions
diff --git a/lib/csapi/third_party_lookup.cpp b/lib/csapi/third_party_lookup.cpp
new file mode 100644
index 00000000..783d6896
--- /dev/null
+++ b/lib/csapi/third_party_lookup.cpp
@@ -0,0 +1,282 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "third_party_lookup.h"
+
+#include "converters.h"
+
+#include <QtCore/QStringBuilder>
+
+using namespace QMatrixClient;
+
+static const auto basePath = QStringLiteral("/_matrix/client/r0");
+
+class GetProtocolsJob::Private
+{
+ public:
+ ProtocolMetadata data;
+};
+
+QUrl GetProtocolsJob::makeRequestUrl(QUrl baseUrl)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/thirdparty/protocols");
+}
+
+static const auto GetProtocolsJobName = QStringLiteral("GetProtocolsJob");
+
+GetProtocolsJob::GetProtocolsJob()
+ : BaseJob(HttpVerb::Get, GetProtocolsJobName,
+ basePath % "/thirdparty/protocols", false)
+ , d(new Private)
+{
+}
+
+GetProtocolsJob::~GetProtocolsJob() = default;
+
+const ProtocolMetadata& GetProtocolsJob::data() const
+{
+ return d->data;
+}
+
+BaseJob::Status GetProtocolsJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ if (!json.contains("data"_ls))
+ return { JsonParseError,
+ "The key 'data' not found in the response" };
+ d->data = fromJson<ProtocolMetadata>(json.value("data"_ls));
+ return Success;
+}
+
+class GetProtocolMetadataJob::Private
+{
+ public:
+ Protocol data;
+};
+
+QUrl GetProtocolMetadataJob::makeRequestUrl(QUrl baseUrl, const QString& protocol)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/thirdparty/protocol/" % protocol);
+}
+
+static const auto GetProtocolMetadataJobName = QStringLiteral("GetProtocolMetadataJob");
+
+GetProtocolMetadataJob::GetProtocolMetadataJob(const QString& protocol)
+ : BaseJob(HttpVerb::Get, GetProtocolMetadataJobName,
+ basePath % "/thirdparty/protocol/" % protocol, false)
+ , d(new Private)
+{
+}
+
+GetProtocolMetadataJob::~GetProtocolMetadataJob() = default;
+
+const Protocol& GetProtocolMetadataJob::data() const
+{
+ return d->data;
+}
+
+BaseJob::Status GetProtocolMetadataJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ if (!json.contains("data"_ls))
+ return { JsonParseError,
+ "The key 'data' not found in the response" };
+ d->data = fromJson<Protocol>(json.value("data"_ls));
+ return Success;
+}
+
+class QueryLocationByProtocolJob::Private
+{
+ public:
+ LocationBatch data;
+};
+
+BaseJob::Query queryToQueryLocationByProtocol(const QString& searchFields)
+{
+ BaseJob::Query _q;
+ addParam<IfNotEmpty>(_q, QStringLiteral("searchFields"), searchFields);
+ return _q;
+}
+
+QUrl QueryLocationByProtocolJob::makeRequestUrl(QUrl baseUrl, const QString& protocol, const QString& searchFields)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/thirdparty/location/" % protocol,
+ queryToQueryLocationByProtocol(searchFields));
+}
+
+static const auto QueryLocationByProtocolJobName = QStringLiteral("QueryLocationByProtocolJob");
+
+QueryLocationByProtocolJob::QueryLocationByProtocolJob(const QString& protocol, const QString& searchFields)
+ : BaseJob(HttpVerb::Get, QueryLocationByProtocolJobName,
+ basePath % "/thirdparty/location/" % protocol,
+ queryToQueryLocationByProtocol(searchFields),
+ {}, false)
+ , d(new Private)
+{
+}
+
+QueryLocationByProtocolJob::~QueryLocationByProtocolJob() = default;
+
+const LocationBatch& QueryLocationByProtocolJob::data() const
+{
+ return d->data;
+}
+
+BaseJob::Status QueryLocationByProtocolJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ if (!json.contains("data"_ls))
+ return { JsonParseError,
+ "The key 'data' not found in the response" };
+ d->data = fromJson<LocationBatch>(json.value("data"_ls));
+ return Success;
+}
+
+class QueryUserByProtocolJob::Private
+{
+ public:
+ UserBatch data;
+};
+
+BaseJob::Query queryToQueryUserByProtocol(const QString& field1Field2)
+{
+ BaseJob::Query _q;
+ addParam<IfNotEmpty>(_q, QStringLiteral("field1, field2..."), field1Field2);
+ return _q;
+}
+
+QUrl QueryUserByProtocolJob::makeRequestUrl(QUrl baseUrl, const QString& protocol, const QString& field1Field2)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/thirdparty/user/" % protocol,
+ queryToQueryUserByProtocol(field1Field2));
+}
+
+static const auto QueryUserByProtocolJobName = QStringLiteral("QueryUserByProtocolJob");
+
+QueryUserByProtocolJob::QueryUserByProtocolJob(const QString& protocol, const QString& field1Field2)
+ : BaseJob(HttpVerb::Get, QueryUserByProtocolJobName,
+ basePath % "/thirdparty/user/" % protocol,
+ queryToQueryUserByProtocol(field1Field2),
+ {}, false)
+ , d(new Private)
+{
+}
+
+QueryUserByProtocolJob::~QueryUserByProtocolJob() = default;
+
+const UserBatch& QueryUserByProtocolJob::data() const
+{
+ return d->data;
+}
+
+BaseJob::Status QueryUserByProtocolJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ if (!json.contains("data"_ls))
+ return { JsonParseError,
+ "The key 'data' not found in the response" };
+ d->data = fromJson<UserBatch>(json.value("data"_ls));
+ return Success;
+}
+
+class QueryLocationByAliasJob::Private
+{
+ public:
+ LocationBatch data;
+};
+
+BaseJob::Query queryToQueryLocationByAlias(const QString& alias)
+{
+ BaseJob::Query _q;
+ addParam<>(_q, QStringLiteral("alias"), alias);
+ return _q;
+}
+
+QUrl QueryLocationByAliasJob::makeRequestUrl(QUrl baseUrl, const QString& alias)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/thirdparty/location",
+ queryToQueryLocationByAlias(alias));
+}
+
+static const auto QueryLocationByAliasJobName = QStringLiteral("QueryLocationByAliasJob");
+
+QueryLocationByAliasJob::QueryLocationByAliasJob(const QString& alias)
+ : BaseJob(HttpVerb::Get, QueryLocationByAliasJobName,
+ basePath % "/thirdparty/location",
+ queryToQueryLocationByAlias(alias),
+ {}, false)
+ , d(new Private)
+{
+}
+
+QueryLocationByAliasJob::~QueryLocationByAliasJob() = default;
+
+const LocationBatch& QueryLocationByAliasJob::data() const
+{
+ return d->data;
+}
+
+BaseJob::Status QueryLocationByAliasJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ if (!json.contains("data"_ls))
+ return { JsonParseError,
+ "The key 'data' not found in the response" };
+ d->data = fromJson<LocationBatch>(json.value("data"_ls));
+ return Success;
+}
+
+class QueryUserByIDJob::Private
+{
+ public:
+ UserBatch data;
+};
+
+BaseJob::Query queryToQueryUserByID(const QString& userid)
+{
+ BaseJob::Query _q;
+ addParam<>(_q, QStringLiteral("userid"), userid);
+ return _q;
+}
+
+QUrl QueryUserByIDJob::makeRequestUrl(QUrl baseUrl, const QString& userid)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/thirdparty/user",
+ queryToQueryUserByID(userid));
+}
+
+static const auto QueryUserByIDJobName = QStringLiteral("QueryUserByIDJob");
+
+QueryUserByIDJob::QueryUserByIDJob(const QString& userid)
+ : BaseJob(HttpVerb::Get, QueryUserByIDJobName,
+ basePath % "/thirdparty/user",
+ queryToQueryUserByID(userid),
+ {}, false)
+ , d(new Private)
+{
+}
+
+QueryUserByIDJob::~QueryUserByIDJob() = default;
+
+const UserBatch& QueryUserByIDJob::data() const
+{
+ return d->data;
+}
+
+BaseJob::Status QueryUserByIDJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ if (!json.contains("data"_ls))
+ return { JsonParseError,
+ "The key 'data' not found in the response" };
+ d->data = fromJson<UserBatch>(json.value("data"_ls));
+ return Success;
+}
+
diff --git a/lib/csapi/third_party_lookup.h b/lib/csapi/third_party_lookup.h
new file mode 100644
index 00000000..c66902d7
--- /dev/null
+++ b/lib/csapi/third_party_lookup.h
@@ -0,0 +1,240 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "jobs/basejob.h"
+
+#include "csapi/../application-service/definitions/protocol_metadata.h"
+#include "csapi/../application-service/definitions/protocol.h"
+#include "converters.h"
+#include "csapi/../application-service/definitions/location_batch.h"
+#include "csapi/../application-service/definitions/user_batch.h"
+
+namespace QMatrixClient
+{
+ // Operations
+
+ /// Retrieve metadata about all protocols that a homeserver supports.
+ ///
+ /// Fetches the overall metadata about protocols supported by the
+ /// homeserver. Includes both the available protocols and all fields
+ /// required for queries against each protocol.
+ class GetProtocolsJob : public BaseJob
+ {
+ public:
+ explicit GetProtocolsJob();
+
+ /*! Construct a URL without creating a full-fledged job object
+ *
+ * This function can be used when a URL for
+ * GetProtocolsJob is necessary but the job
+ * itself isn't.
+ */
+ static QUrl makeRequestUrl(QUrl baseUrl);
+
+ ~GetProtocolsJob() override;
+
+ // Result properties
+
+ /// The protocols supported by the homeserver.
+ const ProtocolMetadata& data() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+
+ /// Retrieve metadata about a specific protocol that the homeserver supports.
+ ///
+ /// Fetches the metadata from the homeserver about a particular third party protocol.
+ class GetProtocolMetadataJob : public BaseJob
+ {
+ public:
+ /*! Retrieve metadata about a specific protocol that the homeserver supports.
+ * \param protocol
+ * The name of the protocol.
+ */
+ explicit GetProtocolMetadataJob(const QString& protocol);
+
+ /*! Construct a URL without creating a full-fledged job object
+ *
+ * This function can be used when a URL for
+ * GetProtocolMetadataJob is necessary but the job
+ * itself isn't.
+ */
+ static QUrl makeRequestUrl(QUrl baseUrl, const QString& protocol);
+
+ ~GetProtocolMetadataJob() override;
+
+ // Result properties
+
+ /// The protocol was found and metadata returned.
+ const Protocol& data() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+
+ /// Retreive Matrix-side portals rooms leading to a third party location.
+ ///
+ /// Requesting this endpoint with a valid protocol name results in a list
+ /// of successful mapping results in a JSON array. Each result contains
+ /// objects to represent the Matrix room or rooms that represent a portal
+ /// to this third party network. Each has the Matrix room alias string,
+ /// an identifier for the particular third party network protocol, and an
+ /// object containing the network-specific fields that comprise this
+ /// identifier. It should attempt to canonicalise the identifier as much
+ /// as reasonably possible given the network type.
+ class QueryLocationByProtocolJob : public BaseJob
+ {
+ public:
+ /*! Retreive Matrix-side portals rooms leading to a third party location.
+ * \param protocol
+ * The protocol used to communicate to the third party network.
+ * \param searchFields
+ * One or more custom fields to help identify the third party
+ * location.
+ */
+ explicit QueryLocationByProtocolJob(const QString& protocol, const QString& searchFields = {});
+
+ /*! Construct a URL without creating a full-fledged job object
+ *
+ * This function can be used when a URL for
+ * QueryLocationByProtocolJob is necessary but the job
+ * itself isn't.
+ */
+ static QUrl makeRequestUrl(QUrl baseUrl, const QString& protocol, const QString& searchFields = {});
+
+ ~QueryLocationByProtocolJob() override;
+
+ // Result properties
+
+ /// At least one portal room was found.
+ const LocationBatch& data() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+
+ /// Retrieve the Matrix User ID of a corresponding third party user.
+ ///
+ /// Retrieve a Matrix User ID linked to a user on the third party service, given
+ /// a set of user parameters.
+ class QueryUserByProtocolJob : public BaseJob
+ {
+ public:
+ /*! Retrieve the Matrix User ID of a corresponding third party user.
+ * \param protocol
+ * The name of the protocol.
+ * \param field1Field2
+ * One or more custom fields that are passed to the AS to help identify the user.
+ */
+ explicit QueryUserByProtocolJob(const QString& protocol, const QString& field1Field2 = {});
+
+ /*! Construct a URL without creating a full-fledged job object
+ *
+ * This function can be used when a URL for
+ * QueryUserByProtocolJob is necessary but the job
+ * itself isn't.
+ */
+ static QUrl makeRequestUrl(QUrl baseUrl, const QString& protocol, const QString& field1Field2 = {});
+
+ ~QueryUserByProtocolJob() override;
+
+ // Result properties
+
+ /// The Matrix User IDs found with the given parameters.
+ const UserBatch& data() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+
+ /// Reverse-lookup third party locations given a Matrix room alias.
+ ///
+ /// Retreive an array of third party network locations from a Matrix room
+ /// alias.
+ class QueryLocationByAliasJob : public BaseJob
+ {
+ public:
+ /*! Reverse-lookup third party locations given a Matrix room alias.
+ * \param alias
+ * The Matrix room alias to look up.
+ */
+ explicit QueryLocationByAliasJob(const QString& alias);
+
+ /*! Construct a URL without creating a full-fledged job object
+ *
+ * This function can be used when a URL for
+ * QueryLocationByAliasJob is necessary but the job
+ * itself isn't.
+ */
+ static QUrl makeRequestUrl(QUrl baseUrl, const QString& alias);
+
+ ~QueryLocationByAliasJob() override;
+
+ // Result properties
+
+ /// All found third party locations.
+ const LocationBatch& data() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+
+ /// Reverse-lookup third party users given a Matrix User ID.
+ ///
+ /// Retreive an array of third party users from a Matrix User ID.
+ class QueryUserByIDJob : public BaseJob
+ {
+ public:
+ /*! Reverse-lookup third party users given a Matrix User ID.
+ * \param userid
+ * The Matrix User ID to look up.
+ */
+ explicit QueryUserByIDJob(const QString& userid);
+
+ /*! Construct a URL without creating a full-fledged job object
+ *
+ * This function can be used when a URL for
+ * QueryUserByIDJob is necessary but the job
+ * itself isn't.
+ */
+ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userid);
+
+ ~QueryUserByIDJob() override;
+
+ // Result properties
+
+ /// An array of third party users.
+ const UserBatch& data() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+} // namespace QMatrixClient