mirror of
https://github.com/HenkKalkwater/harbour-sailfin.git
synced 2025-09-05 10:12:46 +00:00
WIP: HttpLoader seems to work, Model still borked
This commit is contained in:
parent
e421adf733
commit
729e343661
1412 changed files with 13967 additions and 33794 deletions
|
@ -14,4 +14,17 @@ private:
|
|||
explicit {{className}}Class();
|
||||
};
|
||||
|
||||
typedef {{className}}Class::Value {{className}};
|
||||
using {{className}} = {{className}}Class::Value;
|
||||
|
||||
} // NS DTO
|
||||
|
||||
namespace Support {
|
||||
|
||||
using {{className}} = Jellyfin::DTO::{{className}};
|
||||
|
||||
template <>
|
||||
|
||||
{{className}} fromJsonValue(const QJsonValue &source, convertType<{{className}}>);
|
||||
|
||||
template <>
|
||||
QJsonValue toJsonValue(const {{className}} &source, convertType<{{className}}>);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{{className}}Class::{{className}}Class() {}
|
||||
|
||||
|
||||
} // NS DTO
|
||||
|
||||
namespace Support {
|
||||
|
@ -9,7 +8,7 @@ using {{className}} = Jellyfin::DTO::{{className}};
|
|||
|
||||
template <>
|
||||
|
||||
{{className}} fromJsonValue<{{className}}>(const QJsonValue &source) {
|
||||
{{className}} fromJsonValue(const QJsonValue &source, convertType<{{className}}>) {
|
||||
if (!source.isString()) return {{className}}::EnumNotSet;
|
||||
|
||||
QString str = source.toString();
|
||||
|
@ -23,3 +22,19 @@ template <>
|
|||
|
||||
return {{className}}::EnumNotSet;
|
||||
}
|
||||
|
||||
template <>
|
||||
QJsonValue toJsonValue(const {{className}} &source, convertType<{{className}}>) {
|
||||
switch(source) {
|
||||
|
||||
{{#each values as |value|}}
|
||||
case {{className}}::{{value}}:
|
||||
return QStringLiteral("{{value}}");
|
||||
|
||||
{{/each}}
|
||||
|
||||
case {{className}}::EnumNotSet: // Fallthrough
|
||||
default:
|
||||
return QJsonValue();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
{{#if endpoint.hasSuccessResponse}}
|
||||
|
||||
using namespace {{dtoNamespace}};
|
||||
|
||||
{{#if endpoint.description.length > 0}}
|
||||
/**
|
||||
* @brief {{endpoint.description}}
|
||||
|
@ -6,7 +9,8 @@
|
|||
*/
|
||||
{{/if}}
|
||||
|
||||
class {{className}}Loader : public {{supportNamespace}}::HttpLoader<{{dtoNamespace}}::{{endpoint.resultType}}, {{endpoint.parameterType}}> {
|
||||
|
||||
class {{className}}Loader : public {{supportNamespace}}::HttpLoader<{{endpoint.resultType}}, {{endpoint.parameterType}}> {
|
||||
public:
|
||||
explicit {{className}}Loader(ApiClient *apiClient = nullptr);
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
{{#if endpoint.hasSuccessResponse}}
|
||||
|
||||
using namespace {{dtoNamespace}};
|
||||
|
||||
{{className}}Loader::{{className}}Loader(ApiClient *apiClient)
|
||||
: {{supportNamespace}}::HttpLoader<{{dtoNamespace}}::{{endpoint.resultType}}, {{endpoint.parameterType}}>(apiClient) {}
|
||||
: {{supportNamespace}}::HttpLoader<{{endpoint.resultType}}, {{endpoint.parameterType}}>(apiClient) {}
|
||||
|
||||
QString {{className}}Loader::path(const {{endpoint.parameterType}} ¶ms) const {
|
||||
Q_UNUSED(params) // Might be overzealous, but I don't like theses kind of warnings
|
||||
|
@ -15,7 +17,7 @@ QUrlQuery {{className}}Loader::query(const {{endpoint.parameterType}} ¶ms) c
|
|||
QUrlQuery result;
|
||||
|
||||
{{#each endpoint.requiredQueryParameters as |p|}}
|
||||
result.addQueryItem("{{p.name}}", params.{{p.type.name}}());
|
||||
result.addQueryItem("{{p.name}}", Support::toString<{{p.type.typeNameWithQualifiers}}>(params.{{p.type.name}}()));
|
||||
|
||||
{{/each}}
|
||||
|
||||
|
@ -23,7 +25,7 @@ QUrlQuery {{className}}Loader::query(const {{endpoint.parameterType}} ¶ms) c
|
|||
|
||||
{{#each endpoint.optionalQueryParameters as |p|}}
|
||||
if (!params.{{p.type.name}}Null()) {
|
||||
result.addQueryItem("{{p.name}}", Support::toString(params.{{p.type.name}}()));
|
||||
result.addQueryItem("{{p.name}}", Support::toString<{{p.type.typeNameWithQualifiers}}>(params.{{p.type.name}}()));
|
||||
}
|
||||
|
||||
{{/each}}
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
|
||||
static {{className}} fromJson(QJsonObject source);
|
||||
void setFromJson(QJsonObject source);
|
||||
QJsonObject toJson();
|
||||
QJsonObject toJson() const;
|
||||
|
||||
// Properties
|
||||
|
||||
|
@ -61,3 +61,16 @@ protected:
|
|||
|
||||
{{/each}}
|
||||
};
|
||||
|
||||
} // NS DTO
|
||||
|
||||
namespace Support {
|
||||
|
||||
using {{className}} = Jellyfin::DTO::{{className}};
|
||||
|
||||
template <>
|
||||
|
||||
{{className}} fromJsonValue(const QJsonValue &source, convertType<{{className}}>);
|
||||
|
||||
template<>
|
||||
QJsonValue toJsonValue(const {{className}} &source, convertType<{{className}}>);
|
||||
|
|
|
@ -41,7 +41,7 @@ void {{className}}::setFromJson(QJsonObject source) {
|
|||
|
||||
}
|
||||
|
||||
QJsonObject {{className}}::toJson() {
|
||||
QJsonObject {{className}}::toJson() const {
|
||||
QJsonObject result;
|
||||
|
||||
{{#each properties as |property|}}
|
||||
|
@ -83,7 +83,12 @@ using {{className}} = Jellyfin::DTO::{{className}};
|
|||
|
||||
template <>
|
||||
|
||||
{{className}} fromJsonValue<{{className}}>(const QJsonValue &source) {
|
||||
if (!source.isObject()) throw new ParseException("Expected JSON Object");
|
||||
{{className}} fromJsonValue(const QJsonValue &source, convertType<{{className}}>) {
|
||||
if (!source.isObject()) throw ParseException("Expected JSON Object");
|
||||
return {{className}}::fromJson(source.toObject());
|
||||
}
|
||||
|
||||
template<>
|
||||
QJsonValue toJsonValue(const {{className}} &source, convertType<{{className}}>) {
|
||||
return source.toJson();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue