Browse Source

dynamite,nextcloud,neon: Suffix serialize and deserialize functions

pull/168/head
jld3103 2 years ago
parent
commit
f24f9e838b
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 4
      packages/dynamite/lib/src/openapi_builder.dart
  2. 6
      packages/neon/lib/src/utils/request_manager.dart
  3. 4
      packages/nextcloud/lib/src/nextcloud.openapi.dart

4
packages/dynamite/lib/src/openapi_builder.dart

@ -865,9 +865,9 @@ class OpenAPIBuilder implements Builder {
],
'};',
'',
'T deserialize<T>(final dynamic data) => _deserializers[T]!(data) as T;',
'T deserialize$prefix<T>(final dynamic data) => _deserializers[T]!(data) as T;',
'',
'dynamic serialize<T>(final T data) => _serializers[T]!(data);',
'dynamic serialize$prefix<T>(final T data) => _serializers[T]!(data);',
'// coverage:ignore-end',
]);
}

6
packages/neon/lib/src/utils/request_manager.dart

@ -34,7 +34,7 @@ class RequestManager {
try {
subject.add(
Result(
unwrap(deserialize<R>(json.decode((await cache!.get(key))!))),
unwrap(deserializeNextcloud<R>(json.decode((await cache!.get(key))!))),
null,
loading: true,
cached: true,
@ -48,7 +48,7 @@ class RequestManager {
try {
final response = await (disableTimeout ? call() : timeout(call));
await cache?.set(key, json.encode(serialize<R>(response)));
await cache?.set(key, json.encode(serializeNextcloud<R>(response)));
subject.add(Result.success(unwrap(response)));
} catch (e, s) {
debugPrint(e.toString());
@ -57,7 +57,7 @@ class RequestManager {
try {
subject.add(
Result(
unwrap(deserialize<R>(json.decode((await cache!.get(key))!))),
unwrap(deserializeNextcloud<R>(json.decode((await cache!.get(key))!))),
null,
loading: false,
cached: true,

4
packages/nextcloud/lib/src/nextcloud.openapi.dart

@ -6041,7 +6041,7 @@ final _serializers = <Type, dynamic Function(dynamic)>{
data.map((final e) => e.toJson()).toList(),
};
T deserialize<T>(final dynamic data) => _deserializers[T]!(data) as T;
T deserializeNextcloud<T>(final dynamic data) => _deserializers[T]!(data) as T;
dynamic serialize<T>(final T data) => _serializers[T]!(data);
dynamic serializeNextcloud<T>(final T data) => _serializers[T]!(data);
// coverage:ignore-end

Loading…
Cancel
Save