aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/room_state.cpp
blob: 5973b06bcf8ca8541a69f5a550e0bd6f6cd43d7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/******************************************************************************
 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
 */

#include "room_state.h"

#include "converters.h"

#include <QtCore/QStringBuilder>

using namespace Quotient;

static const auto basePath = QStringLiteral("/_matrix/client/r0");

class SetRoomStateWithKeyJob::Private {
public:
    QString eventId;
};

SetRoomStateWithKeyJob::SetRoomStateWithKeyJob(const QString& roomId,
                                               const QString& eventType,
                                               const QString& stateKey,
                                               const QJsonObject& body)
    : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomStateWithKeyJob"),
              basePath % "/rooms/" % roomId % "/state/" % eventType % "/"
                  % stateKey)
    , d(new Private)
{
    setRequestData(Data(toJson(body)));
}

SetRoomStateWithKeyJob::~SetRoomStateWithKeyJob() = default;

const QString& SetRoomStateWithKeyJob::eventId() const { return d->eventId; }

BaseJob::Status SetRoomStateWithKeyJob::parseJson(const QJsonDocument& data)
{
    auto json = data.object();
    fromJson(json.value("event_id"_ls), d->eventId);

    return Success;
}

class SetRoomStateJob::Private {
public:
    QString eventId;
};

SetRoomStateJob::SetRoomStateJob(const QString& roomId, const QString& eventType,
                                 const QJsonObject& body)
    : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomStateJob"),
              basePath % "/rooms/" % roomId % "/state/" % eventType)
    , d(new Private)
{
    setRequestData(Data(toJson(body)));
}

SetRoomStateJob::~SetRoomStateJob() = default;

const QString& SetRoomStateJob::eventId() const { return d->eventId; }

BaseJob::Status SetRoomStateJob::parseJson(const QJsonDocument& data)
{
    auto json = data.object();
    fromJson(json.value("event_id"_ls), d->eventId);

    return Success;
}