{{#@filePartial}}preamble{{/@filePartial}} #include "{{filenameBase}}.h" {{^models}}#include "jobs/converters.h"{{/models}} {{#operations}}#include {{/operations}} using namespace QMatrixClient; {{#models}}{{#model}} {{classname}}::operator QJsonValue() const { QJsonObject o; {{#vars}}o.insert("{{name}}", toJson({{name}})); {{/vars}} return o; } {{classname}} FromJson<{{classname}}>::operator()(QJsonValue jv) { QJsonObject o = jv.toObject(); {{classname}} result; {{#vars}}result.{{name}} = fromJson<{{datatype}}>(o.value("{{name}}")); {{/vars}} return result; } {{/model}}{{/models}}{{#operations}} static const auto basePath = QStringLiteral("{{basePathWithoutHost}}"); {{# operation}}{{#responses}}{{#normalResponse?}}{{#properties?}} class {{camelCaseOperationId}}Job::Private { public: {{#properties}}{{dataType}} {{paramName}}; {{/properties}} }; {{/ properties?}}{{/normalResponse?}}{{/responses}} {{camelCaseOperationId}}Job::{{camelCaseOperationId}}Job({{#allParams}}{{#avoidCopy?}}const {{dataType}}&{{/avoidCopy?}}{{^avoidCopy?}}{{dataType}}{{/avoidCopy?}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : BaseJob(HttpVerb::{{#@cap}}{{#@tolower}}{{httpMethod}}{{/@tolower}}{{/@cap}}, "{{camelCaseOperationId}}Job", basePath{{#pathParts}} % {{part}}{{/pathParts}}, Query {{^queryParams}}{ }{{/queryParams}}{{#queryParams?}}{ {{#queryParams}}{ "{{baseName}}", toJson({{paramName}}).toString() }{{#hasMore}}, {{/hasMore}}{{/queryParams}} }{{/queryParams?}}, Data {{^bodyParams}}{ }{{/bodyParams}}{{#bodyParams?}}{ {{#bodyParams}}{ "{{baseName}}", toJson({{paramName}}) }{{#hasMore}}, {{/hasMore}}{{/bodyParams}} }{{/bodyParams?}}{{#skipAuth}}, false{{/skipAuth}} ){{#responses}}{{#normalResponse?}}{{#properties?}}, d(new Private){{/properties?}}{{/normalResponse?}}{{/responses}} { } {{# responses}}{{#normalResponse?}}{{#properties?}} {{camelCaseOperationId}}Job::~{{camelCaseOperationId}}Job() { delete d; } {{# properties}} const {{dataType}}& {{camelCaseOperationId}}Job::{{paramName}}() const { return d->{{paramName}}; } {{/ properties}}{{#returnFile?}} BaseJob::Status {{camelCaseOperationId}}Job::parseReply(QByteArray data) { {{#properties}}{{paramName}}{{/properties}} = data; return Success; }{{/ returnFile?}}{{^returnFile?}} BaseJob::Status {{camelCaseOperationId}}Job::parseJson(const QJsonDocument& data) { auto json = data.object(); {{# properties}}{{#required?}}if (!json.contains("{{paramName}}")) return { JsonParseError, "The key '{{paramName}}' not found in the response" };{{/required?}} d->{{paramName}} = fromJson<{{dataType}}>(json.value("{{paramName}}")); {{/ properties}} return Success; }{{/ returnFile?}} {{/properties?}}{{/normalResponse?}}{{/responses}}{{/operation}}{{/operations}}