mirror of
https://github.com/HenkKalkwater/harbour-sailfin.git
synced 2024-07-08 23:53:52 +00:00
ApiClient was refractored to use PIMPL. This is mainly done to reduce compile times whenever the implementation of ApiClient itself changes, since a lot of files include it. The loaders have gained support for body parameters, this was somehow omitted before.
58 lines
1.6 KiB
Handlebars
58 lines
1.6 KiB
Handlebars
|
|
using namespace {{dtoNamespace}};
|
|
|
|
{{#each endpoints as |e|}}
|
|
{{#if e.endpoint.hasSuccessResponse}}
|
|
|
|
{{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 {
|
|
Q_UNUSED(params) // Might be overzealous, but I don't like theses kind of warnings
|
|
|
|
return {{e.pathStringInterpolation "params"}};
|
|
}
|
|
|
|
QUrlQuery {{e.className}}Loader::query(const {{e.endpoint.parameterType}} ¶ms) const {
|
|
Q_UNUSED(params) // Might be overzealous, but I don't like theses kind of warnings
|
|
|
|
QUrlQuery result;
|
|
|
|
{{#each e.endpoint.requiredQueryParameters as |p|}}
|
|
result.addQueryItem("{{p.name}}", Support::toString<{{p.type.typeNameWithQualifiers}}>(params.{{p.type.name}}()));
|
|
|
|
{{/each}}
|
|
|
|
// Optional parameters
|
|
|
|
{{#each e.endpoint.optionalQueryParameters as |p|}}
|
|
if (!params.{{p.type.name}}Null()) {
|
|
result.addQueryItem("{{p.name}}", Support::toString<{{p.type.typeNameWithQualifiers}}>(params.{{p.type.name}}()));
|
|
}
|
|
|
|
{{/each}}
|
|
|
|
return result;
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
{{/if}}
|
|
{{/each}}
|