aboutsummaryrefslogtreecommitdiff
path: root/lib/jobs/generated/pusher.cpp
blob: 4fddac454b8932b5d0cd944953bc6b9ea92a2334 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
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);
}