{{>preamble}}
#include "{{filenameBase}}.h"

#include <QtCore/QStringBuilder>

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

auto queryTo{{camelCaseOperationId}}(
            {{#queryParams}}{{>joinedParamDef}}{{/queryParams}})
{
    BaseJob::Query _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(Data({{#consumesNonJson?}}{{nameCamelCase}}{{/consumesNonJson?
    }}{{^consumesNonJson?}}toJson({{nameCamelCase}}){{/consumesNonJson?}}));
    {{/bodyParams?}}{{/propertyMap}}{{/inlineBody
    }}{{^consumesNonJson?}}{{#bodyParams?}}
    QJsonObject _data;
        {{#propertyMap}}
    fillJson(_data, {{nameCamelCase}});
        {{/propertyMap}}{{#inlineBody}}
    fillJson<{{>maybeOmittableType}}>(_data, {{paramName}});
        {{/inlineBody}}{{#bodyParams}}
    addParam<{{^required?}}IfNotEmpty{{/required?}}>(_data,
                    QStringLiteral("{{baseName}}"), {{paramName}});
        {{/bodyParams}}
    setRequestData(std::move(_data));
    {{/bodyParams?}}{{/consumesNonJson?}}{{#producesNonJson?}}
    setExpectedContentTypes({ {{#produces}}"{{_}}"{{>cjoin}}{{/produces}} });
    {{/producesNonJson?}}{{^producesNonJson?
        }}{{#responses}}{{#normalResponse?}}{{#properties}}{{#required?}}
    addExpectedKey("{{baseName}}");
        {{/required?}}{{/properties}}{{/normalResponse?}}{{/responses
    }}{{/producesNonJson?}}
}
{{/operation}}{{/operations}}
