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
|
{{#@filePartial}}preamble{{/@filePartial}}
#include "{{filenameBase}}.h"
{{#operations}}
#include "../converters.h"
#include <QtCore/QStringBuilder>
using namespace QMatrixClient;
{{#returns?}}
class {{#@cap}}{{operationId}}{{/@cap}}Job::Private
{
public:
{{#returns}}
{{type}} {{name}};
{{/returns}}
};
{{/returns?}}
{{#operation}}
{{#@cap}}{{operationId}}{{/@cap}}Job::{{#@cap}}{{operationId}}{{/@cap}}Job(const ConnectionData* connection{{#allParams}}, {{!}}
{{#avoidCopy?}}const {{dataType}}&{{/avoidCopy?}}
{{^avoidCopy?}}{{dataType}}{{/avoidCopy?}} {{paramName}}
{{/allParams}})
: BaseJob(connection, HttpVerb::{{#@cap}}{{#@tolower}}{{httpMethod}}{{/@tolower}}{{/@cap}}, "{{#@cap}}{{operationId}}{{/@cap}}Job"
, {{#pathParts}}{{part}}{{#hasMore}} % {{/hasMore}}{{/pathParts}}
, Query { {{#queryParams}}
{ "{{baseName}}", toJson({{paramName}}).toString() }{{#hasMore}}, {{/hasMore}}
{{/queryParams}} }
, Data { {{#bodyParams}}
{ "{{baseName}}", toJson({{paramName}}) }{{#hasMore}}, {{/hasMore}}
{{/bodyParams}} }
{{#skipAuth}}, false{{/skipAuth}}
){{#returns?}}, d(new Private){{/returns?}}
{ }
{{/operation}}
{{#returns?}}
{{className}}Job::~{{className}}Job()
{
delete d;
}
{{#returns}}
{{type}} {{className}}Job::{{name}}() const
{
return d->{{name}};
}
{{/returns}}
{{#returnFile?}}
BaseJob::Status {{className}}Job::parseReply(QByteArray data)
{
{{#returns}}{{name}}{{/returns}} = data;
return Success;
}
{{/returnFile?}}
{{^returnFile?}}
BaseJob::Status {{className}}Job::parseJson(const QJsonDocument& data)
{
auto json = data.object();
{{#returns}}
{{#required?}}
if (!json.contains("{{name}}")
return { JsonParseError, "{{name}} not found in the response" };
{{/required?}}
d->{{name}} = fromJson<{{type}}>(json.value("{{name}}"));
{{/returns}}
return Success;
}
{{/returnFile?}}
{{/returns?}}
{{/operations}}
|