{{!
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{{>titleCaseOperationId}}(
            {{#queryParams}}{{>joinedParamDef}}{{/queryParams}})
{
    QUrlQuery _q;{{#queryParams}}
    addParam{{^required?}}<IfNotEmpty>{{/required?}}(_q, u"{{baseName}}"_s,
                                                     {{paramName}});{{/queryParams}}
    return _q;
}
    {{/queryParams?}}
    {{^hasBody?}}

QUrl {{>titleCaseOperationId}}Job::makeRequestUrl(const HomeserverData& hsData{{#allParams?}},
        {{#allParams}}{{>joinedParamDef}}{{/allParams}}{{/allParams?}})
{
    return BaseJob::makeRequestUrl(hsData, {{>passPathAndMaybeQuery}});
}   {{/hasBody?}}

{{>titleCaseOperationId}}Job::{{>titleCaseOperationId}}Job(
        {{#allParams}}{{>joinedParamDef}}{{/allParams}})
    : BaseJob(HttpVerb::{{#_titleCase}}{{httpMethod}}{{/_titleCase}},
              {{!object name}}u"{{>titleCaseOperationId}}Job"_s, {{>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<{{>maybeOptionalType}}>(_dataJson, {{paramName}});
        {{/inlineBody}}{{#bodyParams}}
    addParam{{^required?}}<IfNotEmpty>{{/required?}}(_dataJson, "{{baseName}}"_L1, {{paramName}});
        {{/bodyParams}}
    setRequestData({ _dataJson });
    {{/bodyParams?}}{{/consumesNonJson?}}{{#producesNonJson?}}
    setExpectedContentTypes({ {{#produces}}"{{_}}"{{>cjoin}}{{/produces}} });
    {{/producesNonJson?}}{{^producesNonJson?
        }}{{#responses}}{{#normalResponse?}}{{#properties}}{{#required?}}
    addExpectedKey(u"{{baseName}}"_s);
        {{/required?}}{{/properties}}{{/normalResponse?}}{{/responses
    }}{{/producesNonJson?}}
}
{{/operation}}{{/operations}}
