aboutsummaryrefslogtreecommitdiff
path: root/gtad/operation.cpp.mustache
blob: 4b75434c2a38a893b547b5dc06a4373bcbbe895e (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
{{!
SPDX-FileCopyrightText: 2020 Kitsune Ral <Kitsune-Ral@users.sf.net>
SPDX-License-Identifier: LGPL-2.1-or-later
}}{{>preamble}}
#include "{{filenameBase}}.h"

using namespace Quotient;
{{#operations}}{{#operation}}
    {{#queryParams?}}

auto queryTo{{camelCaseOperationId}}(
            {{#queryParams}}{{>joinedParamDef}}{{/queryParams}})
{
    QUrlQuery _q;{{#queryParams}}
    addParam<{{^required?}}IfNotEmpty{{/required?}}>(_q,
            QStringLiteral("{{baseName}}"), {{paramName}});{{/queryParams}}
    return _q;
}
    {{/queryParams?}}
    {{^hasBody?}}

QUrl {{camelCaseOperationId}}Job::makeRequestUrl(QUrl baseUrl{{#allParams?}},
        {{#allParams}}{{>joinedParamDef}}{{/allParams}}{{/allParams?}})
{
    return BaseJob::makeRequestUrl(std::move(baseUrl), {{>passPathAndMaybeQuery}});
}   {{/hasBody?}}

{{camelCaseOperationId}}Job::{{camelCaseOperationId}}Job(
        {{#allParams}}{{>joinedParamDef}}{{/allParams}})
    : BaseJob(HttpVerb::{{#_cap}}{{#_tolower}}{{httpMethod}}{{/_tolower}}{{/_cap}},
            {{!object name}}QStringLiteral("{{camelCaseOperationId}}Job"),
            {{>passPathAndMaybeQuery}}
        {{#skipAuth}}{{#queryParams?}}, {}{{/queryParams?}}, false{{/skipAuth}} )
{   {{#headerParams}}
    setRequestHeader("{{baseName}}", {{paramName}}.toLatin1());
    {{/headerParams}}{{#inlineBody}}{{^propertyMap}}{{^bodyParams?}}
    setRequestData({ {{#consumesNonJson?}}{{nameCamelCase}}{{/consumesNonJson?
    }}{{^consumesNonJson?}}toJson({{nameCamelCase}}){{/consumesNonJson?}} });
    {{/bodyParams?}}{{/propertyMap}}{{/inlineBody
    }}{{^consumesNonJson?}}{{#bodyParams?}}
    QJsonObject _dataJson;
        {{#propertyMap}}
    fillJson(_dataJson, {{nameCamelCase}});
        {{/propertyMap}}{{#inlineBody}}
    fillJson<{{>maybeOmittableType}}>(_dataJson, {{paramName}});
        {{/inlineBody}}{{#bodyParams}}
    addParam<{{^required?}}IfNotEmpty{{/required?}}>(_dataJson,
                    QStringLiteral("{{baseName}}"), {{paramName}});
        {{/bodyParams}}
    setRequestData({ _dataJson });
    {{/bodyParams?}}{{/consumesNonJson?}}{{#producesNonJson?}}
    setExpectedContentTypes({ {{#produces}}"{{_}}"{{>cjoin}}{{/produces}} });
    {{/producesNonJson?}}{{^producesNonJson?
        }}{{#responses}}{{#normalResponse?}}{{#properties}}{{#required?}}
    addExpectedKey("{{baseName}}");
        {{/required?}}{{/properties}}{{/normalResponse?}}{{/responses
    }}{{/producesNonJson?}}
}
{{/operation}}{{/operations}}