2021-03-25 16:32:00 +00:00
|
|
|
|
2021-03-28 02:00:00 +00:00
|
|
|
using namespace {{dtoNamespace}};
|
|
|
|
|
2021-09-01 12:50:02 +00:00
|
|
|
{{#each endpoints as |e|}}
|
|
|
|
{{#if e.endpoint.hasSuccessResponse}}
|
2021-03-25 16:32:00 +00:00
|
|
|
|
2021-09-01 12:50:02 +00:00
|
|
|
{{e.className}}Loader::{{e.className}}Loader(ApiClient *apiClient)
|
|
|
|
: {{supportNamespace}}::HttpLoader<{{e.endpoint.resultType}}, {{e.endpoint.parameterType}}>(apiClient) {}
|
|
|
|
|
|
|
|
QString {{e.className}}Loader::path(const {{e.endpoint.parameterType}} ¶ms) const {
|
2021-03-25 16:32:00 +00:00
|
|
|
Q_UNUSED(params) // Might be overzealous, but I don't like theses kind of warnings
|
|
|
|
|
2021-09-01 12:50:02 +00:00
|
|
|
return {{e.pathStringInterpolation "params"}};
|
2021-03-25 16:32:00 +00:00
|
|
|
}
|
|
|
|
|
2021-09-01 12:50:02 +00:00
|
|
|
QUrlQuery {{e.className}}Loader::query(const {{e.endpoint.parameterType}} ¶ms) const {
|
2021-03-25 16:32:00 +00:00
|
|
|
Q_UNUSED(params) // Might be overzealous, but I don't like theses kind of warnings
|
|
|
|
|
|
|
|
QUrlQuery result;
|
|
|
|
|
2021-09-01 12:50:02 +00:00
|
|
|
{{#each e.endpoint.requiredQueryParameters as |p|}}
|
2021-03-28 02:00:00 +00:00
|
|
|
result.addQueryItem("{{p.name}}", Support::toString<{{p.type.typeNameWithQualifiers}}>(params.{{p.type.name}}()));
|
2021-03-25 16:32:00 +00:00
|
|
|
|
|
|
|
{{/each}}
|
|
|
|
|
|
|
|
// Optional parameters
|
|
|
|
|
2021-09-01 12:50:02 +00:00
|
|
|
{{#each e.endpoint.optionalQueryParameters as |p|}}
|
2021-03-25 16:32:00 +00:00
|
|
|
if (!params.{{p.type.name}}Null()) {
|
2021-03-28 02:00:00 +00:00
|
|
|
result.addQueryItem("{{p.name}}", Support::toString<{{p.type.typeNameWithQualifiers}}>(params.{{p.type.name}}()));
|
2021-03-25 16:32:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{{/each}}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-09-03 01:47:25 +00:00
|
|
|
QByteArray {{e.className}}Loader::body(const {{e.endpoint.parameterType}} ¶ms) const {
|
|
|
|
|
|
|
|
{{#if e.endpoint.bodyParameters.length == 1}}
|
|
|
|
return Support::toString<{{e.endpoint.bodyParameters[0].type.typeNameWithQualifiers}}>(params.body()).toUtf8();
|
|
|
|
|
|
|
|
{{else}}
|
|
|
|
return QByteArray();
|
|
|
|
|
|
|
|
{{/if}}
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkAccessManager::Operation {{e.className}}Loader::operation() const {
|
|
|
|
// HTTP method {{e.operation}}
|
|
|
|
|
|
|
|
return QNetworkAccessManager::{{e.operation}}Operation;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-03-25 16:32:00 +00:00
|
|
|
{{/if}}
|
2021-09-01 12:50:02 +00:00
|
|
|
{{/each}}
|