diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-02-27 20:18:32 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-02-27 20:18:32 +0900 |
commit | f1f71255fb1a9e90dadd34fd055d14155da485ea (patch) | |
tree | 51e5f19853ee1e0bda74af3e9693c654311cffa6 /jobs | |
parent | 292ed58962fb11d6572e273bcb4d2ad762d60365 (diff) | |
download | libquotient-f1f71255fb1a9e90dadd34fd055d14155da485ea.tar.gz libquotient-f1f71255fb1a9e90dadd34fd055d14155da485ea.zip |
jobs/generated: GetPushersJob, PostPusherJob
Diffstat (limited to 'jobs')
-rw-r--r-- | jobs/generated/pusher.cpp | 153 | ||||
-rw-r--r-- | jobs/generated/pusher.h | 81 |
2 files changed, 234 insertions, 0 deletions
diff --git a/jobs/generated/pusher.cpp b/jobs/generated/pusher.cpp new file mode 100644 index 00000000..4fddac45 --- /dev/null +++ b/jobs/generated/pusher.cpp @@ -0,0 +1,153 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "pusher.h" + +#include <QtCore/QStringBuilder> + +using namespace QMatrixClient; + +static const auto basePath = QStringLiteral("/_matrix/client/r0"); + +GetPushersJob::PusherData::operator QJsonObject() const +{ + QJsonObject o; + o.insert("url", toJson(url)); + + return o; +} +namespace QMatrixClient +{ + template <> struct FromJson<GetPushersJob::PusherData> + { + GetPushersJob::PusherData operator()(QJsonValue jv) + { + QJsonObject o = jv.toObject(); + GetPushersJob::PusherData result; + result.url = + fromJson<QString>(o.value("url")); + + return result; + } + }; +} // namespace QMatrixClient + +GetPushersJob::Pusher::operator QJsonObject() const +{ + QJsonObject o; + o.insert("pushkey", toJson(pushkey)); + o.insert("kind", toJson(kind)); + o.insert("app_id", toJson(appId)); + o.insert("app_display_name", toJson(appDisplayName)); + o.insert("device_display_name", toJson(deviceDisplayName)); + o.insert("profile_tag", toJson(profileTag)); + o.insert("lang", toJson(lang)); + o.insert("data", toJson(data)); + + return o; +} +namespace QMatrixClient +{ + template <> struct FromJson<GetPushersJob::Pusher> + { + GetPushersJob::Pusher operator()(QJsonValue jv) + { + QJsonObject o = jv.toObject(); + GetPushersJob::Pusher result; + result.pushkey = + fromJson<QString>(o.value("pushkey")); + result.kind = + fromJson<QString>(o.value("kind")); + result.appId = + fromJson<QString>(o.value("app_id")); + result.appDisplayName = + fromJson<QString>(o.value("app_display_name")); + result.deviceDisplayName = + fromJson<QString>(o.value("device_display_name")); + result.profileTag = + fromJson<QString>(o.value("profile_tag")); + result.lang = + fromJson<QString>(o.value("lang")); + result.data = + fromJson<GetPushersJob::PusherData>(o.value("data")); + + return result; + } + }; +} // namespace QMatrixClient + +class GetPushersJob::Private +{ + public: + QVector<Pusher> pushers; +}; + +QUrl GetPushersJob::makeRequestUrl(QUrl baseUrl) +{ + return BaseJob::makeRequestUrl(baseUrl, + basePath % "/pushers"); +} + +GetPushersJob::GetPushersJob() + : BaseJob(HttpVerb::Get, "GetPushersJob", + basePath % "/pushers") + , d(new Private) +{ +} + +GetPushersJob::~GetPushersJob() = default; + +const QVector<GetPushersJob::Pusher>& GetPushersJob::pushers() const +{ + return d->pushers; +} + +BaseJob::Status GetPushersJob::parseJson(const QJsonDocument& data) +{ + auto json = data.object(); + d->pushers = fromJson<QVector<Pusher>>(json.value("pushers")); + return Success; +} + +PostPusherJob::PusherData::operator QJsonObject() const +{ + QJsonObject o; + o.insert("url", toJson(url)); + + return o; +} +namespace QMatrixClient +{ + template <> struct FromJson<PostPusherJob::PusherData> + { + PostPusherJob::PusherData operator()(QJsonValue jv) + { + QJsonObject o = jv.toObject(); + PostPusherJob::PusherData result; + result.url = + fromJson<QString>(o.value("url")); + + return result; + } + }; +} // namespace QMatrixClient + +PostPusherJob::PostPusherJob(const QString& pushkey, const QString& kind, const QString& appId, const QString& appDisplayName, const QString& deviceDisplayName, const QString& lang, const PusherData& data, const QString& profileTag, bool append) + : BaseJob(HttpVerb::Post, "PostPusherJob", + basePath % "/pushers/set") +{ + QJsonObject _data; + _data.insert("pushkey", toJson(pushkey)); + _data.insert("kind", toJson(kind)); + _data.insert("app_id", toJson(appId)); + _data.insert("app_display_name", toJson(appDisplayName)); + _data.insert("device_display_name", toJson(deviceDisplayName)); + if (!profileTag.isEmpty()) + _data.insert("profile_tag", toJson(profileTag)); + _data.insert("lang", toJson(lang)); + _data.insert("data", toJson(data)); + _data.insert("append", toJson(append)); + setRequestData(_data); +} + diff --git a/jobs/generated/pusher.h b/jobs/generated/pusher.h new file mode 100644 index 00000000..36576996 --- /dev/null +++ b/jobs/generated/pusher.h @@ -0,0 +1,81 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "../basejob.h" + +#include <QtCore/QVector> + +#include "converters.h" + +namespace QMatrixClient +{ + // Operations + + class GetPushersJob : public BaseJob + { + public: + // Inner data structures + + struct PusherData + { + QString url; + + operator QJsonObject() const; + }; + + struct Pusher + { + QString pushkey; + QString kind; + QString appId; + QString appDisplayName; + QString deviceDisplayName; + QString profileTag; + QString lang; + PusherData data; + + operator QJsonObject() const; + }; + + // End of inner data structures + + /** Construct a URL out of baseUrl and usual parameters passed to + * GetPushersJob. This function can be used when + * a URL for GetPushersJob is necessary but the job + * itself isn't. + */ + static QUrl makeRequestUrl(QUrl baseUrl); + + explicit GetPushersJob(); + ~GetPushersJob() override; + + const QVector<Pusher>& pushers() const; + + protected: + Status parseJson(const QJsonDocument& data) override; + + private: + class Private; + QScopedPointer<Private> d; + }; + + class PostPusherJob : public BaseJob + { + public: + // Inner data structures + + struct PusherData + { + QString url; + + operator QJsonObject() const; + }; + + // End of inner data structures + + explicit PostPusherJob(const QString& pushkey, const QString& kind, const QString& appId, const QString& appDisplayName, const QString& deviceDisplayName, const QString& lang, const PusherData& data, const QString& profileTag = {}, bool append = {}); + }; +} // namespace QMatrixClient |