From 49022915fde72b83d9f18944c268110b01fa3469 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 4 May 2018 23:04:04 +0900 Subject: New home for the generated code - lib/csapi --- lib/csapi/event_context.cpp | 91 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 lib/csapi/event_context.cpp (limited to 'lib/csapi/event_context.cpp') diff --git a/lib/csapi/event_context.cpp b/lib/csapi/event_context.cpp new file mode 100644 index 00000000..d9ab45ca --- /dev/null +++ b/lib/csapi/event_context.cpp @@ -0,0 +1,91 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "event_context.h" + +#include "converters.h" + +#include + +using namespace QMatrixClient; + +static const auto basePath = QStringLiteral("/_matrix/client/r0"); + +class GetEventContextJob::Private +{ + public: + QString begin; + QString end; + RoomEvents eventsBefore; + RoomEventPtr event; + RoomEvents eventsAfter; + StateEvents state; +}; + +BaseJob::Query queryToGetEventContext(int limit) +{ + BaseJob::Query _q; + _q.addQueryItem("limit", QString("%1").arg(limit)); + return _q; +} + +QUrl GetEventContextJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventId, int limit) +{ + return BaseJob::makeRequestUrl(std::move(baseUrl), + basePath % "/rooms/" % roomId % "/context/" % eventId, + queryToGetEventContext(limit)); +} + +GetEventContextJob::GetEventContextJob(const QString& roomId, const QString& eventId, int limit) + : BaseJob(HttpVerb::Get, "GetEventContextJob", + basePath % "/rooms/" % roomId % "/context/" % eventId, + queryToGetEventContext(limit)) + , d(new Private) +{ +} + +GetEventContextJob::~GetEventContextJob() = default; + +const QString& GetEventContextJob::begin() const +{ + return d->begin; +} + +const QString& GetEventContextJob::end() const +{ + return d->end; +} + +RoomEvents&& GetEventContextJob::eventsBefore() +{ + return std::move(d->eventsBefore); +} + +RoomEventPtr&& GetEventContextJob::event() +{ + return std::move(d->event); +} + +RoomEvents&& GetEventContextJob::eventsAfter() +{ + return std::move(d->eventsAfter); +} + +StateEvents&& GetEventContextJob::state() +{ + return std::move(d->state); +} + +BaseJob::Status GetEventContextJob::parseJson(const QJsonDocument& data) +{ + auto json = data.object(); + d->begin = fromJson(json.value("start")); + d->end = fromJson(json.value("end")); + d->eventsBefore = fromJson(json.value("events_before")); + d->event = fromJson(json.value("event")); + d->eventsAfter = fromJson(json.value("events_after")); + d->state = fromJson(json.value("state")); + return Success; +} + -- cgit v1.2.3