mirror of
https://github.com/HenkKalkwater/harbour-sailfin.git
synced 2025-09-05 10:12:46 +00:00
Refractor ApiClient and add support for body params
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.
This commit is contained in:
parent
1453cbbc63
commit
96ecd8e7d8
116 changed files with 4437 additions and 106 deletions
|
@ -18,6 +18,8 @@ public:
|
|||
protected:
|
||||
QString path(const {{e.endpoint.parameterType}}& parameters) const override;
|
||||
QUrlQuery query(const {{e.endpoint.parameterType}}& parameters) const override;
|
||||
QByteArray body(const {{e.endpoint.parameterType}}& parameters) const override;
|
||||
QNetworkAccessManager::Operation operation() const override;
|
||||
};
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
|
|
|
@ -35,5 +35,23 @@ QUrlQuery {{e.className}}Loader::query(const {{e.endpoint.parameterType}} ¶m
|
|||
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}}
|
||||
|
|
|
@ -51,6 +51,18 @@ private:
|
|||
|
||||
{{/each}}
|
||||
|
||||
{{#if e.bodyParameters.length > 0}}
|
||||
// Body parameters
|
||||
|
||||
{{#if e.bodyParameters.length == 1}}
|
||||
{{e.bodyParameters[0].type.typeNameWithQualifiers}} m_body;
|
||||
|
||||
{{else}}
|
||||
//FIXME: Multiple body options not implemented.
|
||||
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue