From 4248e3909c28a70605d523fc7865ee74c5ce1650 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Sun, 24 Sep 2023 19:38:23 +0200 Subject: [PATCH 1/9] refactor(dynamite): refactor models structure Signed-off-by: Nikolas Rimikis --- .../dynamite/lib/src/builder/client.dart | 41 +++++------ .../lib/src/builder/header_serializer.dart | 16 +++-- .../dynamite/lib/src/builder/ofs_builder.dart | 13 ++-- .../lib/src/builder/resolve_enum.dart | 9 ++- .../lib/src/builder/resolve_interface.dart | 9 ++- .../lib/src/builder/resolve_object.dart | 9 ++- .../lib/src/builder/resolve_type.dart | 9 ++- .../dynamite/lib/src/builder/state.dart | 2 +- .../dynamite/lib/src/helpers/built_value.dart | 2 +- .../dynamite/lib/src/helpers/dynamite.dart | 7 +- .../dynamite/lib/src/helpers/type_result.dart | 2 +- .../dynamite/lib/src/models/openapi.dart | 70 +++++++++++++++++++ .../{serializers.g.dart => openapi.g.dart} | 2 +- .../src/models/{ => openapi}/components.dart | 4 +- .../models/{ => openapi}/components.g.dart | 0 .../models/{ => openapi}/discriminator.dart | 0 .../models/{ => openapi}/discriminator.g.dart | 0 .../lib/src/models/{ => openapi}/header.dart | 2 +- .../src/models/{ => openapi}/header.g.dart | 0 .../lib/src/models/{ => openapi}/info.dart | 2 +- .../lib/src/models/{ => openapi}/info.g.dart | 0 .../lib/src/models/{ => openapi}/license.dart | 0 .../src/models/{ => openapi}/license.g.dart | 0 .../src/models/{ => openapi}/media_type.dart | 2 +- .../models/{ => openapi}/media_type.g.dart | 0 .../src/models/{ => openapi}/open_api.dart | 10 +-- .../src/models/{ => openapi}/open_api.g.dart | 0 .../src/models/{ => openapi}/operation.dart | 8 +-- .../src/models/{ => openapi}/operation.g.dart | 0 .../src/models/{ => openapi}/parameter.dart | 2 +- .../src/models/{ => openapi}/parameter.g.dart | 0 .../src/models/{ => openapi}/path_item.dart | 4 +- .../src/models/{ => openapi}/path_item.g.dart | 0 .../models/{ => openapi}/request_body.dart | 2 +- .../models/{ => openapi}/request_body.g.dart | 0 .../src/models/{ => openapi}/response.dart | 4 +- .../src/models/{ => openapi}/response.g.dart | 0 .../lib/src/models/{ => openapi}/schema.dart | 2 +- .../src/models/{ => openapi}/schema.g.dart | 0 .../models/{ => openapi}/security_scheme.dart | 0 .../{ => openapi}/security_scheme.g.dart | 0 .../lib/src/models/{ => openapi}/server.dart | 2 +- .../src/models/{ => openapi}/server.g.dart | 0 .../models/{ => openapi}/server_variable.dart | 0 .../{ => openapi}/server_variable.g.dart | 0 .../lib/src/models/{ => openapi}/tag.dart | 0 .../lib/src/models/{ => openapi}/tag.g.dart | 0 .../dynamite/lib/src/models/serializers.dart | 52 -------------- .../dynamite/lib/src/models/type_result.dart | 1 + .../src/{ => models}/type_result/base.dart | 0 .../src/{ => models}/type_result/enum.dart | 0 .../src/{ => models}/type_result/list.dart | 0 .../lib/src/{ => models}/type_result/map.dart | 0 .../src/{ => models}/type_result/object.dart | 0 .../{ => models}/type_result/type_result.dart | 0 .../dynamite/lib/src/openapi_builder.dart | 11 ++- .../dynamite/test/type_result_test.dart | 2 +- 57 files changed, 157 insertions(+), 144 deletions(-) create mode 100644 packages/dynamite/dynamite/lib/src/models/openapi.dart rename packages/dynamite/dynamite/lib/src/models/{serializers.g.dart => openapi.g.dart} (99%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/components.dart (81%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/components.g.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/discriminator.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/discriminator.g.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/header.dart (88%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/header.g.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/info.dart (89%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/info.g.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/license.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/license.g.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/media_type.dart (87%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/media_type.g.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/open_api.dart (77%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/open_api.g.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/operation.dart (78%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/operation.g.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/parameter.dart (92%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/parameter.g.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/path_item.dart (91%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/path_item.g.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/request_body.dart (90%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/request_body.g.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/response.dart (82%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/response.g.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/schema.dart (95%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/schema.g.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/security_scheme.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/security_scheme.g.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/server.dart (87%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/server.g.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/server_variable.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/server_variable.g.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/tag.dart (100%) rename packages/dynamite/dynamite/lib/src/models/{ => openapi}/tag.g.dart (100%) delete mode 100644 packages/dynamite/dynamite/lib/src/models/serializers.dart create mode 100644 packages/dynamite/dynamite/lib/src/models/type_result.dart rename packages/dynamite/dynamite/lib/src/{ => models}/type_result/base.dart (100%) rename packages/dynamite/dynamite/lib/src/{ => models}/type_result/enum.dart (100%) rename packages/dynamite/dynamite/lib/src/{ => models}/type_result/list.dart (100%) rename packages/dynamite/dynamite/lib/src/{ => models}/type_result/map.dart (100%) rename packages/dynamite/dynamite/lib/src/{ => models}/type_result/object.dart (100%) rename packages/dynamite/dynamite/lib/src/{ => models}/type_result/type_result.dart (100%) diff --git a/packages/dynamite/dynamite/lib/src/builder/client.dart b/packages/dynamite/dynamite/lib/src/builder/client.dart index 3bb46694..f64f9f98 100644 --- a/packages/dynamite/dynamite/lib/src/builder/client.dart +++ b/packages/dynamite/dynamite/lib/src/builder/client.dart @@ -7,11 +7,8 @@ import 'package:dynamite/src/builder/state.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart'; import 'package:dynamite/src/helpers/dynamite.dart'; import 'package:dynamite/src/helpers/type_result.dart'; -import 'package:dynamite/src/models/open_api.dart'; -import 'package:dynamite/src/models/path_item.dart'; -import 'package:dynamite/src/models/response.dart'; -import 'package:dynamite/src/models/schema.dart'; -import 'package:dynamite/src/type_result/type_result.dart'; +import 'package:dynamite/src/models/openapi.dart' as openapi; +import 'package:dynamite/src/models/type_result.dart'; List generateDynamiteOverrides(final State state) => [ Class( @@ -111,7 +108,7 @@ return ${state.classPrefix}ApiException( ]; Iterable generateClients( - final OpenAPI spec, + final openapi.OpenAPI spec, final State state, ) sync* { yield* generateDynamiteOverrides(state); @@ -125,7 +122,7 @@ Iterable generateClients( } Class buildRootClient( - final OpenAPI spec, + final openapi.OpenAPI spec, final State state, final List tags, ) => @@ -224,7 +221,7 @@ super( ); Class buildClient( - final OpenAPI spec, + final openapi.OpenAPI spec, final State state, final List tags, final String tag, @@ -272,7 +269,7 @@ Class buildClient( ); Iterable buildTags( - final OpenAPI spec, + final openapi.OpenAPI spec, final State state, final List tags, final String? tag, @@ -299,7 +296,7 @@ Iterable buildTags( b.annotations.add(refer('Deprecated').call([refer("''")])); } - var responses = >{}; + var responses = >{}; if (operation.responses != null) { for (final responseEntry in operation.responses!.entries) { final statusCode = int.parse(responseEntry.key); @@ -530,7 +527,7 @@ final _response = await ${isRootClient ? 'this' : '_rootClient'}.doRequest( spec, state, identifier, - Schema( + openapi.Schema( (final b) => b ..properties.replace( response.headers!.map( @@ -625,8 +622,8 @@ final _response = await ${isRootClient ? 'this' : '_rootClient'}.doRequest( } } -Map generatePaths(final OpenAPI spec, final String? tag) { - final paths = {}; +Map generatePaths(final openapi.OpenAPI spec, final String? tag) { + final paths = {}; if (spec.paths != null) { for (final path in spec.paths!.entries) { @@ -637,21 +634,21 @@ Map generatePaths(final OpenAPI spec, final String? tag) { paths[path.key] ??= path.value; paths[path.key]!.rebuild((final b) { switch (operationEntry.key) { - case PathItemOperation.get: + case openapi.PathItemOperation.get: b.get.replace(operation); - case PathItemOperation.put: + case openapi.PathItemOperation.put: b.put.replace(operation); - case PathItemOperation.post: + case openapi.PathItemOperation.post: b.post.replace(operation); - case PathItemOperation.delete: + case openapi.PathItemOperation.delete: b.delete.replace(operation); - case PathItemOperation.options: + case openapi.PathItemOperation.options: b.options.replace(operation); - case PathItemOperation.head: + case openapi.PathItemOperation.head: b.head.replace(operation); - case PathItemOperation.patch: + case openapi.PathItemOperation.patch: b.patch.replace(operation); - case PathItemOperation.trace: + case openapi.PathItemOperation.trace: b.trace.replace(operation); } }); @@ -663,7 +660,7 @@ Map generatePaths(final OpenAPI spec, final String? tag) { return paths; } -List generateTags(final OpenAPI spec) { +List generateTags(final openapi.OpenAPI spec) { final tags = []; if (spec.paths != null) { diff --git a/packages/dynamite/dynamite/lib/src/builder/header_serializer.dart b/packages/dynamite/dynamite/lib/src/builder/header_serializer.dart index 0a6f519b..2e9121d2 100644 --- a/packages/dynamite/dynamite/lib/src/builder/header_serializer.dart +++ b/packages/dynamite/dynamite/lib/src/builder/header_serializer.dart @@ -3,11 +3,15 @@ import 'package:dynamite/src/builder/resolve_type.dart'; import 'package:dynamite/src/builder/state.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart'; import 'package:dynamite/src/helpers/dynamite.dart'; -import 'package:dynamite/src/models/open_api.dart'; -import 'package:dynamite/src/models/schema.dart'; -import 'package:dynamite/src/type_result/type_result.dart'; +import 'package:dynamite/src/models/openapi.dart' as openapi; +import 'package:dynamite/src/models/type_result.dart'; -Spec buildHeaderSerializer(final State state, final String identifier, final OpenAPI spec, final Schema schema) => +Spec buildHeaderSerializer( + final State state, + final String identifier, + final openapi.OpenAPI spec, + final openapi.Schema schema, +) => Class( (final b) => b ..name = '_\$${state.classPrefix}${identifier}Serializer' @@ -107,8 +111,8 @@ return result.build(); Iterable deserializeProperty( final State state, final String identifier, - final OpenAPI spec, - final Schema schema, + final openapi.OpenAPI spec, + final openapi.Schema schema, ) sync* { for (final property in schema.properties!.entries) { final propertyName = property.key; diff --git a/packages/dynamite/dynamite/lib/src/builder/ofs_builder.dart b/packages/dynamite/dynamite/lib/src/builder/ofs_builder.dart index 04583373..5d8fe5ea 100644 --- a/packages/dynamite/dynamite/lib/src/builder/ofs_builder.dart +++ b/packages/dynamite/dynamite/lib/src/builder/ofs_builder.dart @@ -5,15 +5,14 @@ import 'package:dynamite/src/builder/resolve_type.dart'; import 'package:dynamite/src/builder/state.dart'; import 'package:dynamite/src/helpers/built_value.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart'; -import 'package:dynamite/src/models/open_api.dart'; -import 'package:dynamite/src/models/schema.dart'; -import 'package:dynamite/src/type_result/type_result.dart'; +import 'package:dynamite/src/models/openapi.dart' as openapi; +import 'package:dynamite/src/models/type_result.dart'; TypeResult resolveAllOf( - final OpenAPI spec, + final openapi.OpenAPI spec, final State state, final String identifier, - final Schema schema, { + final openapi.Schema schema, { final bool nullable = false, }) { final result = TypeResultObject( @@ -65,10 +64,10 @@ TypeResult resolveAllOf( } TypeResult resolveOfs( - final OpenAPI spec, + final openapi.OpenAPI spec, final State state, final String identifier, - final Schema schema, { + final openapi.Schema schema, { final bool nullable = false, }) { if (schema.allOf != null) { diff --git a/packages/dynamite/dynamite/lib/src/builder/resolve_enum.dart b/packages/dynamite/dynamite/lib/src/builder/resolve_enum.dart index 1c986ca1..df8199ab 100644 --- a/packages/dynamite/dynamite/lib/src/builder/resolve_enum.dart +++ b/packages/dynamite/dynamite/lib/src/builder/resolve_enum.dart @@ -4,15 +4,14 @@ import 'package:dynamite/src/builder/state.dart'; import 'package:dynamite/src/helpers/built_value.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart'; import 'package:dynamite/src/helpers/type_result.dart'; -import 'package:dynamite/src/models/open_api.dart'; -import 'package:dynamite/src/models/schema.dart'; -import 'package:dynamite/src/type_result/type_result.dart'; +import 'package:dynamite/src/models/openapi.dart' as openapi; +import 'package:dynamite/src/models/type_result.dart'; TypeResult resolveEnum( - final OpenAPI spec, + final openapi.OpenAPI spec, final State state, final String identifier, - final Schema schema, + final openapi.Schema schema, final TypeResult subResult, { final bool nullable = false, }) { diff --git a/packages/dynamite/dynamite/lib/src/builder/resolve_interface.dart b/packages/dynamite/dynamite/lib/src/builder/resolve_interface.dart index d20f472f..6f93512e 100644 --- a/packages/dynamite/dynamite/lib/src/builder/resolve_interface.dart +++ b/packages/dynamite/dynamite/lib/src/builder/resolve_interface.dart @@ -4,15 +4,14 @@ import 'package:dynamite/src/builder/state.dart'; import 'package:dynamite/src/helpers/built_value.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart'; import 'package:dynamite/src/helpers/dynamite.dart'; -import 'package:dynamite/src/models/open_api.dart'; -import 'package:dynamite/src/models/schema.dart'; -import 'package:dynamite/src/type_result/type_result.dart'; +import 'package:dynamite/src/models/openapi.dart' as openapi; +import 'package:dynamite/src/models/type_result.dart'; TypeResultObject resolveInterface( - final OpenAPI spec, + final openapi.OpenAPI spec, final State state, final String identifier, - final Schema schema, + final openapi.Schema schema, ) { final result = TypeResultObject( '${state.classPrefix}$identifier', diff --git a/packages/dynamite/dynamite/lib/src/builder/resolve_object.dart b/packages/dynamite/dynamite/lib/src/builder/resolve_object.dart index d33d81e4..6ad891d2 100644 --- a/packages/dynamite/dynamite/lib/src/builder/resolve_object.dart +++ b/packages/dynamite/dynamite/lib/src/builder/resolve_object.dart @@ -5,15 +5,14 @@ import 'package:dynamite/src/builder/state.dart'; import 'package:dynamite/src/helpers/built_value.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart'; import 'package:dynamite/src/helpers/type_result.dart'; -import 'package:dynamite/src/models/open_api.dart'; -import 'package:dynamite/src/models/schema.dart'; -import 'package:dynamite/src/type_result/type_result.dart'; +import 'package:dynamite/src/models/openapi.dart' as openapi; +import 'package:dynamite/src/models/type_result.dart'; TypeResultObject resolveObject( - final OpenAPI spec, + final openapi.OpenAPI spec, final State state, final String identifier, - final Schema schema, { + final openapi.Schema schema, { final bool nullable = false, final bool isHeader = false, }) { diff --git a/packages/dynamite/dynamite/lib/src/builder/resolve_type.dart b/packages/dynamite/dynamite/lib/src/builder/resolve_type.dart index 99e61ccc..e96363ec 100644 --- a/packages/dynamite/dynamite/lib/src/builder/resolve_type.dart +++ b/packages/dynamite/dynamite/lib/src/builder/resolve_type.dart @@ -2,15 +2,14 @@ import 'package:dynamite/src/builder/ofs_builder.dart'; import 'package:dynamite/src/builder/resolve_enum.dart'; import 'package:dynamite/src/builder/resolve_object.dart'; import 'package:dynamite/src/builder/state.dart'; -import 'package:dynamite/src/models/open_api.dart'; -import 'package:dynamite/src/models/schema.dart'; -import 'package:dynamite/src/type_result/type_result.dart'; +import 'package:dynamite/src/models/openapi.dart' as openapi; +import 'package:dynamite/src/models/type_result.dart'; TypeResult resolveType( - final OpenAPI spec, + final openapi.OpenAPI spec, final State state, final String identifier, - final Schema schema, { + final openapi.Schema schema, { final bool ignoreEnum = false, final bool nullable = false, }) { diff --git a/packages/dynamite/dynamite/lib/src/builder/state.dart b/packages/dynamite/dynamite/lib/src/builder/state.dart index c9d66d20..b4ebac49 100644 --- a/packages/dynamite/dynamite/lib/src/builder/state.dart +++ b/packages/dynamite/dynamite/lib/src/builder/state.dart @@ -1,6 +1,6 @@ import 'package:code_builder/code_builder.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart'; -import 'package:dynamite/src/type_result/type_result.dart'; +import 'package:dynamite/src/models/type_result.dart'; class State { State(final String prefix) diff --git a/packages/dynamite/dynamite/lib/src/helpers/built_value.dart b/packages/dynamite/dynamite/lib/src/helpers/built_value.dart index bf58c9c0..013b0945 100644 --- a/packages/dynamite/dynamite/lib/src/helpers/built_value.dart +++ b/packages/dynamite/dynamite/lib/src/helpers/built_value.dart @@ -1,7 +1,7 @@ import 'package:built_collection/built_collection.dart'; import 'package:code_builder/code_builder.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart'; -import 'package:dynamite/src/type_result/type_result.dart'; +import 'package:dynamite/src/models/type_result.dart'; const interfaceSuffix = 'Interface'; diff --git a/packages/dynamite/dynamite/lib/src/helpers/dynamite.dart b/packages/dynamite/dynamite/lib/src/helpers/dynamite.dart index ae15d5ba..8df4768b 100644 --- a/packages/dynamite/dynamite/lib/src/helpers/dynamite.dart +++ b/packages/dynamite/dynamite/lib/src/helpers/dynamite.dart @@ -1,8 +1,7 @@ // ignore_for_file: avoid_positional_boolean_parameters import 'package:dynamite/src/helpers/dart_helpers.dart'; -import 'package:dynamite/src/models/parameter.dart'; -import 'package:dynamite/src/models/schema.dart'; +import 'package:dynamite/src/models/openapi.dart' as openapi; String filterMethodName(final String operationId, final String tag) { final expandedTag = tag.split('/').toList(); @@ -20,7 +19,7 @@ String clientName(final String tag) => '${toDartName(tag, uppercaseFirstCharacte bool isDartParameterNullable( final bool? required, - final Schema? schema, + final openapi.Schema? schema, ) => (!(required ?? false) && schema?.$default == null) || (schema?.nullable ?? false); @@ -30,7 +29,7 @@ bool isRequired( ) => (required ?? false) && default_ == null; -int sortRequiredParameters(final Parameter a, final Parameter b) { +int sortRequiredParameters(final openapi.Parameter a, final openapi.Parameter b) { if (a.isDartRequired != b.isDartRequired) { if (a.isDartRequired && !b.isDartRequired) { return -1; diff --git a/packages/dynamite/dynamite/lib/src/helpers/type_result.dart b/packages/dynamite/dynamite/lib/src/helpers/type_result.dart index 3bc8f104..1a57a799 100644 --- a/packages/dynamite/dynamite/lib/src/helpers/type_result.dart +++ b/packages/dynamite/dynamite/lib/src/helpers/type_result.dart @@ -1,5 +1,5 @@ import 'package:dynamite/src/helpers/dart_helpers.dart'; -import 'package:dynamite/src/type_result/type_result.dart'; +import 'package:dynamite/src/models/type_result.dart'; String valueToEscapedValue(final TypeResult result, final String value) { if (result is TypeResultBase && result.name == 'String') { diff --git a/packages/dynamite/dynamite/lib/src/models/openapi.dart b/packages/dynamite/dynamite/lib/src/models/openapi.dart new file mode 100644 index 00000000..f4fac433 --- /dev/null +++ b/packages/dynamite/dynamite/lib/src/models/openapi.dart @@ -0,0 +1,70 @@ +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/serializer.dart'; +import 'package:built_value/standard_json_plugin.dart'; +import 'package:dynamite/src/models/openapi/components.dart'; +import 'package:dynamite/src/models/openapi/discriminator.dart'; +import 'package:dynamite/src/models/openapi/header.dart'; +import 'package:dynamite/src/models/openapi/info.dart'; +import 'package:dynamite/src/models/openapi/license.dart'; +import 'package:dynamite/src/models/openapi/media_type.dart'; +import 'package:dynamite/src/models/openapi/open_api.dart'; +import 'package:dynamite/src/models/openapi/operation.dart'; +import 'package:dynamite/src/models/openapi/parameter.dart'; +import 'package:dynamite/src/models/openapi/path_item.dart'; +import 'package:dynamite/src/models/openapi/request_body.dart'; +import 'package:dynamite/src/models/openapi/response.dart'; +import 'package:dynamite/src/models/openapi/schema.dart'; +import 'package:dynamite/src/models/openapi/security_scheme.dart'; +import 'package:dynamite/src/models/openapi/server.dart'; +import 'package:dynamite/src/models/openapi/server_variable.dart'; +import 'package:dynamite/src/models/openapi/tag.dart'; + +export 'openapi/components.dart'; +export 'openapi/discriminator.dart'; +export 'openapi/header.dart'; +export 'openapi/info.dart'; +export 'openapi/license.dart'; +export 'openapi/media_type.dart'; +export 'openapi/open_api.dart'; +export 'openapi/operation.dart'; +export 'openapi/parameter.dart'; +export 'openapi/path_item.dart'; +export 'openapi/request_body.dart'; +export 'openapi/response.dart'; +export 'openapi/schema.dart'; +export 'openapi/security_scheme.dart'; +export 'openapi/server.dart'; +export 'openapi/server_variable.dart'; +export 'openapi/tag.dart'; + +part 'openapi.g.dart'; + +@SerializersFor([ + Components, + Discriminator, + Header, + Info, + License, + MediaType, + OpenAPI, + Operation, + Parameter, + PathItem, + RequestBody, + Response, + Schema, + SecurityScheme, + Server, + ServerVariable, + Tag, +]) +final Serializers serializers = (_$serializers.toBuilder() + ..addBuilderFactory( + const FullType(BuiltMap, [ + FullType(String), + FullType(BuiltList, [FullType(String)]), + ]), + MapBuilder>.new, + ) + ..addPlugin(StandardJsonPlugin())) + .build(); diff --git a/packages/dynamite/dynamite/lib/src/models/serializers.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi.g.dart similarity index 99% rename from packages/dynamite/dynamite/lib/src/models/serializers.g.dart rename to packages/dynamite/dynamite/lib/src/models/openapi.g.dart index b39aa85b..574ace87 100644 --- a/packages/dynamite/dynamite/lib/src/models/serializers.g.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'serializers.dart'; +part of 'openapi.dart'; // ************************************************************************** // BuiltValueGenerator diff --git a/packages/dynamite/dynamite/lib/src/models/components.dart b/packages/dynamite/dynamite/lib/src/models/openapi/components.dart similarity index 81% rename from packages/dynamite/dynamite/lib/src/models/components.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/components.dart index 3d4e0f61..4ce32ae4 100644 --- a/packages/dynamite/dynamite/lib/src/models/components.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/components.dart @@ -1,8 +1,8 @@ import 'package:built_collection/built_collection.dart'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; -import 'package:dynamite/src/models/schema.dart'; -import 'package:dynamite/src/models/security_scheme.dart'; +import 'package:dynamite/src/models/openapi/schema.dart'; +import 'package:dynamite/src/models/openapi/security_scheme.dart'; part 'components.g.dart'; diff --git a/packages/dynamite/dynamite/lib/src/models/components.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/components.g.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/components.g.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/components.g.dart diff --git a/packages/dynamite/dynamite/lib/src/models/discriminator.dart b/packages/dynamite/dynamite/lib/src/models/openapi/discriminator.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/discriminator.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/discriminator.dart diff --git a/packages/dynamite/dynamite/lib/src/models/discriminator.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/discriminator.g.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/discriminator.g.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/discriminator.g.dart diff --git a/packages/dynamite/dynamite/lib/src/models/header.dart b/packages/dynamite/dynamite/lib/src/models/openapi/header.dart similarity index 88% rename from packages/dynamite/dynamite/lib/src/models/header.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/header.dart index 41155bb8..a9623417 100644 --- a/packages/dynamite/dynamite/lib/src/models/header.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/header.dart @@ -1,6 +1,6 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; -import 'package:dynamite/src/models/schema.dart'; +import 'package:dynamite/src/models/openapi/schema.dart'; part 'header.g.dart'; diff --git a/packages/dynamite/dynamite/lib/src/models/header.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/header.g.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/header.g.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/header.g.dart diff --git a/packages/dynamite/dynamite/lib/src/models/info.dart b/packages/dynamite/dynamite/lib/src/models/openapi/info.dart similarity index 89% rename from packages/dynamite/dynamite/lib/src/models/info.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/info.dart index 3f14c893..1e7d346f 100644 --- a/packages/dynamite/dynamite/lib/src/models/info.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/info.dart @@ -1,6 +1,6 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; -import 'package:dynamite/src/models/license.dart'; +import 'package:dynamite/src/models/openapi/license.dart'; part 'info.g.dart'; diff --git a/packages/dynamite/dynamite/lib/src/models/info.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/info.g.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/info.g.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/info.g.dart diff --git a/packages/dynamite/dynamite/lib/src/models/license.dart b/packages/dynamite/dynamite/lib/src/models/openapi/license.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/license.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/license.dart diff --git a/packages/dynamite/dynamite/lib/src/models/license.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/license.g.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/license.g.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/license.g.dart diff --git a/packages/dynamite/dynamite/lib/src/models/media_type.dart b/packages/dynamite/dynamite/lib/src/models/openapi/media_type.dart similarity index 87% rename from packages/dynamite/dynamite/lib/src/models/media_type.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/media_type.dart index 71363871..9a4b1cc2 100644 --- a/packages/dynamite/dynamite/lib/src/models/media_type.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/media_type.dart @@ -1,6 +1,6 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; -import 'package:dynamite/src/models/schema.dart'; +import 'package:dynamite/src/models/openapi/schema.dart'; part 'media_type.g.dart'; diff --git a/packages/dynamite/dynamite/lib/src/models/media_type.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/media_type.g.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/media_type.g.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/media_type.g.dart diff --git a/packages/dynamite/dynamite/lib/src/models/open_api.dart b/packages/dynamite/dynamite/lib/src/models/openapi/open_api.dart similarity index 77% rename from packages/dynamite/dynamite/lib/src/models/open_api.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/open_api.dart index a6bd891e..0f33dba2 100644 --- a/packages/dynamite/dynamite/lib/src/models/open_api.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/open_api.dart @@ -1,11 +1,11 @@ import 'package:built_collection/built_collection.dart'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; -import 'package:dynamite/src/models/components.dart'; -import 'package:dynamite/src/models/info.dart'; -import 'package:dynamite/src/models/path_item.dart'; -import 'package:dynamite/src/models/server.dart'; -import 'package:dynamite/src/models/tag.dart'; +import 'package:dynamite/src/models/openapi/components.dart'; +import 'package:dynamite/src/models/openapi/info.dart'; +import 'package:dynamite/src/models/openapi/path_item.dart'; +import 'package:dynamite/src/models/openapi/server.dart'; +import 'package:dynamite/src/models/openapi/tag.dart'; part 'open_api.g.dart'; diff --git a/packages/dynamite/dynamite/lib/src/models/open_api.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/open_api.g.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/open_api.g.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/open_api.g.dart diff --git a/packages/dynamite/dynamite/lib/src/models/operation.dart b/packages/dynamite/dynamite/lib/src/models/openapi/operation.dart similarity index 78% rename from packages/dynamite/dynamite/lib/src/models/operation.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/operation.dart index ace1970c..88a8df11 100644 --- a/packages/dynamite/dynamite/lib/src/models/operation.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/operation.dart @@ -2,9 +2,9 @@ import 'package:built_collection/built_collection.dart'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; import 'package:dynamite/src/helpers/docs.dart'; -import 'package:dynamite/src/models/parameter.dart'; -import 'package:dynamite/src/models/request_body.dart'; -import 'package:dynamite/src/models/response.dart'; +import 'package:dynamite/src/models/openapi/parameter.dart'; +import 'package:dynamite/src/models/openapi/request_body.dart'; +import 'package:dynamite/src/models/openapi/response.dart'; part 'operation.g.dart'; @@ -38,7 +38,7 @@ abstract class Operation implements Built { Iterable get formattedDescription sync* { yield* descriptionToDocs(summary); - if (summary != null && description != null) { + if (summary != null && summary!.isNotEmpty && description != null && description!.isNotEmpty) { yield docsSeparator; } diff --git a/packages/dynamite/dynamite/lib/src/models/operation.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/operation.g.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/operation.g.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/operation.g.dart diff --git a/packages/dynamite/dynamite/lib/src/models/parameter.dart b/packages/dynamite/dynamite/lib/src/models/openapi/parameter.dart similarity index 92% rename from packages/dynamite/dynamite/lib/src/models/parameter.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/parameter.dart index 575fcdb8..de74945e 100644 --- a/packages/dynamite/dynamite/lib/src/models/parameter.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/parameter.dart @@ -1,7 +1,7 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; import 'package:dynamite/src/helpers/dynamite.dart'; -import 'package:dynamite/src/models/schema.dart'; +import 'package:dynamite/src/models/openapi/schema.dart'; part 'parameter.g.dart'; diff --git a/packages/dynamite/dynamite/lib/src/models/parameter.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/parameter.g.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/parameter.g.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/parameter.g.dart diff --git a/packages/dynamite/dynamite/lib/src/models/path_item.dart b/packages/dynamite/dynamite/lib/src/models/openapi/path_item.dart similarity index 91% rename from packages/dynamite/dynamite/lib/src/models/path_item.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/path_item.dart index 121f3eb6..a5cf539b 100644 --- a/packages/dynamite/dynamite/lib/src/models/path_item.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/path_item.dart @@ -1,8 +1,8 @@ import 'package:built_collection/built_collection.dart'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; -import 'package:dynamite/src/models/operation.dart'; -import 'package:dynamite/src/models/parameter.dart'; +import 'package:dynamite/src/models/openapi/operation.dart'; +import 'package:dynamite/src/models/openapi/parameter.dart'; part 'path_item.g.dart'; diff --git a/packages/dynamite/dynamite/lib/src/models/path_item.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/path_item.g.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/path_item.g.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/path_item.g.dart diff --git a/packages/dynamite/dynamite/lib/src/models/request_body.dart b/packages/dynamite/dynamite/lib/src/models/openapi/request_body.dart similarity index 90% rename from packages/dynamite/dynamite/lib/src/models/request_body.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/request_body.dart index 9f7417dd..f89d5310 100644 --- a/packages/dynamite/dynamite/lib/src/models/request_body.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/request_body.dart @@ -1,7 +1,7 @@ import 'package:built_collection/built_collection.dart'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; -import 'package:dynamite/src/models/media_type.dart'; +import 'package:dynamite/src/models/openapi/media_type.dart'; part 'request_body.g.dart'; diff --git a/packages/dynamite/dynamite/lib/src/models/request_body.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/request_body.g.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/request_body.g.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/request_body.g.dart diff --git a/packages/dynamite/dynamite/lib/src/models/response.dart b/packages/dynamite/dynamite/lib/src/models/openapi/response.dart similarity index 82% rename from packages/dynamite/dynamite/lib/src/models/response.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/response.dart index 872b6a6f..aedfccca 100644 --- a/packages/dynamite/dynamite/lib/src/models/response.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/response.dart @@ -1,8 +1,8 @@ import 'package:built_collection/built_collection.dart'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; -import 'package:dynamite/src/models/header.dart'; -import 'package:dynamite/src/models/media_type.dart'; +import 'package:dynamite/src/models/openapi/header.dart'; +import 'package:dynamite/src/models/openapi/media_type.dart'; part 'response.g.dart'; diff --git a/packages/dynamite/dynamite/lib/src/models/response.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/response.g.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/response.g.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/response.g.dart diff --git a/packages/dynamite/dynamite/lib/src/models/schema.dart b/packages/dynamite/dynamite/lib/src/models/openapi/schema.dart similarity index 95% rename from packages/dynamite/dynamite/lib/src/models/schema.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/schema.dart index 76030ecd..145e59e6 100644 --- a/packages/dynamite/dynamite/lib/src/models/schema.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/schema.dart @@ -3,7 +3,7 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/json_object.dart'; import 'package:built_value/serializer.dart'; import 'package:dynamite/src/helpers/docs.dart'; -import 'package:dynamite/src/models/discriminator.dart'; +import 'package:dynamite/src/models/openapi/discriminator.dart'; part 'schema.g.dart'; diff --git a/packages/dynamite/dynamite/lib/src/models/schema.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/schema.g.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/schema.g.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/schema.g.dart diff --git a/packages/dynamite/dynamite/lib/src/models/security_scheme.dart b/packages/dynamite/dynamite/lib/src/models/openapi/security_scheme.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/security_scheme.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/security_scheme.dart diff --git a/packages/dynamite/dynamite/lib/src/models/security_scheme.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/security_scheme.g.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/security_scheme.g.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/security_scheme.g.dart diff --git a/packages/dynamite/dynamite/lib/src/models/server.dart b/packages/dynamite/dynamite/lib/src/models/openapi/server.dart similarity index 87% rename from packages/dynamite/dynamite/lib/src/models/server.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/server.dart index af4a364d..c2928115 100644 --- a/packages/dynamite/dynamite/lib/src/models/server.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/server.dart @@ -1,7 +1,7 @@ import 'package:built_collection/built_collection.dart'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; -import 'package:dynamite/src/models/server_variable.dart'; +import 'package:dynamite/src/models/openapi/server_variable.dart'; part 'server.g.dart'; diff --git a/packages/dynamite/dynamite/lib/src/models/server.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/server.g.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/server.g.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/server.g.dart diff --git a/packages/dynamite/dynamite/lib/src/models/server_variable.dart b/packages/dynamite/dynamite/lib/src/models/openapi/server_variable.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/server_variable.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/server_variable.dart diff --git a/packages/dynamite/dynamite/lib/src/models/server_variable.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/server_variable.g.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/server_variable.g.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/server_variable.g.dart diff --git a/packages/dynamite/dynamite/lib/src/models/tag.dart b/packages/dynamite/dynamite/lib/src/models/openapi/tag.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/tag.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/tag.dart diff --git a/packages/dynamite/dynamite/lib/src/models/tag.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/tag.g.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/models/tag.g.dart rename to packages/dynamite/dynamite/lib/src/models/openapi/tag.g.dart diff --git a/packages/dynamite/dynamite/lib/src/models/serializers.dart b/packages/dynamite/dynamite/lib/src/models/serializers.dart deleted file mode 100644 index b4a8ce1a..00000000 --- a/packages/dynamite/dynamite/lib/src/models/serializers.dart +++ /dev/null @@ -1,52 +0,0 @@ -import 'package:built_collection/built_collection.dart'; -import 'package:built_value/serializer.dart'; -import 'package:built_value/standard_json_plugin.dart'; -import 'package:dynamite/src/models/components.dart'; -import 'package:dynamite/src/models/discriminator.dart'; -import 'package:dynamite/src/models/header.dart'; -import 'package:dynamite/src/models/info.dart'; -import 'package:dynamite/src/models/license.dart'; -import 'package:dynamite/src/models/media_type.dart'; -import 'package:dynamite/src/models/open_api.dart'; -import 'package:dynamite/src/models/operation.dart'; -import 'package:dynamite/src/models/parameter.dart'; -import 'package:dynamite/src/models/path_item.dart'; -import 'package:dynamite/src/models/request_body.dart'; -import 'package:dynamite/src/models/response.dart'; -import 'package:dynamite/src/models/schema.dart'; -import 'package:dynamite/src/models/security_scheme.dart'; -import 'package:dynamite/src/models/server.dart'; -import 'package:dynamite/src/models/server_variable.dart'; -import 'package:dynamite/src/models/tag.dart'; - -part 'serializers.g.dart'; - -@SerializersFor([ - Components, - Discriminator, - Header, - Info, - License, - MediaType, - OpenAPI, - Operation, - Parameter, - PathItem, - RequestBody, - Response, - Schema, - SecurityScheme, - Server, - ServerVariable, - Tag, -]) -final Serializers serializers = (_$serializers.toBuilder() - ..addBuilderFactory( - const FullType(BuiltMap, [ - FullType(String), - FullType(BuiltList, [FullType(String)]), - ]), - MapBuilder>.new, - ) - ..addPlugin(StandardJsonPlugin())) - .build(); diff --git a/packages/dynamite/dynamite/lib/src/models/type_result.dart b/packages/dynamite/dynamite/lib/src/models/type_result.dart new file mode 100644 index 00000000..aa13439d --- /dev/null +++ b/packages/dynamite/dynamite/lib/src/models/type_result.dart @@ -0,0 +1 @@ +export 'type_result/type_result.dart'; diff --git a/packages/dynamite/dynamite/lib/src/type_result/base.dart b/packages/dynamite/dynamite/lib/src/models/type_result/base.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/type_result/base.dart rename to packages/dynamite/dynamite/lib/src/models/type_result/base.dart diff --git a/packages/dynamite/dynamite/lib/src/type_result/enum.dart b/packages/dynamite/dynamite/lib/src/models/type_result/enum.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/type_result/enum.dart rename to packages/dynamite/dynamite/lib/src/models/type_result/enum.dart diff --git a/packages/dynamite/dynamite/lib/src/type_result/list.dart b/packages/dynamite/dynamite/lib/src/models/type_result/list.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/type_result/list.dart rename to packages/dynamite/dynamite/lib/src/models/type_result/list.dart diff --git a/packages/dynamite/dynamite/lib/src/type_result/map.dart b/packages/dynamite/dynamite/lib/src/models/type_result/map.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/type_result/map.dart rename to packages/dynamite/dynamite/lib/src/models/type_result/map.dart diff --git a/packages/dynamite/dynamite/lib/src/type_result/object.dart b/packages/dynamite/dynamite/lib/src/models/type_result/object.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/type_result/object.dart rename to packages/dynamite/dynamite/lib/src/models/type_result/object.dart diff --git a/packages/dynamite/dynamite/lib/src/type_result/type_result.dart b/packages/dynamite/dynamite/lib/src/models/type_result/type_result.dart similarity index 100% rename from packages/dynamite/dynamite/lib/src/type_result/type_result.dart rename to packages/dynamite/dynamite/lib/src/models/type_result/type_result.dart diff --git a/packages/dynamite/dynamite/lib/src/openapi_builder.dart b/packages/dynamite/dynamite/lib/src/openapi_builder.dart index c675c6b2..3eaad791 100644 --- a/packages/dynamite/dynamite/lib/src/openapi_builder.dart +++ b/packages/dynamite/dynamite/lib/src/openapi_builder.dart @@ -11,9 +11,8 @@ import 'package:dynamite/src/builder/resolve_type.dart'; import 'package:dynamite/src/builder/serializer.dart'; import 'package:dynamite/src/builder/state.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart'; -import 'package:dynamite/src/models/open_api.dart'; -import 'package:dynamite/src/models/serializers.dart'; -import 'package:dynamite/src/type_result/type_result.dart'; +import 'package:dynamite/src/models/openapi.dart' as openapi; +import 'package:dynamite/src/models/type_result.dart'; class OpenAPIBuilder implements Builder { @override @@ -34,13 +33,13 @@ class OpenAPIBuilder implements Builder { ); final spec = switch (inputId.extension) { - '.json' => serializers.deserializeWith( - OpenAPI.serializer, + '.json' => openapi.serializers.deserializeWith( + openapi.OpenAPI.serializer, json.decode(await buildStep.readAsString(inputId)), )!, '.yaml' => checkedYamlDecode( await buildStep.readAsString(inputId), - (final m) => serializers.deserializeWith(OpenAPI.serializer, m)!, + (final m) => openapi.serializers.deserializeWith(openapi.OpenAPI.serializer, m)!, ), _ => throw StateError('Openapi specs can only be yaml or json.'), }; diff --git a/packages/dynamite/dynamite/test/type_result_test.dart b/packages/dynamite/dynamite/test/type_result_test.dart index 903475f3..e8147142 100644 --- a/packages/dynamite/dynamite/test/type_result_test.dart +++ b/packages/dynamite/dynamite/test/type_result_test.dart @@ -1,4 +1,4 @@ -import 'package:dynamite/src/type_result/type_result.dart'; +import 'package:dynamite/src/models/type_result.dart'; import 'package:test/test.dart'; void main() { From 4cd65a0d0161b8f55262d28a613273fda17cf697 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Sun, 24 Sep 2023 19:54:41 +0200 Subject: [PATCH 2/9] feat(dynamite,nextcloud): use serializer for serializing base types Signed-off-by: Nikolas Rimikis --- .../lib/src/models/type_result/base.dart | 42 ++++++++----------- .../src/models/type_result/type_result.dart | 2 +- .../nextcloud/lib/src/api/core.openapi.dart | 29 ++++++++----- .../lib/src/api/files_sharing.openapi.dart | 12 +++--- .../lib/src/api/provisioning_api.openapi.dart | 14 +++---- .../lib/src/api/user_status.openapi.dart | 4 +- 6 files changed, 52 insertions(+), 51 deletions(-) diff --git a/packages/dynamite/dynamite/lib/src/models/type_result/base.dart b/packages/dynamite/dynamite/lib/src/models/type_result/base.dart index fe9df7f2..aa58e38c 100644 --- a/packages/dynamite/dynamite/lib/src/models/type_result/base.dart +++ b/packages/dynamite/dynamite/lib/src/models/type_result/base.dart @@ -21,37 +21,29 @@ class TypeResultBase extends TypeResult { final String object, { final bool onlyChildren = false, final String? mimeType, - }) => - name == 'String' ? object : '$object.toString()'; - - @override - String deserialize(final String object, {final bool toBuilder = false}) => '($object as $nullableName)'; - - @override - String decode(final String object) { - switch (name) { - case 'String': - return '($object as String)'; - case 'int': - return 'int.parse($object as String)'; - case 'bool': - return "($object as String == 'true')"; - case 'JsonObject': - return 'JsonObject($object)'; + }) { + switch (mimeType) { + case null: + case 'application/json': + case 'application/x-www-form-urlencoded': + if (className == 'String') { + return object; + } else { + return '$object.toString()'; + } + case 'application/octet-stream': + return 'utf8.encode($object) as Uint8List'; default: - throw Exception('Can not decode "$name" from String'); + throw Exception('Can not encode mime type "$mimeType"'); } } @override TypeResultBase get dartType { - final String dartName; - switch (name) { - case 'JsonObject': - dartName = 'dynamic'; - default: - dartName = name; - } + final dartName = switch (name) { + 'JsonObject' => 'dynamic', + _ => name, + }; return TypeResultBase(dartName, nullable: nullable); } diff --git a/packages/dynamite/dynamite/lib/src/models/type_result/type_result.dart b/packages/dynamite/dynamite/lib/src/models/type_result/type_result.dart index 7067ddfc..db2c66ef 100644 --- a/packages/dynamite/dynamite/lib/src/models/type_result/type_result.dart +++ b/packages/dynamite/dynamite/lib/src/models/type_result/type_result.dart @@ -8,7 +8,7 @@ part 'map.dart'; part 'object.dart'; @immutable -abstract class TypeResult { +sealed class TypeResult { TypeResult( this.className, { this.generics = const [], diff --git a/packages/nextcloud/lib/src/api/core.openapi.dart b/packages/nextcloud/lib/src/api/core.openapi.dart index 8b2086fd..85b655c8 100644 --- a/packages/nextcloud/lib/src/api/core.openapi.dart +++ b/packages/nextcloud/lib/src/api/core.openapi.dart @@ -1,5 +1,6 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +import 'dart:convert'; import 'dart:typed_data'; import 'package:built_collection/built_collection.dart'; @@ -2111,7 +2112,10 @@ class CoreWipeClient { body, ); if (response.statusCode == 200 || response.statusCode == 404) { - return JsonObject(await response.body); + return _jsonSerializers.deserialize( + json.decode(await response.body), + specifiedType: const FullType(JsonObject), + )! as JsonObject; } throw await CoreApiException.fromResponse(response); // coverage:ignore-line } @@ -2630,7 +2634,8 @@ class _$CoreAvatarAvatarGetAvatarDarkHeadersSerializer final value = iterator.current! as String; switch (key) { case 'x-nc-iscustomavatar': - result.xNcIscustomavatar = int.parse(value); + result.xNcIscustomavatar = + _jsonSerializers.deserialize(json.decode(value), specifiedType: const FullType(int))! as int; } } @@ -2703,7 +2708,8 @@ class _$CoreAvatarAvatarGetAvatarHeadersSerializer implements StructuredSerializ final value = iterator.current! as String; switch (key) { case 'x-nc-iscustomavatar': - result.xNcIscustomavatar = int.parse(value); + result.xNcIscustomavatar = + _jsonSerializers.deserialize(json.decode(value), specifiedType: const FullType(int))! as int; } } @@ -3587,10 +3593,10 @@ class _$CoreNavigationEntry_OrderSerializer implements PrimitiveSerializer x != null).isNotEmpty, 'Need oneOf for ${result._data}'); return result.build(); @@ -3837,7 +3843,10 @@ class _$CoreOcmOcmDiscoveryHeadersSerializer implements StructuredSerializer x != null).isNotEmpty, 'Need oneOf for ${result._data}'); return result.build(); @@ -7569,10 +7578,10 @@ class _$CoreUnifiedSearchResult_CursorSerializer implements PrimitiveSerializer< }) { final result = CoreUnifiedSearchResult_CursorBuilder()..data = JsonObject(data); try { - result._$int = data as int?; + result._$int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int; } catch (_) {} try { - result._string = data as String?; + result._string = _jsonSerializers.deserialize(data, specifiedType: const FullType(String))! as String; } catch (_) {} assert([result._$int, result._string].where((final x) => x != null).isNotEmpty, 'Need oneOf for ${result._data}'); return result.build(); diff --git a/packages/nextcloud/lib/src/api/files_sharing.openapi.dart b/packages/nextcloud/lib/src/api/files_sharing.openapi.dart index e1c07dfc..9368a709 100644 --- a/packages/nextcloud/lib/src/api/files_sharing.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_sharing.openapi.dart @@ -1876,10 +1876,10 @@ class _$FilesSharingShareInfo_SizeSerializer implements PrimitiveSerializer x != null).isNotEmpty, 'Need oneOf for ${result._data}'); return result.build(); @@ -1970,10 +1970,10 @@ class _$FilesSharingShare_ItemSizeSerializer implements PrimitiveSerializer x != null).isNotEmpty, 'Need oneOf for ${result._data}'); return result.build(); @@ -2739,7 +2739,7 @@ class _$FilesSharingShareesapiSearchShareTypeSerializer }) { final result = FilesSharingShareesapiSearchShareTypeBuilder()..data = JsonObject(data); try { - result._$int = data as int?; + result._$int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int; } catch (_) {} try { result._builtListInt = (_jsonSerializers.deserialize( @@ -3540,7 +3540,7 @@ class _$FilesSharingShareesapiFindRecommendedShareTypeSerializer }) { final result = FilesSharingShareesapiFindRecommendedShareTypeBuilder()..data = JsonObject(data); try { - result._$int = data as int?; + result._$int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int; } catch (_) {} try { result._builtListInt = (_jsonSerializers.deserialize( diff --git a/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart b/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart index bb60b0d7..04ac33f2 100644 --- a/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart +++ b/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart @@ -3190,10 +3190,10 @@ class _$ProvisioningApiGroupDetails_UsercountSerializer }) { final result = ProvisioningApiGroupDetails_UsercountBuilder()..data = JsonObject(data); try { - result._$bool = data as bool?; + result._$bool = _jsonSerializers.deserialize(data, specifiedType: const FullType(bool))! as bool; } catch (_) {} try { - result._$int = data as int?; + result._$int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int; } catch (_) {} assert([result._$bool, result._$int].where((final x) => x != null).isNotEmpty, 'Need oneOf for ${result._data}'); return result.build(); @@ -3250,10 +3250,10 @@ class _$ProvisioningApiGroupDetails_DisabledSerializer }) { final result = ProvisioningApiGroupDetails_DisabledBuilder()..data = JsonObject(data); try { - result._$bool = data as bool?; + result._$bool = _jsonSerializers.deserialize(data, specifiedType: const FullType(bool))! as bool; } catch (_) {} try { - result._$int = data as int?; + result._$int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int; } catch (_) {} assert([result._$bool, result._$int].where((final x) => x != null).isNotEmpty, 'Need oneOf for ${result._data}'); return result.build(); @@ -3600,13 +3600,13 @@ class _$ProvisioningApiUserDetailsQuota_QuotaSerializer }) { final result = ProvisioningApiUserDetailsQuota_QuotaBuilder()..data = JsonObject(data); try { - result._$num = data as num?; + result._$num = _jsonSerializers.deserialize(data, specifiedType: const FullType(num))! as num; } catch (_) {} try { - result._$int = data as int?; + result._$int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int; } catch (_) {} try { - result._string = data as String?; + result._string = _jsonSerializers.deserialize(data, specifiedType: const FullType(String))! as String; } catch (_) {} assert( [result._$num, result._$int, result._string].where((final x) => x != null).isNotEmpty, diff --git a/packages/nextcloud/lib/src/api/user_status.openapi.dart b/packages/nextcloud/lib/src/api/user_status.openapi.dart index 96563011..904e89c5 100644 --- a/packages/nextcloud/lib/src/api/user_status.openapi.dart +++ b/packages/nextcloud/lib/src/api/user_status.openapi.dart @@ -766,7 +766,7 @@ class _$UserStatusClearAt_TimeSerializer implements PrimitiveSerializer x != null).isNotEmpty, From 701be33fa6500cd165e5a5f9b67f5cc86c7eab61 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Sun, 24 Sep 2023 21:02:39 +0200 Subject: [PATCH 3/9] style(dynamite,dynamite_runtime,nextcloud): externalize auth check Signed-off-by: Nikolas Rimikis --- .../dynamite/lib/src/builder/client.dart | 105 +- .../dynamite/lib/src/builder/imports.dart | 2 + .../dynamite_runtime/lib/src/http_client.dart | 58 +- .../dynamite/dynamite_runtime/pubspec.yaml | 1 + .../lib/src/api/comments.openapi.dart | 1 + .../nextcloud/lib/src/api/core.openapi.dart | 929 +++++++++++------- .../lib/src/api/dashboard.openapi.dart | 65 +- .../nextcloud/lib/src/api/dav.openapi.dart | 23 +- .../nextcloud/lib/src/api/files.openapi.dart | 275 ++++-- .../lib/src/api/files_external.openapi.dart | 23 +- .../lib/src/api/files_reminders.openapi.dart | 65 +- .../lib/src/api/files_sharing.openapi.dart | 443 +++++---- .../lib/src/api/files_trashbin.openapi.dart | 23 +- .../lib/src/api/files_versions.openapi.dart | 23 +- .../nextcloud/lib/src/api/news.openapi.dart | 344 +++++-- .../nextcloud/lib/src/api/notes.openapi.dart | 135 ++- .../lib/src/api/notifications.openapi.dart | 212 ++-- .../lib/src/api/provisioning_api.openapi.dart | 905 ++++++++++------- .../lib/src/api/settings.openapi.dart | 23 +- .../lib/src/api/sharebymail.openapi.dart | 1 + .../lib/src/api/theming.openapi.dart | 233 +++-- .../src/api/updatenotification.openapi.dart | 23 +- .../nextcloud/lib/src/api/uppush.openapi.dart | 211 +++- .../lib/src/api/user_status.openapi.dart | 212 ++-- .../lib/src/api/weather_status.openapi.dart | 149 +-- packages/nextcloud/pubspec.yaml | 1 + 26 files changed, 2921 insertions(+), 1564 deletions(-) diff --git a/packages/dynamite/dynamite/lib/src/builder/client.dart b/packages/dynamite/dynamite/lib/src/builder/client.dart index f64f9f98..16cac51c 100644 --- a/packages/dynamite/dynamite/lib/src/builder/client.dart +++ b/packages/dynamite/dynamite/lib/src/builder/client.dart @@ -9,6 +9,7 @@ import 'package:dynamite/src/helpers/dynamite.dart'; import 'package:dynamite/src/helpers/type_result.dart'; import 'package:dynamite/src/models/openapi.dart' as openapi; import 'package:dynamite/src/models/type_result.dart'; +import 'package:intersperse/intersperse.dart'; List generateDynamiteOverrides(final State state) => [ Class( @@ -274,7 +275,7 @@ Iterable buildTags( final List tags, final String? tag, ) sync* { - final isRootClient = tag == null; + final client = tag == null ? 'this' : '_rootClient'; final paths = generatePaths(spec, tag); for (final pathEntry in paths.entries) { @@ -312,42 +313,29 @@ Iterable buildTags( } } + final code = StringBuffer(); + final acceptHeader = responses.keys .map((final response) => response.content?.keys) .whereNotNull() .expand((final element) => element) .toSet() .join(','); - final code = StringBuffer(''' -var _path = '${pathEntry.key}'; -final _queryParameters = {}; -final _headers = {${acceptHeader.isNotEmpty ? "'Accept': '$acceptHeader'," : ''}}; -Uint8List? _body; -'''); - final security = operation.security ?? spec.security ?? BuiltList(); - final securityRequirements = security.where((final requirement) => requirement.isNotEmpty); - final isOptionalSecurity = securityRequirements.length != security.length; - code.write(' // coverage:ignore-start\n'); - for (final requirement in securityRequirements) { - final securityScheme = spec.components!.securitySchemes![requirement.keys.single]!; - code.write(''' -if (${isRootClient ? 'this' : '_rootClient'}.authentications.where((final a) => a.type == '${securityScheme.type}' && a.scheme == '${securityScheme.scheme}').isNotEmpty) { - _headers.addAll(${isRootClient ? 'this' : '_rootClient'}.authentications.singleWhere((final a) => a.type == '${securityScheme.type}' && a.scheme == '${securityScheme.scheme}').headers); -} -'''); - if (securityRequirements.last != requirement) { - code.write('else '); - } - } - if (securityRequirements.isNotEmpty && !isOptionalSecurity) { - code.write(''' -else { - throw Exception('Missing authentication for ${securityRequirements.map((final r) => r.keys.single).join(' or ')}'); -} -'''); - } - code.write(' // coverage:ignore-end\n'); + code.writeln(''' + var _path = '${pathEntry.key}'; + final _queryParameters = {}; + final _headers = {${acceptHeader.isNotEmpty ? "'Accept': '$acceptHeader'," : ''}}; + Uint8List? _body; + '''); + + buildAuthCheck( + responses, + pathEntry, + operation, + spec, + client, + ).forEach(code.writeln); for (final parameter in parameters) { final dartParameterNullable = isDartParameterNullable( @@ -502,7 +490,7 @@ if (${toDartName(parameter.name)}.length > ${parameter.schema!.maxLength!}) { code.write( ''' -final _response = await ${isRootClient ? 'this' : '_rootClient'}.doRequest( +final _response = await $client.doRequest( '$httpMethod', Uri(path: _path, queryParameters: _queryParameters.isNotEmpty ? _queryParameters : null), _headers, @@ -622,6 +610,61 @@ final _response = await ${isRootClient ? 'this' : '_rootClient'}.doRequest( } } +Iterable buildAuthCheck( + final Map> responses, + final MapEntry pathEntry, + final openapi.Operation operation, + final openapi.OpenAPI spec, + final String client, +) sync* { + final security = operation.security ?? spec.security ?? BuiltList(); + final securityRequirements = security.where((final requirement) => requirement.isNotEmpty); + final isOptionalSecurity = securityRequirements.length != security.length; + + if (securityRequirements.isEmpty) { + return; + } + + yield ''' +// coverage:ignore-start +final authentication = $client.authentications.firstWhereOrNull( + (final auth) => switch (auth) { +'''; + + yield* securityRequirements.map((final requirement) { + final securityScheme = spec.components!.securitySchemes![requirement.keys.single]!; + final dynamiteAuth = toDartName( + 'Dynamite-${securityScheme.type}-${securityScheme.scheme}-Authentication', + uppercaseFirstCharacter: true, + ); + return '$dynamiteAuth()'; + }).intersperse(' || '); + + yield ''' + => true, + _ => false, + }, + ); +'''; + + yield ''' +if(authentication != null) { + _headers.addAll( + authentication.headers, + ); +} +'''; + + if (!isOptionalSecurity) { + yield ''' +else { + throw Exception('Missing authentication for ${securityRequirements.map((final r) => r.keys.single).join(' or ')}'); +} +'''; + } + yield '// coverage:ignore-end'; +} + Map generatePaths(final openapi.OpenAPI spec, final String? tag) { final paths = {}; diff --git a/packages/dynamite/dynamite/lib/src/builder/imports.dart b/packages/dynamite/dynamite/lib/src/builder/imports.dart index c847f0d2..7e15b857 100644 --- a/packages/dynamite/dynamite/lib/src/builder/imports.dart +++ b/packages/dynamite/dynamite/lib/src/builder/imports.dart @@ -5,6 +5,7 @@ import 'package:path/path.dart' as p; List generateImports(final AssetId outputId) => [ const Code('// ignore_for_file: camel_case_types'), const Code('// ignore_for_file: public_member_api_docs'), + const Code('// ignore_for_file: unreachable_switch_case'), Directive.import('dart:convert'), Directive.import('dart:typed_data'), const Code(''), @@ -13,6 +14,7 @@ List generateImports(final AssetId outputId) => [ Directive.import('package:built_value/json_object.dart'), Directive.import('package:built_value/serializer.dart'), Directive.import('package:built_value/standard_json_plugin.dart'), + Directive.import('package:collection/collection.dart'), Directive.import('package:dynamite_runtime/content_string.dart'), Directive.import('package:dynamite_runtime/http_client.dart'), Directive.import('package:universal_io/io.dart'), diff --git a/packages/dynamite/dynamite_runtime/lib/src/http_client.dart b/packages/dynamite/dynamite_runtime/lib/src/http_client.dart index 52366962..eb16c8b2 100644 --- a/packages/dynamite/dynamite_runtime/lib/src/http_client.dart +++ b/packages/dynamite/dynamite_runtime/lib/src/http_client.dart @@ -4,6 +4,7 @@ import 'dart:typed_data'; import 'package:cookie_jar/cookie_jar.dart'; import 'package:dynamite_runtime/src/uri.dart'; +import 'package:meta/meta.dart'; import 'package:universal_io/io.dart'; export 'package:cookie_jar/cookie_jar.dart'; @@ -62,47 +63,66 @@ class DynamiteApiException implements Exception { String toString() => 'DynamiteApiException(statusCode: $statusCode, headers: $headers, body: $body)'; } -abstract class DynamiteAuthentication { - String get type; - String get scheme; +/// Base dynamite authentication. +/// +/// See: +/// * [DynamiteResponse] as the response returned by an operation. +/// * [DynamiteApiException] as the exception that can be thrown in operations +/// * [DynamiteClient] for the client providing operations. +@immutable +sealed class DynamiteAuthentication { + /// Creates a new authentication. + const DynamiteAuthentication({ + required this.type, + required this.scheme, + }); + + /// The base type of the authentication. + final String type; + + /// The used authentication scheme. + final String scheme; + + /// The authentication headers added to a request. Map get headers; } +/// Basic http authentication with username and password. class DynamiteHttpBasicAuthentication extends DynamiteAuthentication { - DynamiteHttpBasicAuthentication({ + /// Creates a new http basic authentication. + const DynamiteHttpBasicAuthentication({ required this.username, required this.password, - }); + }) : super( + type: 'http', + scheme: 'basic', + ); + /// The username. final String username; + /// The password. final String password; - @override - String type = 'http'; - - @override - String scheme = 'basic'; - @override Map get headers => { 'Authorization': 'Basic ${base64.encode(utf8.encode('$username:$password'))}', }; } +/// Http bearer authentication with a token. class DynamiteHttpBearerAuthentication extends DynamiteAuthentication { - DynamiteHttpBearerAuthentication({ + /// Creates a new http bearer authentication. + const DynamiteHttpBearerAuthentication({ required this.token, - }); + }) : super( + type: 'http', + scheme: 'bearer', + ); + /// The authentication token. final String token; - @override - String type = 'http'; - - @override - String scheme = 'bearer'; - @override Map get headers => { 'Authorization': 'Bearer $token', diff --git a/packages/dynamite/dynamite_runtime/pubspec.yaml b/packages/dynamite/dynamite_runtime/pubspec.yaml index c0c34740..5de176e5 100644 --- a/packages/dynamite/dynamite_runtime/pubspec.yaml +++ b/packages/dynamite/dynamite_runtime/pubspec.yaml @@ -8,6 +8,7 @@ environment: dependencies: built_value: ^8.6.3 cookie_jar: ^4.0.8 + meta: ^1.9.1 universal_io: ^2.2.2 dev_dependencies: diff --git a/packages/nextcloud/lib/src/api/comments.openapi.dart b/packages/nextcloud/lib/src/api/comments.openapi.dart index a8576d69..9edddb21 100644 --- a/packages/nextcloud/lib/src/api/comments.openapi.dart +++ b/packages/nextcloud/lib/src/api/comments.openapi.dart @@ -1,5 +1,6 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; diff --git a/packages/nextcloud/lib/src/api/core.openapi.dart b/packages/nextcloud/lib/src/api/core.openapi.dart index 85b655c8..0e4c38e1 100644 --- a/packages/nextcloud/lib/src/api/core.openapi.dart +++ b/packages/nextcloud/lib/src/api/core.openapi.dart @@ -1,5 +1,6 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'dart:convert'; import 'dart:typed_data'; @@ -8,6 +9,7 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/json_object.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:universal_io/io.dart'; @@ -116,8 +118,7 @@ class CoreClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - // coverage:ignore-end + final response = await doRequest( 'get', Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), @@ -145,19 +146,24 @@ class CoreAppPasswordClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -184,19 +190,24 @@ class CoreAppPasswordClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'post', @@ -223,19 +234,24 @@ class CoreAppPasswordClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'delete', @@ -274,19 +290,24 @@ class CoreAutoCompleteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['search'] = search; if (itemType != null) { queryParameters['itemType'] = itemType; @@ -337,17 +358,22 @@ class CoreAvatarClient { 'Accept': '*/*', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); path = path.replaceAll('{size}', Uri.encodeQueryComponent(size.toString())); final response = await _rootClient.doRequest( @@ -379,17 +405,22 @@ class CoreAvatarClient { 'Accept': '*/*', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); path = path.replaceAll('{size}', Uri.encodeQueryComponent(size.toString())); final response = await _rootClient.doRequest( @@ -424,17 +455,22 @@ class CoreClientFlowLoginV2Client { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['token'] = token; final response = await _rootClient.doRequest( 'post', @@ -459,17 +495,22 @@ class CoreClientFlowLoginV2Client { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end final response = await _rootClient.doRequest( 'post', Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), @@ -500,19 +541,24 @@ class CoreCollaborationResourcesClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{filter}', Uri.encodeQueryComponent(filter)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -541,19 +587,24 @@ class CoreCollaborationResourcesClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{collectionId}', Uri.encodeQueryComponent(collectionId.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -583,19 +634,24 @@ class CoreCollaborationResourcesClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['collectionName'] = collectionName; path = path.replaceAll('{collectionId}', Uri.encodeQueryComponent(collectionId.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -627,19 +683,24 @@ class CoreCollaborationResourcesClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['resourceType'] = resourceType; queryParameters['resourceId'] = resourceId; path = path.replaceAll('{collectionId}', Uri.encodeQueryComponent(collectionId.toString())); @@ -672,19 +733,24 @@ class CoreCollaborationResourcesClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['resourceType'] = resourceType; queryParameters['resourceId'] = resourceId; path = path.replaceAll('{collectionId}', Uri.encodeQueryComponent(collectionId.toString())); @@ -716,19 +782,24 @@ class CoreCollaborationResourcesClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{resourceType}', Uri.encodeQueryComponent(resourceType)); path = path.replaceAll('{resourceId}', Uri.encodeQueryComponent(resourceId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -760,19 +831,24 @@ class CoreCollaborationResourcesClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['name'] = name; path = path.replaceAll('{baseResourceType}', Uri.encodeQueryComponent(baseResourceType)); path = path.replaceAll('{baseResourceId}', Uri.encodeQueryComponent(baseResourceId)); @@ -810,17 +886,22 @@ class CoreGuestAvatarClient { 'Accept': '*/*', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{guestName}', Uri.encodeQueryComponent(guestName)); path = path.replaceAll('{size}', Uri.encodeQueryComponent(size)); final response = await _rootClient.doRequest( @@ -847,17 +928,22 @@ class CoreGuestAvatarClient { 'Accept': '*/*', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{guestName}', Uri.encodeQueryComponent(guestName)); path = path.replaceAll('{size}', Uri.encodeQueryComponent(size)); if (darkTheme != null) { @@ -894,19 +980,24 @@ class CoreHoverCardClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -941,19 +1032,24 @@ class CoreNavigationClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (absolute != 0) { queryParameters['absolute'] = absolute.toString(); } @@ -984,19 +1080,24 @@ class CoreNavigationClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (absolute != 0) { queryParameters['absolute'] = absolute.toString(); } @@ -1031,17 +1132,22 @@ class CoreOcmClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end final response = await _rootClient.doRequest( 'get', Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), @@ -1077,17 +1183,22 @@ class CoreOcsClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -1126,19 +1237,24 @@ class CorePreviewClient { 'Accept': '*/*', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (fileId != -1) { queryParameters['fileId'] = fileId.toString(); } @@ -1188,19 +1304,24 @@ class CorePreviewClient { 'Accept': '*/*', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (file != '') { queryParameters['file'] = file; } @@ -1253,19 +1374,24 @@ class CoreProfileApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['paramId'] = paramId; queryParameters['visibility'] = visibility; path = path.replaceAll('{targetUserId}', Uri.encodeQueryComponent(targetUserId)); @@ -1299,17 +1425,22 @@ class CoreReferenceClient { 'Accept': '*/*', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{referenceId}', Uri.encodeQueryComponent(referenceId)); final response = await _rootClient.doRequest( 'get', @@ -1340,19 +1471,24 @@ class CoreReferenceApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['reference'] = reference; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -1382,19 +1518,24 @@ class CoreReferenceApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['references[]'] = references.map((final e) => e); if (limit != 1) { queryParameters['limit'] = limit.toString(); @@ -1428,19 +1569,24 @@ class CoreReferenceApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['text'] = text; if (resolve != 0) { queryParameters['resolve'] = resolve.toString(); @@ -1474,19 +1620,24 @@ class CoreReferenceApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -1515,19 +1666,24 @@ class CoreReferenceApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{providerId}', Uri.encodeQueryComponent(providerId)); if (timestamp != null) { queryParameters['timestamp'] = timestamp.toString(); @@ -1562,17 +1718,22 @@ class CoreTextProcessingApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -1603,17 +1764,22 @@ class CoreTextProcessingApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['input'] = input; queryParameters['type'] = type; queryParameters['appId'] = appId; @@ -1647,17 +1813,22 @@ class CoreTextProcessingApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -1686,19 +1857,24 @@ class CoreTextProcessingApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -1728,19 +1904,24 @@ class CoreTextProcessingApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{appId}', Uri.encodeQueryComponent(appId)); if (identifier != null) { queryParameters['identifier'] = identifier; @@ -1775,17 +1956,22 @@ class CoreTranslationApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -1815,17 +2001,22 @@ class CoreTranslationApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['text'] = text; queryParameters['toLanguage'] = toLanguage; if (fromLanguage != null) { @@ -1864,19 +2055,24 @@ class CoreUnifiedSearchClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (from != '') { queryParameters['from'] = from; } @@ -1912,19 +2108,24 @@ class CoreUnifiedSearchClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{providerId}', Uri.encodeQueryComponent(providerId)); if (term != '') { queryParameters['term'] = term; @@ -1974,19 +2175,24 @@ class CoreWhatsNewClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -2014,19 +2220,24 @@ class CoreWhatsNewClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['version'] = version; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -2058,17 +2269,22 @@ class CoreWipeClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['token'] = token; final response = await _rootClient.doRequest( 'post', @@ -2093,17 +2309,22 @@ class CoreWipeClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['token'] = token; final response = await _rootClient.doRequest( 'post', diff --git a/packages/nextcloud/lib/src/api/dashboard.openapi.dart b/packages/nextcloud/lib/src/api/dashboard.openapi.dart index 126c77d2..21dbfcdf 100644 --- a/packages/nextcloud/lib/src/api/dashboard.openapi.dart +++ b/packages/nextcloud/lib/src/api/dashboard.openapi.dart @@ -1,11 +1,13 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'dart:typed_data'; import 'package:built_collection/built_collection.dart'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:universal_io/io.dart'; @@ -85,19 +87,24 @@ class DashboardDashboardApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -127,19 +134,24 @@ class DashboardDashboardApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (sinceIds != null) { queryParameters['sinceIds'] = _jsonSerializers.serialize( sinceIds, @@ -183,19 +195,24 @@ class DashboardDashboardApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (sinceIds != null) { queryParameters['sinceIds'] = _jsonSerializers.serialize( sinceIds, diff --git a/packages/nextcloud/lib/src/api/dav.openapi.dart b/packages/nextcloud/lib/src/api/dav.openapi.dart index 0660ed34..7e37ffd4 100644 --- a/packages/nextcloud/lib/src/api/dav.openapi.dart +++ b/packages/nextcloud/lib/src/api/dav.openapi.dart @@ -1,10 +1,12 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'dart:typed_data'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:universal_io/io.dart'; @@ -88,19 +90,24 @@ class DavDirectClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['fileId'] = fileId.toString(); if (expirationTime != null) { queryParameters['expirationTime'] = expirationTime.toString(); diff --git a/packages/nextcloud/lib/src/api/files.openapi.dart b/packages/nextcloud/lib/src/api/files.openapi.dart index 71785dd1..d97ff316 100644 --- a/packages/nextcloud/lib/src/api/files.openapi.dart +++ b/packages/nextcloud/lib/src/api/files.openapi.dart @@ -1,5 +1,6 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'dart:typed_data'; import 'package:built_collection/built_collection.dart'; @@ -7,6 +8,7 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/json_object.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:universal_io/io.dart'; @@ -98,19 +100,24 @@ class FilesApiClient { 'Accept': '*/*', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{x}', Uri.encodeQueryComponent(x.toString())); path = path.replaceAll('{y}', Uri.encodeQueryComponent(y.toString())); if (!RegExp(r'^.+$').hasMatch(file)) { @@ -143,19 +150,24 @@ class FilesDirectEditingClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -184,19 +196,24 @@ class FilesDirectEditingClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{editorId}', Uri.encodeQueryComponent(editorId)); path = path.replaceAll('{creatorId}', Uri.encodeQueryComponent(creatorId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -228,19 +245,24 @@ class FilesDirectEditingClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['path'] = path; if (editorId != null) { queryParameters['editorId'] = editorId; @@ -278,19 +300,24 @@ class FilesDirectEditingClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['path'] = path; queryParameters['editorId'] = editorId; queryParameters['creatorId'] = creatorId; @@ -330,19 +357,24 @@ class FilesOpenLocalEditorClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['path'] = path; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -372,19 +404,24 @@ class FilesOpenLocalEditorClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['path'] = path; path0 = path0.replaceAll('{token}', Uri.encodeQueryComponent(token)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -417,19 +454,24 @@ class FilesTemplateClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -459,19 +501,24 @@ class FilesTemplateClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['filePath'] = filePath; if (templatePath != '') { queryParameters['templatePath'] = templatePath; @@ -507,19 +554,24 @@ class FilesTemplateClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (templatePath != '') { queryParameters['templatePath'] = templatePath; } @@ -560,19 +612,24 @@ class FilesTransferOwnershipClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['recipient'] = recipient; queryParameters['path'] = path; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -602,19 +659,24 @@ class FilesTransferOwnershipClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -643,19 +705,24 @@ class FilesTransferOwnershipClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( diff --git a/packages/nextcloud/lib/src/api/files_external.openapi.dart b/packages/nextcloud/lib/src/api/files_external.openapi.dart index 457b28c2..f90baaa4 100644 --- a/packages/nextcloud/lib/src/api/files_external.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_external.openapi.dart @@ -1,5 +1,6 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'dart:typed_data'; import 'package:built_collection/built_collection.dart'; @@ -7,6 +8,7 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/json_object.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:universal_io/io.dart'; @@ -86,19 +88,24 @@ class FilesExternalApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', diff --git a/packages/nextcloud/lib/src/api/files_reminders.openapi.dart b/packages/nextcloud/lib/src/api/files_reminders.openapi.dart index 87b28ecb..e0d6bb7e 100644 --- a/packages/nextcloud/lib/src/api/files_reminders.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_reminders.openapi.dart @@ -1,11 +1,13 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'dart:typed_data'; import 'package:built_value/built_value.dart'; import 'package:built_value/json_object.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:universal_io/io.dart'; @@ -89,19 +91,24 @@ class FilesRemindersApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (!RegExp(r'^1$').hasMatch(version)) { throw Exception( 'Invalid value "$version" for parameter "version" with pattern "${r'^1$'}"', @@ -138,19 +145,24 @@ class FilesRemindersApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['dueDate'] = dueDate; if (!RegExp(r'^1$').hasMatch(version)) { throw Exception( @@ -191,19 +203,24 @@ class FilesRemindersApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (!RegExp(r'^1$').hasMatch(version)) { throw Exception( 'Invalid value "$version" for parameter "version" with pattern "${r'^1$'}"', diff --git a/packages/nextcloud/lib/src/api/files_sharing.openapi.dart b/packages/nextcloud/lib/src/api/files_sharing.openapi.dart index 9368a709..cfdfd1c5 100644 --- a/packages/nextcloud/lib/src/api/files_sharing.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_sharing.openapi.dart @@ -1,5 +1,6 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'dart:typed_data'; import 'package:built_collection/built_collection.dart'; @@ -7,6 +8,7 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/json_object.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:universal_io/io.dart'; @@ -96,19 +98,24 @@ class FilesSharingDeletedShareapiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -136,19 +143,24 @@ class FilesSharingDeletedShareapiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -183,17 +195,22 @@ class FilesSharingPublicPreviewClient { 'Accept': '*/*', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{token}', Uri.encodeQueryComponent(token)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -223,17 +240,22 @@ class FilesSharingPublicPreviewClient { 'Accept': '*/*', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{token}', Uri.encodeQueryComponent(token)); if (file != '') { queryParameters['file'] = file; @@ -274,19 +296,24 @@ class FilesSharingRemoteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -313,19 +340,24 @@ class FilesSharingRemoteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -353,19 +385,24 @@ class FilesSharingRemoteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -394,19 +431,24 @@ class FilesSharingRemoteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -435,19 +477,24 @@ class FilesSharingRemoteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -476,19 +523,24 @@ class FilesSharingRemoteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -525,17 +577,22 @@ class FilesSharingShareInfoClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['t'] = t; if (password != null) { queryParameters['password'] = password; @@ -582,19 +639,24 @@ class FilesSharingShareapiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (sharedWithMe != 'false') { queryParameters['shared_with_me'] = sharedWithMe; } @@ -647,19 +709,24 @@ class FilesSharingShareapiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (path != null) { queryParameters['path'] = path; } @@ -720,19 +787,24 @@ class FilesSharingShareapiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['path'] = path; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -760,19 +832,24 @@ class FilesSharingShareapiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -801,19 +878,24 @@ class FilesSharingShareapiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id)); if (includeTags != 0) { queryParameters['include_tags'] = includeTags.toString(); @@ -854,19 +936,24 @@ class FilesSharingShareapiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id)); if (permissions != null) { queryParameters['permissions'] = permissions.toString(); @@ -922,19 +1009,24 @@ class FilesSharingShareapiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -963,19 +1055,24 @@ class FilesSharingShareapiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -1017,19 +1114,24 @@ class FilesSharingShareesapiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (search != '') { queryParameters['search'] = search; } @@ -1086,19 +1188,24 @@ class FilesSharingShareesapiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['itemType'] = itemType; if (shareType != null) { queryParameters['shareType'] = _jsonSerializers.serialize( diff --git a/packages/nextcloud/lib/src/api/files_trashbin.openapi.dart b/packages/nextcloud/lib/src/api/files_trashbin.openapi.dart index 670d5527..ee0e59e0 100644 --- a/packages/nextcloud/lib/src/api/files_trashbin.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_trashbin.openapi.dart @@ -1,10 +1,12 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'dart:typed_data'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:universal_io/io.dart'; @@ -89,19 +91,24 @@ class FilesTrashbinPreviewClient { 'Accept': '*/*', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (fileId != -1) { queryParameters['fileId'] = fileId.toString(); } diff --git a/packages/nextcloud/lib/src/api/files_versions.openapi.dart b/packages/nextcloud/lib/src/api/files_versions.openapi.dart index 3018a2ae..9025edcf 100644 --- a/packages/nextcloud/lib/src/api/files_versions.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_versions.openapi.dart @@ -1,10 +1,12 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'dart:typed_data'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:universal_io/io.dart'; @@ -89,19 +91,24 @@ class FilesVersionsPreviewClient { 'Accept': '*/*', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (file != '') { queryParameters['file'] = file; } diff --git a/packages/nextcloud/lib/src/api/news.openapi.dart b/packages/nextcloud/lib/src/api/news.openapi.dart index 25b0d0b9..109b9dc9 100644 --- a/packages/nextcloud/lib/src/api/news.openapi.dart +++ b/packages/nextcloud/lib/src/api/news.openapi.dart @@ -1,5 +1,6 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'dart:typed_data'; import 'package:built_collection/built_collection.dart'; @@ -7,6 +8,7 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/json_object.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:universal_io/io.dart'; @@ -77,13 +79,24 @@ class NewsClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end final response = await doRequest( 'get', Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), @@ -106,13 +119,24 @@ class NewsClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end final response = await doRequest( 'get', Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), @@ -133,13 +157,24 @@ class NewsClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['name'] = name; final response = await doRequest( 'post', @@ -162,13 +197,24 @@ class NewsClient extends DynamiteClient { final queryParameters = {}; final headers = {}; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{folderId}', Uri.encodeQueryComponent(folderId.toString())); queryParameters['name'] = name; final response = await doRequest( @@ -188,13 +234,24 @@ class NewsClient extends DynamiteClient { final queryParameters = {}; final headers = {}; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{folderId}', Uri.encodeQueryComponent(folderId.toString())); final response = await doRequest( 'delete', @@ -216,13 +273,24 @@ class NewsClient extends DynamiteClient { final queryParameters = {}; final headers = {}; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{folderId}', Uri.encodeQueryComponent(folderId.toString())); queryParameters['newestItemId'] = newestItemId.toString(); final response = await doRequest( @@ -244,13 +312,24 @@ class NewsClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end final response = await doRequest( 'get', Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), @@ -274,13 +353,24 @@ class NewsClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['url'] = url; if (folderId != null) { queryParameters['folderId'] = folderId.toString(); @@ -303,13 +393,24 @@ class NewsClient extends DynamiteClient { final queryParameters = {}; final headers = {}; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{feedId}', Uri.encodeQueryComponent(feedId.toString())); final response = await doRequest( 'delete', @@ -331,13 +432,24 @@ class NewsClient extends DynamiteClient { final queryParameters = {}; final headers = {}; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{feedId}', Uri.encodeQueryComponent(feedId.toString())); if (folderId != null) { queryParameters['folderId'] = folderId.toString(); @@ -362,13 +474,24 @@ class NewsClient extends DynamiteClient { final queryParameters = {}; final headers = {}; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{feedId}', Uri.encodeQueryComponent(feedId.toString())); queryParameters['feedTitle'] = feedTitle; final response = await doRequest( @@ -391,13 +514,24 @@ class NewsClient extends DynamiteClient { final queryParameters = {}; final headers = {}; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{feedId}', Uri.encodeQueryComponent(feedId.toString())); queryParameters['newestItemId'] = newestItemId.toString(); final response = await doRequest( @@ -426,13 +560,24 @@ class NewsClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (type != 3) { queryParameters['type'] = type.toString(); } @@ -475,13 +620,24 @@ class NewsClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (type != 3) { queryParameters['type'] = type.toString(); } @@ -509,13 +665,24 @@ class NewsClient extends DynamiteClient { final queryParameters = {}; final headers = {}; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{itemId}', Uri.encodeQueryComponent(itemId.toString())); final response = await doRequest( 'post', @@ -534,13 +701,24 @@ class NewsClient extends DynamiteClient { final queryParameters = {}; final headers = {}; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{itemId}', Uri.encodeQueryComponent(itemId.toString())); final response = await doRequest( 'post', @@ -559,13 +737,24 @@ class NewsClient extends DynamiteClient { final queryParameters = {}; final headers = {}; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{itemId}', Uri.encodeQueryComponent(itemId.toString())); final response = await doRequest( 'post', @@ -584,13 +773,24 @@ class NewsClient extends DynamiteClient { final queryParameters = {}; final headers = {}; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{itemId}', Uri.encodeQueryComponent(itemId.toString())); final response = await doRequest( 'post', diff --git a/packages/nextcloud/lib/src/api/notes.openapi.dart b/packages/nextcloud/lib/src/api/notes.openapi.dart index 3aaed16b..c9a12c2d 100644 --- a/packages/nextcloud/lib/src/api/notes.openapi.dart +++ b/packages/nextcloud/lib/src/api/notes.openapi.dart @@ -1,5 +1,6 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'dart:convert'; import 'dart:typed_data'; @@ -8,6 +9,7 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/json_object.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:universal_io/io.dart'; @@ -85,13 +87,24 @@ class NotesClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (category != null) { queryParameters['category'] = category; } @@ -138,13 +151,24 @@ class NotesClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (category != '') { queryParameters['category'] = category; } @@ -184,13 +208,24 @@ class NotesClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); if (exclude != '') { queryParameters['exclude'] = exclude; @@ -226,13 +261,24 @@ class NotesClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); if (content != null) { queryParameters['content'] = content; @@ -272,13 +318,24 @@ class NotesClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); final response = await doRequest( 'delete', @@ -299,13 +356,24 @@ class NotesClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end final response = await doRequest( 'get', Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), @@ -326,13 +394,24 @@ class NotesClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['Content-Type'] = 'application/json'; body = utf8.encode(json.encode(_jsonSerializers.serialize(settings, specifiedType: const FullType(NotesSettings)))) as Uint8List; diff --git a/packages/nextcloud/lib/src/api/notifications.openapi.dart b/packages/nextcloud/lib/src/api/notifications.openapi.dart index 1194d9b5..fc24ec02 100644 --- a/packages/nextcloud/lib/src/api/notifications.openapi.dart +++ b/packages/nextcloud/lib/src/api/notifications.openapi.dart @@ -1,5 +1,6 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'dart:typed_data'; import 'package:built_collection/built_collection.dart'; @@ -7,6 +8,7 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/json_object.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:universal_io/io.dart'; @@ -100,19 +102,24 @@ class NotificationsApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['shortMessage'] = shortMessage; path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); if (longMessage != '') { @@ -155,19 +162,24 @@ class NotificationsEndpointClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{apiVersion}', Uri.encodeQueryComponent(apiVersion.name)); headers['OCS-APIRequest'] = oCSAPIRequest; final response = await _rootClient.doRequest( @@ -204,19 +216,24 @@ class NotificationsEndpointClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{apiVersion}', Uri.encodeQueryComponent(apiVersion.name)); headers['OCS-APIRequest'] = oCSAPIRequest; final response = await _rootClient.doRequest( @@ -246,19 +263,24 @@ class NotificationsEndpointClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); path = path.replaceAll('{apiVersion}', Uri.encodeQueryComponent(apiVersion.name)); headers['OCS-APIRequest'] = oCSAPIRequest; @@ -290,19 +312,24 @@ class NotificationsEndpointClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); path = path.replaceAll('{apiVersion}', Uri.encodeQueryComponent(apiVersion.name)); headers['OCS-APIRequest'] = oCSAPIRequest; @@ -334,19 +361,24 @@ class NotificationsEndpointClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['ids[]'] = ids.map((final e) => e.toString()); path = path.replaceAll('{apiVersion}', Uri.encodeQueryComponent(apiVersion.name)); headers['OCS-APIRequest'] = oCSAPIRequest; @@ -385,19 +417,24 @@ class NotificationsPushClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['pushTokenHash'] = pushTokenHash; queryParameters['devicePublicKey'] = devicePublicKey; queryParameters['proxyServer'] = proxyServer; @@ -429,19 +466,24 @@ class NotificationsPushClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{apiVersion}', Uri.encodeQueryComponent(apiVersion.name)); headers['OCS-APIRequest'] = oCSAPIRequest; final response = await _rootClient.doRequest( @@ -479,19 +521,24 @@ class NotificationsSettingsClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['batchSetting'] = batchSetting.toString(); queryParameters['soundNotification'] = soundNotification; queryParameters['soundTalk'] = soundTalk; @@ -528,19 +575,24 @@ class NotificationsSettingsClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['batchSetting'] = batchSetting.toString(); queryParameters['soundNotification'] = soundNotification; queryParameters['soundTalk'] = soundTalk; diff --git a/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart b/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart index 04ac33f2..95fc8e16 100644 --- a/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart +++ b/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart @@ -1,5 +1,6 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'dart:typed_data'; import 'package:built_collection/built_collection.dart'; @@ -7,6 +8,7 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/json_object.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:universal_io/io.dart'; @@ -96,19 +98,24 @@ class ProvisioningApiAppConfigClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -138,19 +145,24 @@ class ProvisioningApiAppConfigClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -183,19 +195,24 @@ class ProvisioningApiAppConfigClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); path = path.replaceAll('{key}', Uri.encodeQueryComponent(key)); if (defaultValue != '') { @@ -230,19 +247,24 @@ class ProvisioningApiAppConfigClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['value'] = value; path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); path = path.replaceAll('{key}', Uri.encodeQueryComponent(key)); @@ -276,19 +298,24 @@ class ProvisioningApiAppConfigClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); path = path.replaceAll('{key}', Uri.encodeQueryComponent(key)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -326,19 +353,24 @@ class ProvisioningApiAppsClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (filter != null) { queryParameters['filter'] = filter; } @@ -371,19 +403,24 @@ class ProvisioningApiAppsClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -414,19 +451,24 @@ class ProvisioningApiAppsClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -457,19 +499,24 @@ class ProvisioningApiAppsClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -506,19 +553,24 @@ class ProvisioningApiGroupsClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (search != '') { queryParameters['search'] = search; } @@ -558,19 +610,24 @@ class ProvisioningApiGroupsClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['groupid'] = groupid; if (displayname != '') { queryParameters['displayname'] = displayname; @@ -604,19 +661,24 @@ class ProvisioningApiGroupsClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (search != '') { queryParameters['search'] = search; } @@ -653,19 +715,24 @@ class ProvisioningApiGroupsClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (!RegExp(r'^.+$').hasMatch(groupId)) { throw Exception( 'Invalid value "$groupId" for parameter "groupId" with pattern "${r'^.+$'}"', @@ -702,19 +769,24 @@ class ProvisioningApiGroupsClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (!RegExp(r'^.+$').hasMatch(groupId)) { throw Exception( 'Invalid value "$groupId" for parameter "groupId" with pattern "${r'^.+$'}"', @@ -759,19 +831,24 @@ class ProvisioningApiGroupsClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (!RegExp(r'^.+$').hasMatch(groupId)) { throw Exception( 'Invalid value "$groupId" for parameter "groupId" with pattern "${r'^.+$'}"', @@ -806,19 +883,24 @@ class ProvisioningApiGroupsClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (!RegExp(r'^.+$').hasMatch(groupId)) { throw Exception( 'Invalid value "$groupId" for parameter "groupId" with pattern "${r'^.+$'}"', @@ -856,19 +938,24 @@ class ProvisioningApiGroupsClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['key'] = key; queryParameters['value'] = value; if (!RegExp(r'^.+$').hasMatch(groupId)) { @@ -906,19 +993,24 @@ class ProvisioningApiGroupsClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (!RegExp(r'^.+$').hasMatch(groupId)) { throw Exception( 'Invalid value "$groupId" for parameter "groupId" with pattern "${r'^.+$'}"', @@ -960,19 +1052,24 @@ class ProvisioningApiPreferencesClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['configValue'] = configValue; path = path.replaceAll('{appId}', Uri.encodeQueryComponent(appId)); path = path.replaceAll('{configKey}', Uri.encodeQueryComponent(configKey)); @@ -1004,19 +1101,24 @@ class ProvisioningApiPreferencesClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{appId}', Uri.encodeQueryComponent(appId)); path = path.replaceAll('{configKey}', Uri.encodeQueryComponent(configKey)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -1047,19 +1149,24 @@ class ProvisioningApiPreferencesClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['configs'] = _jsonSerializers.serialize( configs, specifiedType: const FullType(ContentString, [ @@ -1095,19 +1202,24 @@ class ProvisioningApiPreferencesClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['configKeys[]'] = configKeys.map((final e) => e); path = path.replaceAll('{appId}', Uri.encodeQueryComponent(appId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -1145,19 +1257,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (search != '') { queryParameters['search'] = search; } @@ -1202,19 +1319,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['userid'] = userid; if (password != '') { queryParameters['password'] = password; @@ -1269,19 +1391,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (search != '') { queryParameters['search'] = search; } @@ -1319,19 +1446,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['location'] = location; queryParameters['search'] = _jsonSerializers.serialize( search, @@ -1369,19 +1501,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -1412,19 +1549,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['key'] = key; queryParameters['value'] = value; path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); @@ -1455,19 +1597,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -1495,19 +1642,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -1534,19 +1686,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -1574,19 +1731,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -1618,19 +1780,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['key'] = key; queryParameters['value'] = value; path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); @@ -1667,19 +1834,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -1708,19 +1880,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -1749,19 +1926,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -1790,19 +1972,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -1832,19 +2019,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); if (groupid != '') { queryParameters['groupid'] = groupid; @@ -1877,19 +2069,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['groupid'] = groupid; path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -1921,19 +2118,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -1965,19 +2167,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['groupid'] = groupid; path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -2010,19 +2217,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['groupid'] = groupid; path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -2052,19 +2264,24 @@ class ProvisioningApiUsersClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( diff --git a/packages/nextcloud/lib/src/api/settings.openapi.dart b/packages/nextcloud/lib/src/api/settings.openapi.dart index 96609560..59bb4c91 100644 --- a/packages/nextcloud/lib/src/api/settings.openapi.dart +++ b/packages/nextcloud/lib/src/api/settings.openapi.dart @@ -1,10 +1,12 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'dart:typed_data'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:universal_io/io.dart'; @@ -86,19 +88,24 @@ class SettingsLogSettingsClient { 'Accept': 'application/octet-stream', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end final response = await _rootClient.doRequest( 'get', Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), diff --git a/packages/nextcloud/lib/src/api/sharebymail.openapi.dart b/packages/nextcloud/lib/src/api/sharebymail.openapi.dart index 7a7bbbb8..3358a7e5 100644 --- a/packages/nextcloud/lib/src/api/sharebymail.openapi.dart +++ b/packages/nextcloud/lib/src/api/sharebymail.openapi.dart @@ -1,5 +1,6 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; diff --git a/packages/nextcloud/lib/src/api/theming.openapi.dart b/packages/nextcloud/lib/src/api/theming.openapi.dart index 1ac3c481..66d75dcf 100644 --- a/packages/nextcloud/lib/src/api/theming.openapi.dart +++ b/packages/nextcloud/lib/src/api/theming.openapi.dart @@ -1,5 +1,6 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'dart:typed_data'; import 'package:built_collection/built_collection.dart'; @@ -7,6 +8,7 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/json_object.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:universal_io/io.dart'; @@ -90,17 +92,22 @@ class ThemingIconClient { 'Accept': 'image/x-icon', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); final response = await _rootClient.doRequest( 'get', @@ -122,17 +129,22 @@ class ThemingIconClient { 'Accept': 'image/png', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); final response = await _rootClient.doRequest( 'get', @@ -157,17 +169,22 @@ class ThemingIconClient { 'Accept': 'image/svg+xml', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); if (!RegExp(r'^.+$').hasMatch(image)) { throw Exception('Invalid value "$image" for parameter "image" with pattern "${r'^.+$'}"'); // coverage:ignore-line @@ -205,17 +222,22 @@ class ThemingThemingClient { 'Accept': 'text/css', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{themeId}', Uri.encodeQueryComponent(themeId)); if (plain != 0) { queryParameters['plain'] = plain.toString(); @@ -246,17 +268,22 @@ class ThemingThemingClient { 'Accept': '*/*', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{key}', Uri.encodeQueryComponent(key)); if (useSvg != 1) { queryParameters['useSvg'] = useSvg.toString(); @@ -281,17 +308,22 @@ class ThemingThemingClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); final response = await _rootClient.doRequest( 'get', @@ -322,19 +354,24 @@ class ThemingUserThemeClient { 'Accept': '*/*', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -361,19 +398,24 @@ class ThemingUserThemeClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{type}', Uri.encodeQueryComponent(type)); if (value != '') { queryParameters['value'] = value; @@ -403,19 +445,24 @@ class ThemingUserThemeClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'delete', @@ -441,19 +488,24 @@ class ThemingUserThemeClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{themeId}', Uri.encodeQueryComponent(themeId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -482,19 +534,24 @@ class ThemingUserThemeClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{themeId}', Uri.encodeQueryComponent(themeId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( diff --git a/packages/nextcloud/lib/src/api/updatenotification.openapi.dart b/packages/nextcloud/lib/src/api/updatenotification.openapi.dart index 75934437..07e887e4 100644 --- a/packages/nextcloud/lib/src/api/updatenotification.openapi.dart +++ b/packages/nextcloud/lib/src/api/updatenotification.openapi.dart @@ -1,11 +1,13 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'dart:typed_data'; import 'package:built_collection/built_collection.dart'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:universal_io/io.dart'; @@ -91,19 +93,24 @@ class UpdatenotificationApiClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{newVersion}', Uri.encodeQueryComponent(newVersion)); path = path.replaceAll('{apiVersion}', Uri.encodeQueryComponent(apiVersion.name)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); diff --git a/packages/nextcloud/lib/src/api/uppush.openapi.dart b/packages/nextcloud/lib/src/api/uppush.openapi.dart index d33c7184..0fa4a625 100644 --- a/packages/nextcloud/lib/src/api/uppush.openapi.dart +++ b/packages/nextcloud/lib/src/api/uppush.openapi.dart @@ -1,11 +1,13 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'dart:typed_data'; import 'package:built_collection/built_collection.dart'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:universal_io/io.dart'; @@ -77,13 +79,24 @@ class UppushClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end final response = await doRequest( 'get', Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), @@ -109,13 +122,24 @@ class UppushClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['keepalive'] = keepalive.toString(); final response = await doRequest( 'put', @@ -140,13 +164,24 @@ class UppushClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['deviceName'] = deviceName; final response = await doRequest( 'put', @@ -173,13 +208,24 @@ class UppushClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{deviceId}', Uri.encodeQueryComponent(deviceId)); final response = await doRequest( 'get', @@ -204,13 +250,24 @@ class UppushClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{deviceId}', Uri.encodeQueryComponent(deviceId)); final response = await doRequest( 'delete', @@ -238,13 +295,24 @@ class UppushClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['deviceId'] = deviceId; queryParameters['appName'] = appName; final response = await doRequest( @@ -270,13 +338,24 @@ class UppushClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{token}', Uri.encodeQueryComponent(token)); final response = await doRequest( 'delete', @@ -301,13 +380,24 @@ class UppushClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{token}', Uri.encodeQueryComponent(token)); final response = await doRequest( 'get', @@ -332,13 +422,24 @@ class UppushClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{token}', Uri.encodeQueryComponent(token)); final response = await doRequest( 'post', @@ -363,13 +464,24 @@ class UppushClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end final response = await doRequest( 'get', Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), @@ -393,13 +505,24 @@ class UppushClient extends DynamiteClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); + +// coverage:ignore-start + final authentication = authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { + headers.addAll( + authentication.headers, + ); } else { throw Exception('Missing authentication for basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end final response = await doRequest( 'post', Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), diff --git a/packages/nextcloud/lib/src/api/user_status.openapi.dart b/packages/nextcloud/lib/src/api/user_status.openapi.dart index 904e89c5..a39ca5c2 100644 --- a/packages/nextcloud/lib/src/api/user_status.openapi.dart +++ b/packages/nextcloud/lib/src/api/user_status.openapi.dart @@ -1,5 +1,6 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'dart:typed_data'; import 'package:built_collection/built_collection.dart'; @@ -7,6 +8,7 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/json_object.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:universal_io/io.dart'; @@ -95,19 +97,24 @@ class UserStatusHeartbeatClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['status'] = status; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -139,19 +146,24 @@ class UserStatusPredefinedStatusClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -186,19 +198,24 @@ class UserStatusStatusesClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (limit != null) { queryParameters['limit'] = limit.toString(); } @@ -232,19 +249,24 @@ class UserStatusStatusesClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -276,19 +298,24 @@ class UserStatusUserStatusClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -316,19 +343,24 @@ class UserStatusUserStatusClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['statusType'] = statusType; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -358,19 +390,24 @@ class UserStatusUserStatusClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['messageId'] = messageId; if (clearAt != null) { queryParameters['clearAt'] = clearAt.toString(); @@ -404,19 +441,24 @@ class UserStatusUserStatusClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (statusIcon != null) { queryParameters['statusIcon'] = statusIcon; } @@ -452,19 +494,24 @@ class UserStatusUserStatusClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'delete', @@ -492,19 +539,24 @@ class UserStatusUserStatusClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end path = path.replaceAll('{messageId}', Uri.encodeQueryComponent(messageId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( diff --git a/packages/nextcloud/lib/src/api/weather_status.openapi.dart b/packages/nextcloud/lib/src/api/weather_status.openapi.dart index a0da9696..86b0b8ac 100644 --- a/packages/nextcloud/lib/src/api/weather_status.openapi.dart +++ b/packages/nextcloud/lib/src/api/weather_status.openapi.dart @@ -1,11 +1,13 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case import 'dart:typed_data'; import 'package:built_collection/built_collection.dart'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:universal_io/io.dart'; @@ -88,19 +90,24 @@ class WeatherStatusWeatherStatusClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['mode'] = mode.toString(); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -128,19 +135,24 @@ class WeatherStatusWeatherStatusClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'put', @@ -167,19 +179,24 @@ class WeatherStatusWeatherStatusClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -209,19 +226,24 @@ class WeatherStatusWeatherStatusClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end if (address != null) { queryParameters['address'] = address; } @@ -257,19 +279,24 @@ class WeatherStatusWeatherStatusClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -296,19 +323,24 @@ class WeatherStatusWeatherStatusClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( 'get', @@ -336,19 +368,24 @@ class WeatherStatusWeatherStatusClient { 'Accept': 'application/json', }; Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + +// coverage:ignore-start + final authentication = _rootClient.authentications.firstWhereOrNull( + (final auth) => switch (auth) { + DynamiteHttpBearerAuthentication() || DynamiteHttpBasicAuthentication() => true, + _ => false, + }, + ); + + if (authentication != null) { headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + authentication.headers, ); } else { throw Exception('Missing authentication for bearer_auth or basic_auth'); } - // coverage:ignore-end + +// coverage:ignore-end queryParameters['favorites[]'] = favorites.map((final e) => e); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( diff --git a/packages/nextcloud/pubspec.yaml b/packages/nextcloud/pubspec.yaml index 9c7dccf2..624ac68b 100644 --- a/packages/nextcloud/pubspec.yaml +++ b/packages/nextcloud/pubspec.yaml @@ -8,6 +8,7 @@ environment: dependencies: built_collection: ^5.1.1 built_value: ^8.6.3 + collection: ^1.17.1 crypto: ^3.0.3 crypton: ^2.2.0 dynamite_runtime: From 3fed82339aab889d36583508eb81a055a077afd4 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Sun, 24 Sep 2023 21:25:14 +0200 Subject: [PATCH 4/9] style(dynamite,dynamite_runtime,nextcloud): externalize pattern check Signed-off-by: Nikolas Rimikis --- .../dynamite/lib/src/builder/client.dart | 45 +++++++++--------- .../dynamite/lib/src/builder/imports.dart | 1 + .../lib/src/string_checker.dart | 26 ++++++++++ .../dynamite/dynamite_runtime/lib/utils.dart | 1 + .../nextcloud/lib/src/api/files.openapi.dart | 5 +- .../lib/src/api/files_reminders.openapi.dart | 19 ++------ .../lib/src/api/provisioning_api.openapi.dart | 47 +++++-------------- .../lib/src/api/theming.openapi.dart | 5 +- 8 files changed, 70 insertions(+), 79 deletions(-) create mode 100644 packages/dynamite/dynamite_runtime/lib/src/string_checker.dart diff --git a/packages/dynamite/dynamite/lib/src/builder/client.dart b/packages/dynamite/dynamite/lib/src/builder/client.dart index 16cac51c..51a4fefa 100644 --- a/packages/dynamite/dynamite/lib/src/builder/client.dart +++ b/packages/dynamite/dynamite/lib/src/builder/client.dart @@ -354,29 +354,7 @@ Iterable buildTags( nullable: dartParameterNullable, ).dartType; - if (result.name == 'String') { - if (parameter.schema?.pattern != null) { - code.write(''' -if (!RegExp(r'${parameter.schema!.pattern!}').hasMatch(${toDartName(parameter.name)})) { - throw Exception('Invalid value "\$${toDartName(parameter.name)}" for parameter "${toDartName(parameter.name)}" with pattern "\${r'${parameter.schema!.pattern!}'}"'); // coverage:ignore-line -} -'''); - } - if (parameter.schema?.minLength != null) { - code.write(''' -if (${toDartName(parameter.name)}.length < ${parameter.schema!.minLength!}) { - throw Exception('Parameter "${toDartName(parameter.name)}" has to be at least ${parameter.schema!.minLength!} characters long'); // coverage:ignore-line -} -'''); - } - if (parameter.schema?.maxLength != null) { - code.write(''' -if (${toDartName(parameter.name)}.length > ${parameter.schema!.maxLength!}) { - throw Exception('Parameter "${toDartName(parameter.name)}" has to be at most ${parameter.schema!.maxLength!} characters long'); // coverage:ignore-line -} -'''); - } - } + buildPatternCheck(result, parameter).forEach(code.writeln); final defaultValueCode = parameter.schema?.$default != null ? valueToEscapedValue(result, parameter.schema!.$default.toString()) @@ -610,6 +588,27 @@ final _response = await $client.doRequest( } } +Iterable buildPatternCheck( + final TypeResult result, + final openapi.Parameter parameter, +) sync* { + final value = toDartName(parameter.name); + final name = "'$value'"; + + final schema = parameter.schema; + if (result.name == 'String' && schema != null) { + if (schema.pattern != null) { + yield "checkPattern($value, RegExp(r'${schema.pattern!}'), $name); // coverage:ignore-line"; + } + if (schema.minLength != null) { + yield 'checkMinLength($value, ${schema.minLength}, $name); // coverage:ignore-line'; + } + if (schema.maxLength != null) { + yield 'checkMaxLength($value, ${schema.maxLength}, $name); // coverage:ignore-line'; + } + } +} + Iterable buildAuthCheck( final Map> responses, final MapEntry pathEntry, diff --git a/packages/dynamite/dynamite/lib/src/builder/imports.dart b/packages/dynamite/dynamite/lib/src/builder/imports.dart index 7e15b857..97c25371 100644 --- a/packages/dynamite/dynamite/lib/src/builder/imports.dart +++ b/packages/dynamite/dynamite/lib/src/builder/imports.dart @@ -17,6 +17,7 @@ List generateImports(final AssetId outputId) => [ Directive.import('package:collection/collection.dart'), Directive.import('package:dynamite_runtime/content_string.dart'), Directive.import('package:dynamite_runtime/http_client.dart'), + Directive.import('package:dynamite_runtime/utils.dart'), Directive.import('package:universal_io/io.dart'), const Code(''), Directive.export('package:dynamite_runtime/http_client.dart'), diff --git a/packages/dynamite/dynamite_runtime/lib/src/string_checker.dart b/packages/dynamite/dynamite_runtime/lib/src/string_checker.dart new file mode 100644 index 00000000..accfb49f --- /dev/null +++ b/packages/dynamite/dynamite_runtime/lib/src/string_checker.dart @@ -0,0 +1,26 @@ +/// Checks the [input] against [pattern]. +/// +/// Throws an `Exception` containing the [parameterName] if the `pattern` does not match. +void checkPattern(final String input, final RegExp pattern, final String parameterName) { + if (!pattern.hasMatch(input)) { + throw Exception('Invalid value "$input" for parameter "$parameterName" with pattern "${pattern.pattern}"'); + } +} + +/// Checks the [input] length against [minLength]. +/// +/// Throws an `Exception` containing the [parameterName] if the `input` is to short. +void checkMinLength(final String input, final int minLength, final String parameterName) { + if (input.length < minLength) { + throw Exception('Parameter "$input" has to be at least $minLength characters long'); + } +} + +/// Checks the [input] length against [maxLength]. +/// +/// Throws an `Exception` containing the [parameterName] if the `input` is to long. +void checkMaxLength(final String input, final int maxLength, final String parameterName) { + if (input.length > maxLength) { + throw Exception('Parameter "$input" has to be at most $maxLength characters long'); + } +} diff --git a/packages/dynamite/dynamite_runtime/lib/utils.dart b/packages/dynamite/dynamite_runtime/lib/utils.dart index 30f229d5..c8d7b711 100644 --- a/packages/dynamite/dynamite_runtime/lib/utils.dart +++ b/packages/dynamite/dynamite_runtime/lib/utils.dart @@ -1 +1,2 @@ +export 'src/string_checker.dart'; export 'src/uri.dart'; diff --git a/packages/nextcloud/lib/src/api/files.openapi.dart b/packages/nextcloud/lib/src/api/files.openapi.dart index d97ff316..af8b02b4 100644 --- a/packages/nextcloud/lib/src/api/files.openapi.dart +++ b/packages/nextcloud/lib/src/api/files.openapi.dart @@ -11,6 +11,7 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; +import 'package:dynamite_runtime/utils.dart'; import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -120,9 +121,7 @@ class FilesApiClient { // coverage:ignore-end path = path.replaceAll('{x}', Uri.encodeQueryComponent(x.toString())); path = path.replaceAll('{y}', Uri.encodeQueryComponent(y.toString())); - if (!RegExp(r'^.+$').hasMatch(file)) { - throw Exception('Invalid value "$file" for parameter "file" with pattern "${r'^.+$'}"'); // coverage:ignore-line - } + checkPattern(file, RegExp(r'^.+$'), 'file'); // coverage:ignore-line path = path.replaceAll('{file}', Uri.encodeQueryComponent(file)); final response = await _rootClient.doRequest( 'get', diff --git a/packages/nextcloud/lib/src/api/files_reminders.openapi.dart b/packages/nextcloud/lib/src/api/files_reminders.openapi.dart index e0d6bb7e..ac6169fc 100644 --- a/packages/nextcloud/lib/src/api/files_reminders.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_reminders.openapi.dart @@ -10,6 +10,7 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; +import 'package:dynamite_runtime/utils.dart'; import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -109,11 +110,7 @@ class FilesRemindersApiClient { } // coverage:ignore-end - if (!RegExp(r'^1$').hasMatch(version)) { - throw Exception( - 'Invalid value "$version" for parameter "version" with pattern "${r'^1$'}"', - ); // coverage:ignore-line - } + checkPattern(version, RegExp(r'^1$'), 'version'); // coverage:ignore-line path = path.replaceAll('{version}', Uri.encodeQueryComponent(version)); path = path.replaceAll('{fileId}', Uri.encodeQueryComponent(fileId.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -164,11 +161,7 @@ class FilesRemindersApiClient { // coverage:ignore-end queryParameters['dueDate'] = dueDate; - if (!RegExp(r'^1$').hasMatch(version)) { - throw Exception( - 'Invalid value "$version" for parameter "version" with pattern "${r'^1$'}"', - ); // coverage:ignore-line - } + checkPattern(version, RegExp(r'^1$'), 'version'); // coverage:ignore-line path = path.replaceAll('{version}', Uri.encodeQueryComponent(version)); path = path.replaceAll('{fileId}', Uri.encodeQueryComponent(fileId.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); @@ -221,11 +214,7 @@ class FilesRemindersApiClient { } // coverage:ignore-end - if (!RegExp(r'^1$').hasMatch(version)) { - throw Exception( - 'Invalid value "$version" for parameter "version" with pattern "${r'^1$'}"', - ); // coverage:ignore-line - } + checkPattern(version, RegExp(r'^1$'), 'version'); // coverage:ignore-line path = path.replaceAll('{version}', Uri.encodeQueryComponent(version)); path = path.replaceAll('{fileId}', Uri.encodeQueryComponent(fileId.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); diff --git a/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart b/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart index 95fc8e16..ca925063 100644 --- a/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart +++ b/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart @@ -11,6 +11,7 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; +import 'package:dynamite_runtime/utils.dart'; import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -733,11 +734,7 @@ class ProvisioningApiGroupsClient { } // coverage:ignore-end - if (!RegExp(r'^.+$').hasMatch(groupId)) { - throw Exception( - 'Invalid value "$groupId" for parameter "groupId" with pattern "${r'^.+$'}"', - ); // coverage:ignore-line - } + checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); // coverage:ignore-line path = path.replaceAll('{groupId}', Uri.encodeQueryComponent(groupId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -787,11 +784,7 @@ class ProvisioningApiGroupsClient { } // coverage:ignore-end - if (!RegExp(r'^.+$').hasMatch(groupId)) { - throw Exception( - 'Invalid value "$groupId" for parameter "groupId" with pattern "${r'^.+$'}"', - ); // coverage:ignore-line - } + checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); // coverage:ignore-line path = path.replaceAll('{groupId}', Uri.encodeQueryComponent(groupId)); if (search != '') { queryParameters['search'] = search; @@ -849,11 +842,7 @@ class ProvisioningApiGroupsClient { } // coverage:ignore-end - if (!RegExp(r'^.+$').hasMatch(groupId)) { - throw Exception( - 'Invalid value "$groupId" for parameter "groupId" with pattern "${r'^.+$'}"', - ); // coverage:ignore-line - } + checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); // coverage:ignore-line path = path.replaceAll('{groupId}', Uri.encodeQueryComponent(groupId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -901,11 +890,7 @@ class ProvisioningApiGroupsClient { } // coverage:ignore-end - if (!RegExp(r'^.+$').hasMatch(groupId)) { - throw Exception( - 'Invalid value "$groupId" for parameter "groupId" with pattern "${r'^.+$'}"', - ); // coverage:ignore-line - } + checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); // coverage:ignore-line path = path.replaceAll('{groupId}', Uri.encodeQueryComponent(groupId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -958,11 +943,7 @@ class ProvisioningApiGroupsClient { // coverage:ignore-end queryParameters['key'] = key; queryParameters['value'] = value; - if (!RegExp(r'^.+$').hasMatch(groupId)) { - throw Exception( - 'Invalid value "$groupId" for parameter "groupId" with pattern "${r'^.+$'}"', - ); // coverage:ignore-line - } + checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); // coverage:ignore-line path = path.replaceAll('{groupId}', Uri.encodeQueryComponent(groupId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -1011,11 +992,7 @@ class ProvisioningApiGroupsClient { } // coverage:ignore-end - if (!RegExp(r'^.+$').hasMatch(groupId)) { - throw Exception( - 'Invalid value "$groupId" for parameter "groupId" with pattern "${r'^.+$'}"', - ); // coverage:ignore-line - } + checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); // coverage:ignore-line path = path.replaceAll('{groupId}', Uri.encodeQueryComponent(groupId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( @@ -1801,11 +1778,11 @@ class ProvisioningApiUsersClient { queryParameters['key'] = key; queryParameters['value'] = value; path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); - if (!RegExp(r'^(?!enable$|disable$)[a-zA-Z0-9_]*$').hasMatch(collectionName)) { - throw Exception( - 'Invalid value "$collectionName" for parameter "collectionName" with pattern "${r'^(?!enable$|disable$)[a-zA-Z0-9_]*$'}"', - ); // coverage:ignore-line - } + checkPattern( + collectionName, + RegExp(r'^(?!enable$|disable$)[a-zA-Z0-9_]*$'), + 'collectionName', + ); // coverage:ignore-line path = path.replaceAll('{collectionName}', Uri.encodeQueryComponent(collectionName)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); final response = await _rootClient.doRequest( diff --git a/packages/nextcloud/lib/src/api/theming.openapi.dart b/packages/nextcloud/lib/src/api/theming.openapi.dart index 66d75dcf..4ed2e605 100644 --- a/packages/nextcloud/lib/src/api/theming.openapi.dart +++ b/packages/nextcloud/lib/src/api/theming.openapi.dart @@ -11,6 +11,7 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; +import 'package:dynamite_runtime/utils.dart'; import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -186,9 +187,7 @@ class ThemingIconClient { // coverage:ignore-end path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); - if (!RegExp(r'^.+$').hasMatch(image)) { - throw Exception('Invalid value "$image" for parameter "image" with pattern "${r'^.+$'}"'); // coverage:ignore-line - } + checkPattern(image, RegExp(r'^.+$'), 'image'); // coverage:ignore-line path = path.replaceAll('{image}', Uri.encodeQueryComponent(image)); final response = await _rootClient.doRequest( 'get', From a4c0b26325447e43dc0b3a05c15ac8987a893212 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Sun, 24 Sep 2023 21:42:17 +0200 Subject: [PATCH 5/9] style(dynamite,dynamite_runtime,nextcloud): unify responses and exceptions Signed-off-by: Nikolas Rimikis --- .../dynamite/lib/src/builder/client.dart | 105 +------------ .../dynamite_runtime/lib/src/http_client.dart | 78 +++++++++- .../lib/src/api/comments.openapi.dart | 37 ----- .../nextcloud/lib/src/api/core.openapi.dart | 139 +++++++----------- .../lib/src/api/dashboard.openapi.dart | 43 +----- .../nextcloud/lib/src/api/dav.openapi.dart | 39 +---- .../nextcloud/lib/src/api/files.openapi.dart | 63 ++------ .../lib/src/api/files_external.openapi.dart | 39 +---- .../lib/src/api/files_reminders.openapi.dart | 43 +----- .../lib/src/api/files_sharing.openapi.dart | 83 +++-------- .../lib/src/api/files_trashbin.openapi.dart | 39 +---- .../lib/src/api/files_versions.openapi.dart | 39 +---- .../nextcloud/lib/src/api/news.openapi.dart | 73 +++------ .../nextcloud/lib/src/api/notes.openapi.dart | 51 +------ .../lib/src/api/notifications.openapi.dart | 61 ++------ .../lib/src/api/provisioning_api.openapi.dart | 123 ++++++---------- .../lib/src/api/settings.openapi.dart | 43 +----- .../lib/src/api/sharebymail.openapi.dart | 37 ----- .../lib/src/api/theming.openapi.dart | 59 ++------ .../src/api/updatenotification.openapi.dart | 39 +---- .../nextcloud/lib/src/api/uppush.openapi.dart | 59 ++------ .../lib/src/api/user_status.openapi.dart | 57 ++----- .../lib/src/api/weather_status.openapi.dart | 51 +------ packages/nextcloud/test/helper.dart | 2 +- 24 files changed, 295 insertions(+), 1107 deletions(-) diff --git a/packages/dynamite/dynamite/lib/src/builder/client.dart b/packages/dynamite/dynamite/lib/src/builder/client.dart index 51a4fefa..ba62edac 100644 --- a/packages/dynamite/dynamite/lib/src/builder/client.dart +++ b/packages/dynamite/dynamite/lib/src/builder/client.dart @@ -11,109 +11,10 @@ import 'package:dynamite/src/models/openapi.dart' as openapi; import 'package:dynamite/src/models/type_result.dart'; import 'package:intersperse/intersperse.dart'; -List generateDynamiteOverrides(final State state) => [ - Class( - (final b) => b - ..name = '${state.classPrefix}Response' - ..types.addAll([ - refer('T'), - refer('U'), - ]) - ..extend = refer('DynamiteResponse') - ..constructors.add( - Constructor( - (final b) => b - ..requiredParameters.addAll( - ['data', 'headers'].map( - (final name) => Parameter( - (final b) => b - ..name = name - ..toSuper = true, - ), - ), - ), - ), - ) - ..methods.add( - Method( - (final b) => b - ..name = 'toString' - ..returns = refer('String') - ..annotations.add(refer('override')) - ..lambda = true - ..body = Code( - "'${state.classPrefix}Response(data: \$data, headers: \$headers)'", - ), - ), - ), - ), - Class( - (final b) => b - ..name = '${state.classPrefix}ApiException' - ..extend = refer('DynamiteApiException') - ..constructors.add( - Constructor( - (final b) => b - ..requiredParameters.addAll( - ['statusCode', 'headers', 'body'].map( - (final name) => Parameter( - (final b) => b - ..name = name - ..toSuper = true, - ), - ), - ), - ), - ) - ..methods.addAll([ - Method( - (final b) => b - ..name = 'fromResponse' - ..returns = refer('Future<${state.classPrefix}ApiException>') - ..static = true - ..modifier = MethodModifier.async - ..requiredParameters.add( - Parameter( - (final b) => b - ..name = 'response' - ..type = refer('HttpClientResponse'), - ), - ) - ..body = Code(''' -String body; -try { - body = await response.body; -} on FormatException { - body = 'binary'; -} - -return ${state.classPrefix}ApiException( - response.statusCode, - response.responseHeaders, - body, -); -'''), - ), - Method( - (final b) => b - ..name = 'toString' - ..returns = refer('String') - ..annotations.add(refer('override')) - ..lambda = true - ..body = Code( - "'${state.classPrefix}ApiException(statusCode: \$statusCode, headers: \$headers, body: \$body)'", - ), - ), - ]), - ), - ]; - Iterable generateClients( final openapi.OpenAPI spec, final State state, ) sync* { - yield* generateDynamiteOverrides(state); - final tags = generateTags(spec); yield buildRootClient(spec, state, tags); @@ -560,9 +461,9 @@ final _response = await $client.doRequest( } if (headersType != null && dataType != null) { - b.returns = refer('Future<${state.classPrefix}Response<$dataType, $headersType>>'); + b.returns = refer('Future>'); code.write( - 'return ${state.classPrefix}Response<$dataType, $headersType>(${dataNeedsAwait ?? false ? 'await ' : ''}$dataValue, $headersValue,);', + 'return DynamiteResponse<$dataType, $headersType>(${dataNeedsAwait ?? false ? 'await ' : ''}$dataValue, $headersValue,);', ); } else if (headersType != null) { b.returns = refer('Future<$headersType>'); @@ -578,7 +479,7 @@ final _response = await $client.doRequest( code.write('}'); } code.write( - 'throw await ${state.classPrefix}ApiException.fromResponse(_response); // coverage:ignore-line\n', + 'throw await DynamiteApiException.fromResponse(_response); // coverage:ignore-line\n', ); b.body = Code(code.toString()); diff --git a/packages/dynamite/dynamite_runtime/lib/src/http_client.dart b/packages/dynamite/dynamite_runtime/lib/src/http_client.dart index eb16c8b2..d1a4f4b2 100644 --- a/packages/dynamite/dynamite_runtime/lib/src/http_client.dart +++ b/packages/dynamite/dynamite_runtime/lib/src/http_client.dart @@ -32,31 +32,74 @@ extension DynamiteHttpClientResponseBody on HttpClientResponse { } } -class DynamiteResponse { - DynamiteResponse( - this.data, +/// Response returned by operations of a [DynamiteClient]. +/// +/// See: +/// * [DynamiteApiException] as the exception that can be thrown in operations +/// * [DynamiteAuthentication] for providing authentication methods. +/// * [DynamiteClient] for the client providing operations. +class DynamiteResponse { + /// Creates a new dynamite response. + const DynamiteResponse( + this.statusCode, + this.body, this.headers, ); - final T data; + /// The status code of the response. + final int statusCode; + + /// The decoded body of the response. + final B body; - final U headers; + /// The decoded headers of the response. + final H headers; @override - String toString() => 'DynamiteResponse(data: $data, headers: $headers)'; + String toString() => 'DynamiteResponse(data: $body, headers: $headers, statusCode: $statusCode)'; } +/// The exception thrown by operations of a [DynamiteClient]. +/// +/// +/// See: +/// * [DynamiteResponse] as the response returned by an operation. +/// * [DynamiteAuthentication] for providing authentication methods. +/// * [DynamiteClient] for the client providing operations. +@immutable class DynamiteApiException implements Exception { - DynamiteApiException( + /// Creates a new dynamite exception with the given information. + const DynamiteApiException( this.statusCode, this.headers, this.body, ); + /// Creates a new Exception from the given [response]. + /// + /// Tries to decode the `response` into a string. + static Future fromResponse(final HttpClientResponse response) async { + String body; + try { + body = await response.body; + } on FormatException { + body = 'binary'; + } + + return DynamiteApiException( + response.statusCode, + response.responseHeaders, + body, + ); + } + + /// The returned status code when the exception was thrown. final int statusCode; + /// The returned headers when the exception was thrown. final Map headers; + /// The returned body code when the exception was thrown. final String body; @override @@ -129,7 +172,17 @@ class DynamiteHttpBearerAuthentication extends DynamiteAuthentication { }; } +/// A client for making network requests. +/// +/// See: +/// * [DynamiteResponse] as the response returned by an operation. +/// * [DynamiteApiException] as the exception that can be thrown in operations +/// * [DynamiteAuthentication] for providing authentication methods. class DynamiteClient { + /// Creates a new dynamite network client. + /// + /// If [httpClient] is not provided a default one will be created. + /// The [baseURL] will be normalized, removing any trailing `/`. DynamiteClient( final Uri baseURL, { this.baseHeaders, @@ -140,16 +193,27 @@ class DynamiteClient { }) : httpClient = (httpClient ?? HttpClient())..userAgent = userAgent, baseURL = baseURL.normalizeEmptyPath(); + /// The base server url used to build the request uri. + /// + /// See `https://swagger.io/docs/specification/api-host-and-base-path` for + /// further information. final Uri baseURL; + /// The base headers added to each request. final Map? baseHeaders; + /// The base http client. final HttpClient httpClient; + /// The optional cookie jar to persist the response cookies. final CookieJar? cookieJar; + /// The available authentications for this client. + /// + /// The first one matching the required authentication type will be used. final List authentications; + /// Makes a request against a given [path]. Future doRequest( final String method, final Uri path, diff --git a/packages/nextcloud/lib/src/api/comments.openapi.dart b/packages/nextcloud/lib/src/api/comments.openapi.dart index 9edddb21..a37ddc5a 100644 --- a/packages/nextcloud/lib/src/api/comments.openapi.dart +++ b/packages/nextcloud/lib/src/api/comments.openapi.dart @@ -7,48 +7,11 @@ import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'comments.openapi.g.dart'; -class CommentsResponse extends DynamiteResponse { - CommentsResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'CommentsResponse(data: $data, headers: $headers)'; -} - -class CommentsApiException extends DynamiteApiException { - CommentsApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return CommentsApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'CommentsApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class CommentsClient extends DynamiteClient { CommentsClient( super.baseURL, { diff --git a/packages/nextcloud/lib/src/api/core.openapi.dart b/packages/nextcloud/lib/src/api/core.openapi.dart index 0e4c38e1..4d2c581b 100644 --- a/packages/nextcloud/lib/src/api/core.openapi.dart +++ b/packages/nextcloud/lib/src/api/core.openapi.dart @@ -12,48 +12,11 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'core.openapi.g.dart'; -class CoreResponse extends DynamiteResponse { - CoreResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'CoreResponse(data: $data, headers: $headers)'; -} - -class CoreApiException extends DynamiteApiException { - CoreApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return CoreApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'CoreApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class CoreClient extends DynamiteClient { CoreClient( super.baseURL, { @@ -129,7 +92,7 @@ class CoreClient extends DynamiteClient { return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(CoreStatus))! as CoreStatus; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -177,7 +140,7 @@ class CoreAppPasswordClient { specifiedType: const FullType(CoreAppPasswordGetAppPasswordResponseApplicationJson), )! as CoreAppPasswordGetAppPasswordResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Rotate app password @@ -221,7 +184,7 @@ class CoreAppPasswordClient { specifiedType: const FullType(CoreAppPasswordRotateAppPasswordResponseApplicationJson), )! as CoreAppPasswordRotateAppPasswordResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Delete app password @@ -265,7 +228,7 @@ class CoreAppPasswordClient { specifiedType: const FullType(CoreAppPasswordDeleteAppPasswordResponseApplicationJson), )! as CoreAppPasswordDeleteAppPasswordResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -337,7 +300,7 @@ class CoreAutoCompleteClient { specifiedType: const FullType(CoreAutoCompleteGetResponseApplicationJson), )! as CoreAutoCompleteGetResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -348,7 +311,7 @@ class CoreAvatarClient { final CoreClient _rootClient; /// Get the dark avatar - Future> getAvatarDark({ + Future> getAvatarDark({ required final String userId, required final int size, }) async { @@ -383,7 +346,7 @@ class CoreAvatarClient { body, ); if (response.statusCode == 200) { - return CoreResponse( + return DynamiteResponse( await response.bodyBytes, _jsonSerializers.deserialize( response.responseHeaders, @@ -391,11 +354,11 @@ class CoreAvatarClient { )! as CoreAvatarAvatarGetAvatarDarkHeaders, ); } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get the avatar - Future> getAvatar({ + Future> getAvatar({ required final String userId, required final int size, }) async { @@ -430,7 +393,7 @@ class CoreAvatarClient { body, ); if (response.statusCode == 200) { - return CoreResponse( + return DynamiteResponse( await response.bodyBytes, _jsonSerializers.deserialize( response.responseHeaders, @@ -438,7 +401,7 @@ class CoreAvatarClient { )! as CoreAvatarAvatarGetAvatarHeaders, ); } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -484,7 +447,7 @@ class CoreClientFlowLoginV2Client { specifiedType: const FullType(CoreLoginFlowV2Credentials), )! as CoreLoginFlowV2Credentials; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Init a login flow @@ -521,7 +484,7 @@ class CoreClientFlowLoginV2Client { return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(CoreLoginFlowV2))! as CoreLoginFlowV2; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -573,7 +536,7 @@ class CoreCollaborationResourcesClient { specifiedType: const FullType(CoreCollaborationResourcesSearchCollectionsResponseApplicationJson), )! as CoreCollaborationResourcesSearchCollectionsResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get a collection @@ -619,7 +582,7 @@ class CoreCollaborationResourcesClient { specifiedType: const FullType(CoreCollaborationResourcesListCollectionResponseApplicationJson), )! as CoreCollaborationResourcesListCollectionResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Rename a collection @@ -667,7 +630,7 @@ class CoreCollaborationResourcesClient { specifiedType: const FullType(CoreCollaborationResourcesRenameCollectionResponseApplicationJson), )! as CoreCollaborationResourcesRenameCollectionResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Add a resource to a collection @@ -717,7 +680,7 @@ class CoreCollaborationResourcesClient { specifiedType: const FullType(CoreCollaborationResourcesAddResourceResponseApplicationJson), )! as CoreCollaborationResourcesAddResourceResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Remove a resource from a collection @@ -767,7 +730,7 @@ class CoreCollaborationResourcesClient { specifiedType: const FullType(CoreCollaborationResourcesRemoveResourceResponseApplicationJson), )! as CoreCollaborationResourcesRemoveResourceResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get collections by resource @@ -815,7 +778,7 @@ class CoreCollaborationResourcesClient { specifiedType: const FullType(CoreCollaborationResourcesGetCollectionsByResourceResponseApplicationJson), )! as CoreCollaborationResourcesGetCollectionsByResourceResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Create a collection for a resource @@ -865,7 +828,7 @@ class CoreCollaborationResourcesClient { specifiedType: const FullType(CoreCollaborationResourcesCreateCollectionOnResourceResponseApplicationJson), )! as CoreCollaborationResourcesCreateCollectionOnResourceResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -913,7 +876,7 @@ class CoreGuestAvatarClient { if (response.statusCode == 200 || response.statusCode == 201) { return response.bodyBytes; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Returns a guest avatar image response @@ -960,7 +923,7 @@ class CoreGuestAvatarClient { if (response.statusCode == 200 || response.statusCode == 201) { return response.bodyBytes; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -1012,7 +975,7 @@ class CoreHoverCardClient { specifiedType: const FullType(CoreHoverCardGetUserResponseApplicationJson), )! as CoreHoverCardGetUserResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -1066,7 +1029,7 @@ class CoreNavigationClient { specifiedType: const FullType(CoreNavigationGetAppsNavigationResponseApplicationJson), )! as CoreNavigationGetAppsNavigationResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get the settings navigation @@ -1114,7 +1077,7 @@ class CoreNavigationClient { specifiedType: const FullType(CoreNavigationGetSettingsNavigationResponseApplicationJson), )! as CoreNavigationGetSettingsNavigationResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -1125,7 +1088,7 @@ class CoreOcmClient { final CoreClient _rootClient; /// generate a OCMProvider with local data and send it as DataResponse. This replaces the old PHP file ocm-provider/index.php - Future> discovery() async { + Future> discovery() async { const path = '/index.php/ocm-provider'; final queryParameters = {}; final headers = { @@ -1155,7 +1118,7 @@ class CoreOcmClient { body, ); if (response.statusCode == 200) { - return CoreResponse( + return DynamiteResponse( _jsonSerializers.deserialize( await response.jsonBody, specifiedType: const FullType(CoreOcmDiscoveryResponseApplicationJson), @@ -1166,7 +1129,7 @@ class CoreOcmClient { )! as CoreOcmOcmDiscoveryHeaders, ); } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -1212,7 +1175,7 @@ class CoreOcsClient { specifiedType: const FullType(CoreOcsGetCapabilitiesResponseApplicationJson), )! as CoreOcsGetCapabilitiesResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -1285,7 +1248,7 @@ class CorePreviewClient { if (response.statusCode == 200) { return response.bodyBytes; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get a preview by file path @@ -1352,7 +1315,7 @@ class CorePreviewClient { if (response.statusCode == 200) { return response.bodyBytes; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -1408,7 +1371,7 @@ class CoreProfileApiClient { specifiedType: const FullType(CoreProfileApiSetVisibilityResponseApplicationJson), )! as CoreProfileApiSetVisibilityResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -1451,7 +1414,7 @@ class CoreReferenceClient { if (response.statusCode == 200) { return response.bodyBytes; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -1503,7 +1466,7 @@ class CoreReferenceApiClient { specifiedType: const FullType(CoreReferenceApiResolveOneResponseApplicationJson), )! as CoreReferenceApiResolveOneResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Resolve multiple references @@ -1553,7 +1516,7 @@ class CoreReferenceApiClient { specifiedType: const FullType(CoreReferenceApiResolveResponseApplicationJson), )! as CoreReferenceApiResolveResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Extract references from a text @@ -1607,7 +1570,7 @@ class CoreReferenceApiClient { specifiedType: const FullType(CoreReferenceApiExtractResponseApplicationJson), )! as CoreReferenceApiExtractResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get the providers @@ -1651,7 +1614,7 @@ class CoreReferenceApiClient { specifiedType: const FullType(CoreReferenceApiGetProvidersInfoResponseApplicationJson), )! as CoreReferenceApiGetProvidersInfoResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Touch a provider @@ -1701,7 +1664,7 @@ class CoreReferenceApiClient { specifiedType: const FullType(CoreReferenceApiTouchProviderResponseApplicationJson), )! as CoreReferenceApiTouchProviderResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -1747,7 +1710,7 @@ class CoreTextProcessingApiClient { specifiedType: const FullType(CoreTextProcessingApiTaskTypesResponseApplicationJson), )! as CoreTextProcessingApiTaskTypesResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// This endpoint allows scheduling a language model task @@ -1799,7 +1762,7 @@ class CoreTextProcessingApiClient { specifiedType: const FullType(CoreTextProcessingApiScheduleResponseApplicationJson), )! as CoreTextProcessingApiScheduleResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// This endpoint allows checking the status and results of a task. Tasks are removed 1 week after receiving their last update. @@ -1843,7 +1806,7 @@ class CoreTextProcessingApiClient { specifiedType: const FullType(CoreTextProcessingApiGetTaskResponseApplicationJson), )! as CoreTextProcessingApiGetTaskResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// This endpoint allows to delete a scheduled task for a user @@ -1889,7 +1852,7 @@ class CoreTextProcessingApiClient { specifiedType: const FullType(CoreTextProcessingApiDeleteTaskResponseApplicationJson), )! as CoreTextProcessingApiDeleteTaskResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// This endpoint returns a list of tasks of a user that are related with a specific appId and optionally with an identifier @@ -1939,7 +1902,7 @@ class CoreTextProcessingApiClient { specifiedType: const FullType(CoreTextProcessingApiListTasksByAppResponseApplicationJson), )! as CoreTextProcessingApiListTasksByAppResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -1985,7 +1948,7 @@ class CoreTranslationApiClient { specifiedType: const FullType(CoreTranslationApiLanguagesResponseApplicationJson), )! as CoreTranslationApiLanguagesResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Translate a text @@ -2035,7 +1998,7 @@ class CoreTranslationApiClient { specifiedType: const FullType(CoreTranslationApiTranslateResponseApplicationJson), )! as CoreTranslationApiTranslateResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -2089,7 +2052,7 @@ class CoreUnifiedSearchClient { specifiedType: const FullType(CoreUnifiedSearchGetProvidersResponseApplicationJson), )! as CoreUnifiedSearchGetProvidersResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Search @@ -2158,7 +2121,7 @@ class CoreUnifiedSearchClient { specifiedType: const FullType(CoreUnifiedSearchSearchResponseApplicationJson), )! as CoreUnifiedSearchSearchResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -2206,7 +2169,7 @@ class CoreWhatsNewClient { specifiedType: const FullType(CoreWhatsNewGetResponseApplicationJson), )! as CoreWhatsNewGetResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Dismiss the changes @@ -2252,7 +2215,7 @@ class CoreWhatsNewClient { specifiedType: const FullType(CoreWhatsNewDismissResponseApplicationJson), )! as CoreWhatsNewDismissResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -2298,7 +2261,7 @@ class CoreWipeClient { specifiedType: const FullType(CoreWipeCheckWipeResponseApplicationJson), )! as CoreWipeCheckWipeResponseApplicationJson; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Finish the wipe @@ -2338,7 +2301,7 @@ class CoreWipeClient { specifiedType: const FullType(JsonObject), )! as JsonObject; } - throw await CoreApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } diff --git a/packages/nextcloud/lib/src/api/dashboard.openapi.dart b/packages/nextcloud/lib/src/api/dashboard.openapi.dart index 21dbfcdf..3709a050 100644 --- a/packages/nextcloud/lib/src/api/dashboard.openapi.dart +++ b/packages/nextcloud/lib/src/api/dashboard.openapi.dart @@ -10,48 +10,11 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'dashboard.openapi.g.dart'; -class DashboardResponse extends DynamiteResponse { - DashboardResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'DashboardResponse(data: $data, headers: $headers)'; -} - -class DashboardApiException extends DynamiteApiException { - DashboardApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return DashboardApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'DashboardApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class DashboardClient extends DynamiteClient { DashboardClient( super.baseURL, { @@ -118,7 +81,7 @@ class DashboardDashboardApiClient { specifiedType: const FullType(DashboardDashboardApiGetWidgetsResponseApplicationJson), )! as DashboardDashboardApiGetWidgetsResponseApplicationJson; } - throw await DashboardApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get the items for the widgets @@ -179,7 +142,7 @@ class DashboardDashboardApiClient { specifiedType: const FullType(DashboardDashboardApiGetWidgetItemsResponseApplicationJson), )! as DashboardDashboardApiGetWidgetItemsResponseApplicationJson; } - throw await DashboardApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get the items for the widgets @@ -240,7 +203,7 @@ class DashboardDashboardApiClient { specifiedType: const FullType(DashboardDashboardApiGetWidgetItemsV2ResponseApplicationJson), )! as DashboardDashboardApiGetWidgetItemsV2ResponseApplicationJson; } - throw await DashboardApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } diff --git a/packages/nextcloud/lib/src/api/dav.openapi.dart b/packages/nextcloud/lib/src/api/dav.openapi.dart index 7e37ffd4..f9838619 100644 --- a/packages/nextcloud/lib/src/api/dav.openapi.dart +++ b/packages/nextcloud/lib/src/api/dav.openapi.dart @@ -9,48 +9,11 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'dav.openapi.g.dart'; -class DavResponse extends DynamiteResponse { - DavResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'DavResponse(data: $data, headers: $headers)'; -} - -class DavApiException extends DynamiteApiException { - DavApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return DavApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'DavApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class DavClient extends DynamiteClient { DavClient( super.baseURL, { @@ -125,7 +88,7 @@ class DavDirectClient { specifiedType: const FullType(DavDirectGetUrlResponseApplicationJson), )! as DavDirectGetUrlResponseApplicationJson; } - throw await DavApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } diff --git a/packages/nextcloud/lib/src/api/files.openapi.dart b/packages/nextcloud/lib/src/api/files.openapi.dart index af8b02b4..6d506b3e 100644 --- a/packages/nextcloud/lib/src/api/files.openapi.dart +++ b/packages/nextcloud/lib/src/api/files.openapi.dart @@ -12,48 +12,11 @@ import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:dynamite_runtime/utils.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'files.openapi.g.dart'; -class FilesResponse extends DynamiteResponse { - FilesResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'FilesResponse(data: $data, headers: $headers)'; -} - -class FilesApiException extends DynamiteApiException { - FilesApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return FilesApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'FilesApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class FilesClient extends DynamiteClient { FilesClient( super.baseURL, { @@ -132,7 +95,7 @@ class FilesApiClient { if (response.statusCode == 200) { return response.bodyBytes; } - throw await FilesApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -180,7 +143,7 @@ class FilesDirectEditingClient { specifiedType: const FullType(FilesDirectEditingInfoResponseApplicationJson), )! as FilesDirectEditingInfoResponseApplicationJson; } - throw await FilesApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get the templates for direct editing @@ -228,7 +191,7 @@ class FilesDirectEditingClient { specifiedType: const FullType(FilesDirectEditingTemplatesResponseApplicationJson), )! as FilesDirectEditingTemplatesResponseApplicationJson; } - throw await FilesApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Open a file for direct editing @@ -282,7 +245,7 @@ class FilesDirectEditingClient { specifiedType: const FullType(FilesDirectEditingOpenResponseApplicationJson), )! as FilesDirectEditingOpenResponseApplicationJson; } - throw await FilesApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Create a file for direct editing @@ -336,7 +299,7 @@ class FilesDirectEditingClient { specifiedType: const FullType(FilesDirectEditingCreateResponseApplicationJson), )! as FilesDirectEditingCreateResponseApplicationJson; } - throw await FilesApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -388,7 +351,7 @@ class FilesOpenLocalEditorClient { specifiedType: const FullType(FilesOpenLocalEditorCreateResponseApplicationJson), )! as FilesOpenLocalEditorCreateResponseApplicationJson; } - throw await FilesApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Validate a local editor @@ -436,7 +399,7 @@ class FilesOpenLocalEditorClient { specifiedType: const FullType(FilesOpenLocalEditorValidateResponseApplicationJson), )! as FilesOpenLocalEditorValidateResponseApplicationJson; } - throw await FilesApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -484,7 +447,7 @@ class FilesTemplateClient { specifiedType: const FullType(FilesTemplateListResponseApplicationJson), )! as FilesTemplateListResponseApplicationJson; } - throw await FilesApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Create a template @@ -538,7 +501,7 @@ class FilesTemplateClient { specifiedType: const FullType(FilesTemplateCreateResponseApplicationJson), )! as FilesTemplateCreateResponseApplicationJson; } - throw await FilesApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Initialize the template directory @@ -590,7 +553,7 @@ class FilesTemplateClient { specifiedType: const FullType(FilesTemplatePathResponseApplicationJson), )! as FilesTemplatePathResponseApplicationJson; } - throw await FilesApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -644,7 +607,7 @@ class FilesTransferOwnershipClient { specifiedType: const FullType(FilesTransferOwnershipTransferResponseApplicationJson), )! as FilesTransferOwnershipTransferResponseApplicationJson; } - throw await FilesApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Accept an ownership transfer @@ -690,7 +653,7 @@ class FilesTransferOwnershipClient { specifiedType: const FullType(FilesTransferOwnershipAcceptResponseApplicationJson), )! as FilesTransferOwnershipAcceptResponseApplicationJson; } - throw await FilesApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Reject an ownership transfer @@ -736,7 +699,7 @@ class FilesTransferOwnershipClient { specifiedType: const FullType(FilesTransferOwnershipRejectResponseApplicationJson), )! as FilesTransferOwnershipRejectResponseApplicationJson; } - throw await FilesApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } diff --git a/packages/nextcloud/lib/src/api/files_external.openapi.dart b/packages/nextcloud/lib/src/api/files_external.openapi.dart index f90baaa4..26bc0874 100644 --- a/packages/nextcloud/lib/src/api/files_external.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_external.openapi.dart @@ -11,48 +11,11 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'files_external.openapi.g.dart'; -class FilesExternalResponse extends DynamiteResponse { - FilesExternalResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'FilesExternalResponse(data: $data, headers: $headers)'; -} - -class FilesExternalApiException extends DynamiteApiException { - FilesExternalApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return FilesExternalApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'FilesExternalApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class FilesExternalClient extends DynamiteClient { FilesExternalClient( super.baseURL, { @@ -119,7 +82,7 @@ class FilesExternalApiClient { specifiedType: const FullType(FilesExternalApiGetUserMountsResponseApplicationJson), )! as FilesExternalApiGetUserMountsResponseApplicationJson; } - throw await FilesExternalApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } diff --git a/packages/nextcloud/lib/src/api/files_reminders.openapi.dart b/packages/nextcloud/lib/src/api/files_reminders.openapi.dart index ac6169fc..3e8d897b 100644 --- a/packages/nextcloud/lib/src/api/files_reminders.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_reminders.openapi.dart @@ -11,48 +11,11 @@ import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:dynamite_runtime/utils.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'files_reminders.openapi.g.dart'; -class FilesRemindersResponse extends DynamiteResponse { - FilesRemindersResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'FilesRemindersResponse(data: $data, headers: $headers)'; -} - -class FilesRemindersApiException extends DynamiteApiException { - FilesRemindersApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return FilesRemindersApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'FilesRemindersApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class FilesRemindersClient extends DynamiteClient { FilesRemindersClient( super.baseURL, { @@ -126,7 +89,7 @@ class FilesRemindersApiClient { specifiedType: const FullType(FilesRemindersApiGetResponseApplicationJson), )! as FilesRemindersApiGetResponseApplicationJson; } - throw await FilesRemindersApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Set a reminder @@ -181,7 +144,7 @@ class FilesRemindersApiClient { specifiedType: const FullType(FilesRemindersApiSetResponseApplicationJson), )! as FilesRemindersApiSetResponseApplicationJson; } - throw await FilesRemindersApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Remove a reminder @@ -230,7 +193,7 @@ class FilesRemindersApiClient { specifiedType: const FullType(FilesRemindersApiRemoveResponseApplicationJson), )! as FilesRemindersApiRemoveResponseApplicationJson; } - throw await FilesRemindersApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } diff --git a/packages/nextcloud/lib/src/api/files_sharing.openapi.dart b/packages/nextcloud/lib/src/api/files_sharing.openapi.dart index cfdfd1c5..600db34c 100644 --- a/packages/nextcloud/lib/src/api/files_sharing.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_sharing.openapi.dart @@ -11,48 +11,11 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'files_sharing.openapi.g.dart'; -class FilesSharingResponse extends DynamiteResponse { - FilesSharingResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'FilesSharingResponse(data: $data, headers: $headers)'; -} - -class FilesSharingApiException extends DynamiteApiException { - FilesSharingApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return FilesSharingApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'FilesSharingApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class FilesSharingClient extends DynamiteClient { FilesSharingClient( super.baseURL, { @@ -129,7 +92,7 @@ class FilesSharingDeletedShareapiClient { specifiedType: const FullType(FilesSharingDeletedShareapiListResponseApplicationJson), )! as FilesSharingDeletedShareapiListResponseApplicationJson; } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Undelete a deleted share @@ -175,7 +138,7 @@ class FilesSharingDeletedShareapiClient { specifiedType: const FullType(FilesSharingDeletedShareapiUndeleteResponseApplicationJson), )! as FilesSharingDeletedShareapiUndeleteResponseApplicationJson; } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -222,7 +185,7 @@ class FilesSharingPublicPreviewClient { if (response.statusCode == 200) { return response.bodyBytes; } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get a preview for a shared file @@ -279,7 +242,7 @@ class FilesSharingPublicPreviewClient { if (response.statusCode == 200) { return response.bodyBytes; } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -327,7 +290,7 @@ class FilesSharingRemoteClient { specifiedType: const FullType(FilesSharingRemoteGetSharesResponseApplicationJson), )! as FilesSharingRemoteGetSharesResponseApplicationJson; } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get list of pending remote shares @@ -371,7 +334,7 @@ class FilesSharingRemoteClient { specifiedType: const FullType(FilesSharingRemoteGetOpenSharesResponseApplicationJson), )! as FilesSharingRemoteGetOpenSharesResponseApplicationJson; } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Accept a remote share @@ -417,7 +380,7 @@ class FilesSharingRemoteClient { specifiedType: const FullType(FilesSharingRemoteAcceptShareResponseApplicationJson), )! as FilesSharingRemoteAcceptShareResponseApplicationJson; } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Decline a remote share @@ -463,7 +426,7 @@ class FilesSharingRemoteClient { specifiedType: const FullType(FilesSharingRemoteDeclineShareResponseApplicationJson), )! as FilesSharingRemoteDeclineShareResponseApplicationJson; } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get info of a remote share @@ -509,7 +472,7 @@ class FilesSharingRemoteClient { specifiedType: const FullType(FilesSharingRemoteGetShareResponseApplicationJson), )! as FilesSharingRemoteGetShareResponseApplicationJson; } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Unshare a remote share @@ -555,7 +518,7 @@ class FilesSharingRemoteClient { specifiedType: const FullType(FilesSharingRemoteUnshareResponseApplicationJson), )! as FilesSharingRemoteUnshareResponseApplicationJson; } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -615,7 +578,7 @@ class FilesSharingShareInfoClient { specifiedType: const FullType(FilesSharingShareInfo), )! as FilesSharingShareInfo; } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -685,7 +648,7 @@ class FilesSharingShareapiClient { specifiedType: const FullType(FilesSharingShareapiGetSharesResponseApplicationJson), )! as FilesSharingShareapiGetSharesResponseApplicationJson; } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Create a share @@ -773,7 +736,7 @@ class FilesSharingShareapiClient { specifiedType: const FullType(FilesSharingShareapiCreateShareResponseApplicationJson), )! as FilesSharingShareapiCreateShareResponseApplicationJson; } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get all shares relative to a file, including parent folders shares rights @@ -819,7 +782,7 @@ class FilesSharingShareapiClient { specifiedType: const FullType(FilesSharingShareapiGetInheritedSharesResponseApplicationJson), )! as FilesSharingShareapiGetInheritedSharesResponseApplicationJson; } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get all shares that are still pending @@ -863,7 +826,7 @@ class FilesSharingShareapiClient { specifiedType: const FullType(FilesSharingShareapiPendingSharesResponseApplicationJson), )! as FilesSharingShareapiPendingSharesResponseApplicationJson; } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get a specific share by id @@ -913,7 +876,7 @@ class FilesSharingShareapiClient { specifiedType: const FullType(FilesSharingShareapiGetShareResponseApplicationJson), )! as FilesSharingShareapiGetShareResponseApplicationJson; } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Update a share @@ -995,7 +958,7 @@ class FilesSharingShareapiClient { specifiedType: const FullType(FilesSharingShareapiUpdateShareResponseApplicationJson), )! as FilesSharingShareapiUpdateShareResponseApplicationJson; } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Delete a share @@ -1041,7 +1004,7 @@ class FilesSharingShareapiClient { specifiedType: const FullType(FilesSharingShareapiDeleteShareResponseApplicationJson), )! as FilesSharingShareapiDeleteShareResponseApplicationJson; } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Accept a share @@ -1087,7 +1050,7 @@ class FilesSharingShareapiClient { specifiedType: const FullType(FilesSharingShareapiAcceptShareResponseApplicationJson), )! as FilesSharingShareapiAcceptShareResponseApplicationJson; } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -1098,7 +1061,7 @@ class FilesSharingShareesapiClient { /// Search for sharees Future< - FilesSharingResponse> search({ final String search = '', final String? itemType, @@ -1161,7 +1124,7 @@ class FilesSharingShareesapiClient { body, ); if (response.statusCode == 200) { - return FilesSharingResponse( _jsonSerializers.deserialize( await response.jsonBody, @@ -1173,7 +1136,7 @@ class FilesSharingShareesapiClient { )! as FilesSharingShareesapiShareesapiSearchHeaders, ); } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Find recommended sharees @@ -1226,7 +1189,7 @@ class FilesSharingShareesapiClient { specifiedType: const FullType(FilesSharingShareesapiFindRecommendedResponseApplicationJson), )! as FilesSharingShareesapiFindRecommendedResponseApplicationJson; } - throw await FilesSharingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } diff --git a/packages/nextcloud/lib/src/api/files_trashbin.openapi.dart b/packages/nextcloud/lib/src/api/files_trashbin.openapi.dart index ee0e59e0..b81fcdf4 100644 --- a/packages/nextcloud/lib/src/api/files_trashbin.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_trashbin.openapi.dart @@ -9,48 +9,11 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'files_trashbin.openapi.g.dart'; -class FilesTrashbinResponse extends DynamiteResponse { - FilesTrashbinResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'FilesTrashbinResponse(data: $data, headers: $headers)'; -} - -class FilesTrashbinApiException extends DynamiteApiException { - FilesTrashbinApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return FilesTrashbinApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'FilesTrashbinApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class FilesTrashbinClient extends DynamiteClient { FilesTrashbinClient( super.baseURL, { @@ -130,7 +93,7 @@ class FilesTrashbinPreviewClient { if (response.statusCode == 200) { return response.bodyBytes; } - throw await FilesTrashbinApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } diff --git a/packages/nextcloud/lib/src/api/files_versions.openapi.dart b/packages/nextcloud/lib/src/api/files_versions.openapi.dart index 9025edcf..76c72f92 100644 --- a/packages/nextcloud/lib/src/api/files_versions.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_versions.openapi.dart @@ -9,48 +9,11 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'files_versions.openapi.g.dart'; -class FilesVersionsResponse extends DynamiteResponse { - FilesVersionsResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'FilesVersionsResponse(data: $data, headers: $headers)'; -} - -class FilesVersionsApiException extends DynamiteApiException { - FilesVersionsApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return FilesVersionsApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'FilesVersionsApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class FilesVersionsClient extends DynamiteClient { FilesVersionsClient( super.baseURL, { @@ -130,7 +93,7 @@ class FilesVersionsPreviewClient { if (response.statusCode == 200) { return response.bodyBytes; } - throw await FilesVersionsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } diff --git a/packages/nextcloud/lib/src/api/news.openapi.dart b/packages/nextcloud/lib/src/api/news.openapi.dart index 109b9dc9..f893bde8 100644 --- a/packages/nextcloud/lib/src/api/news.openapi.dart +++ b/packages/nextcloud/lib/src/api/news.openapi.dart @@ -11,48 +11,11 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'news.openapi.g.dart'; -class NewsResponse extends DynamiteResponse { - NewsResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'NewsResponse(data: $data, headers: $headers)'; -} - -class NewsApiException extends DynamiteApiException { - NewsApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return NewsApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'NewsApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class NewsClient extends DynamiteClient { NewsClient( super.baseURL, { @@ -109,7 +72,7 @@ class NewsClient extends DynamiteClient { specifiedType: const FullType(NewsSupportedAPIVersions), )! as NewsSupportedAPIVersions; } - throw await NewsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future listFolders() async { @@ -147,7 +110,7 @@ class NewsClient extends DynamiteClient { return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NewsListFolders))! as NewsListFolders; } - throw await NewsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future createFolder({required final String name}) async { @@ -186,7 +149,7 @@ class NewsClient extends DynamiteClient { return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NewsListFolders))! as NewsListFolders; } - throw await NewsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future renameFolder({ @@ -226,7 +189,7 @@ class NewsClient extends DynamiteClient { if (response.statusCode == 200) { return; } - throw await NewsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future deleteFolder({required final int folderId}) async { @@ -262,7 +225,7 @@ class NewsClient extends DynamiteClient { if (response.statusCode == 200) { return; } - throw await NewsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future markFolderAsRead({ @@ -302,7 +265,7 @@ class NewsClient extends DynamiteClient { if (response.statusCode == 200) { return; } - throw await NewsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future listFeeds() async { @@ -340,7 +303,7 @@ class NewsClient extends DynamiteClient { return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NewsListFeeds))! as NewsListFeeds; } - throw await NewsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future addFeed({ @@ -385,7 +348,7 @@ class NewsClient extends DynamiteClient { return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NewsListFeeds))! as NewsListFeeds; } - throw await NewsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future deleteFeed({required final int feedId}) async { @@ -421,7 +384,7 @@ class NewsClient extends DynamiteClient { if (response.statusCode == 200) { return; } - throw await NewsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future moveFeed({ @@ -463,7 +426,7 @@ class NewsClient extends DynamiteClient { if (response.statusCode == 200) { return; } - throw await NewsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future renameFeed({ @@ -503,7 +466,7 @@ class NewsClient extends DynamiteClient { if (response.statusCode == 200) { return; } - throw await NewsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future markFeedAsRead({ @@ -543,7 +506,7 @@ class NewsClient extends DynamiteClient { if (response.statusCode == 200) { return; } - throw await NewsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future listArticles({ @@ -606,7 +569,7 @@ class NewsClient extends DynamiteClient { return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NewsListArticles))! as NewsListArticles; } - throw await NewsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future listUpdatedArticles({ @@ -657,7 +620,7 @@ class NewsClient extends DynamiteClient { return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NewsListArticles))! as NewsListArticles; } - throw await NewsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future markArticleAsRead({required final int itemId}) async { @@ -693,7 +656,7 @@ class NewsClient extends DynamiteClient { if (response.statusCode == 200) { return; } - throw await NewsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future markArticleAsUnread({required final int itemId}) async { @@ -729,7 +692,7 @@ class NewsClient extends DynamiteClient { if (response.statusCode == 200) { return; } - throw await NewsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future starArticle({required final int itemId}) async { @@ -765,7 +728,7 @@ class NewsClient extends DynamiteClient { if (response.statusCode == 200) { return; } - throw await NewsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future unstarArticle({required final int itemId}) async { @@ -801,7 +764,7 @@ class NewsClient extends DynamiteClient { if (response.statusCode == 200) { return; } - throw await NewsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } diff --git a/packages/nextcloud/lib/src/api/notes.openapi.dart b/packages/nextcloud/lib/src/api/notes.openapi.dart index c9a12c2d..086aed41 100644 --- a/packages/nextcloud/lib/src/api/notes.openapi.dart +++ b/packages/nextcloud/lib/src/api/notes.openapi.dart @@ -12,48 +12,11 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'notes.openapi.g.dart'; -class NotesResponse extends DynamiteResponse { - NotesResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'NotesResponse(data: $data, headers: $headers)'; -} - -class NotesApiException extends DynamiteApiException { - NotesApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return NotesApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'NotesApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class NotesClient extends DynamiteClient { NotesClient( super.baseURL, { @@ -135,7 +98,7 @@ class NotesClient extends DynamiteClient { specifiedType: const FullType(BuiltList, [FullType(NotesNote)]), )! as BuiltList; } - throw await NotesApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future createNote({ @@ -194,7 +157,7 @@ class NotesClient extends DynamiteClient { return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NotesNote))! as NotesNote; } - throw await NotesApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future getNote({ @@ -243,7 +206,7 @@ class NotesClient extends DynamiteClient { return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NotesNote))! as NotesNote; } - throw await NotesApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future updateNote({ @@ -308,7 +271,7 @@ class NotesClient extends DynamiteClient { return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NotesNote))! as NotesNote; } - throw await NotesApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future deleteNote({required final int id}) async { @@ -346,7 +309,7 @@ class NotesClient extends DynamiteClient { if (response.statusCode == 200) { return response.body; } - throw await NotesApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future getSettings() async { @@ -384,7 +347,7 @@ class NotesClient extends DynamiteClient { return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NotesSettings))! as NotesSettings; } - throw await NotesApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } Future updateSettings({required final NotesSettings settings}) async { @@ -425,7 +388,7 @@ class NotesClient extends DynamiteClient { return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NotesSettings))! as NotesSettings; } - throw await NotesApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } diff --git a/packages/nextcloud/lib/src/api/notifications.openapi.dart b/packages/nextcloud/lib/src/api/notifications.openapi.dart index fc24ec02..3ecd9e6d 100644 --- a/packages/nextcloud/lib/src/api/notifications.openapi.dart +++ b/packages/nextcloud/lib/src/api/notifications.openapi.dart @@ -11,48 +11,11 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'notifications.openapi.g.dart'; -class NotificationsResponse extends DynamiteResponse { - NotificationsResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'NotificationsResponse(data: $data, headers: $headers)'; -} - -class NotificationsApiException extends DynamiteApiException { - NotificationsApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return NotificationsApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'NotificationsApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class NotificationsClient extends DynamiteClient { NotificationsClient( super.baseURL, { @@ -139,7 +102,7 @@ class NotificationsApiClient { specifiedType: const FullType(NotificationsApiGenerateNotificationResponseApplicationJson), )! as NotificationsApiGenerateNotificationResponseApplicationJson; } - throw await NotificationsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -150,7 +113,7 @@ class NotificationsEndpointClient { /// Get all notifications Future< - NotificationsResponse> listNotifications({ final NotificationsEndpointListNotificationsApiVersion apiVersion = NotificationsEndpointListNotificationsApiVersion.v2, @@ -189,7 +152,7 @@ class NotificationsEndpointClient { body, ); if (response.statusCode == 200) { - return NotificationsResponse( _jsonSerializers.deserialize( await response.jsonBody, @@ -201,7 +164,7 @@ class NotificationsEndpointClient { )! as NotificationsEndpointEndpointListNotificationsHeaders, ); } - throw await NotificationsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Delete all notifications @@ -248,7 +211,7 @@ class NotificationsEndpointClient { specifiedType: const FullType(NotificationsEndpointDeleteAllNotificationsResponseApplicationJson), )! as NotificationsEndpointDeleteAllNotificationsResponseApplicationJson; } - throw await NotificationsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get a notification @@ -296,7 +259,7 @@ class NotificationsEndpointClient { specifiedType: const FullType(NotificationsEndpointGetNotificationResponseApplicationJson), )! as NotificationsEndpointGetNotificationResponseApplicationJson; } - throw await NotificationsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Delete a notification @@ -345,7 +308,7 @@ class NotificationsEndpointClient { specifiedType: const FullType(NotificationsEndpointDeleteNotificationResponseApplicationJson), )! as NotificationsEndpointDeleteNotificationResponseApplicationJson; } - throw await NotificationsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Check if notification IDs exist @@ -394,7 +357,7 @@ class NotificationsEndpointClient { specifiedType: const FullType(NotificationsEndpointConfirmIdsForUserResponseApplicationJson), )! as NotificationsEndpointConfirmIdsForUserResponseApplicationJson; } - throw await NotificationsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -452,7 +415,7 @@ class NotificationsPushClient { specifiedType: const FullType(NotificationsPushRegisterDeviceResponseApplicationJson), )! as NotificationsPushRegisterDeviceResponseApplicationJson; } - throw await NotificationsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Remove a device from push notifications @@ -498,7 +461,7 @@ class NotificationsPushClient { specifiedType: const FullType(NotificationsPushRemoveDeviceResponseApplicationJson), )! as NotificationsPushRemoveDeviceResponseApplicationJson; } - throw await NotificationsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -556,7 +519,7 @@ class NotificationsSettingsClient { specifiedType: const FullType(NotificationsSettingsPersonalResponseApplicationJson), )! as NotificationsSettingsPersonalResponseApplicationJson; } - throw await NotificationsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Update default notification settings for new users @@ -610,7 +573,7 @@ class NotificationsSettingsClient { specifiedType: const FullType(NotificationsSettingsAdminResponseApplicationJson), )! as NotificationsSettingsAdminResponseApplicationJson; } - throw await NotificationsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } diff --git a/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart b/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart index ca925063..6bf28cb4 100644 --- a/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart +++ b/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart @@ -12,48 +12,11 @@ import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:dynamite_runtime/utils.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'provisioning_api.openapi.g.dart'; -class ProvisioningApiResponse extends DynamiteResponse { - ProvisioningApiResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'ProvisioningApiResponse(data: $data, headers: $headers)'; -} - -class ProvisioningApiApiException extends DynamiteApiException { - ProvisioningApiApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return ProvisioningApiApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'ProvisioningApiApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class ProvisioningApiClient extends DynamiteClient { ProvisioningApiClient( super.baseURL, { @@ -130,7 +93,7 @@ class ProvisioningApiAppConfigClient { specifiedType: const FullType(ProvisioningApiAppConfigGetAppsResponseApplicationJson), )! as ProvisioningApiAppConfigGetAppsResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get the config keys of an app @@ -178,7 +141,7 @@ class ProvisioningApiAppConfigClient { specifiedType: const FullType(ProvisioningApiAppConfigGetKeysResponseApplicationJson), )! as ProvisioningApiAppConfigGetKeysResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get a the config value of an app @@ -232,7 +195,7 @@ class ProvisioningApiAppConfigClient { specifiedType: const FullType(ProvisioningApiAppConfigGetValueResponseApplicationJson), )! as ProvisioningApiAppConfigGetValueResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Update the config value of an app @@ -282,7 +245,7 @@ class ProvisioningApiAppConfigClient { specifiedType: const FullType(ProvisioningApiAppConfigSetValueResponseApplicationJson), )! as ProvisioningApiAppConfigSetValueResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Delete a config key of an app @@ -332,7 +295,7 @@ class ProvisioningApiAppConfigClient { specifiedType: const FullType(ProvisioningApiAppConfigDeleteKeyResponseApplicationJson), )! as ProvisioningApiAppConfigDeleteKeyResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -388,7 +351,7 @@ class ProvisioningApiAppsClient { specifiedType: const FullType(ProvisioningApiAppsGetAppsResponseApplicationJson), )! as ProvisioningApiAppsGetAppsResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get the app info for an app @@ -436,7 +399,7 @@ class ProvisioningApiAppsClient { specifiedType: const FullType(ProvisioningApiAppsGetAppInfoResponseApplicationJson), )! as ProvisioningApiAppsGetAppInfoResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Enable an app @@ -484,7 +447,7 @@ class ProvisioningApiAppsClient { specifiedType: const FullType(ProvisioningApiAppsEnableResponseApplicationJson), )! as ProvisioningApiAppsEnableResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Disable an app @@ -532,7 +495,7 @@ class ProvisioningApiAppsClient { specifiedType: const FullType(ProvisioningApiAppsDisableResponseApplicationJson), )! as ProvisioningApiAppsDisableResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -594,7 +557,7 @@ class ProvisioningApiGroupsClient { specifiedType: const FullType(ProvisioningApiGroupsGetGroupsResponseApplicationJson), )! as ProvisioningApiGroupsGetGroupsResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Create a new group @@ -646,7 +609,7 @@ class ProvisioningApiGroupsClient { specifiedType: const FullType(ProvisioningApiGroupsAddGroupResponseApplicationJson), )! as ProvisioningApiGroupsAddGroupResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get a list of groups details @@ -702,7 +665,7 @@ class ProvisioningApiGroupsClient { specifiedType: const FullType(ProvisioningApiGroupsGetGroupsDetailsResponseApplicationJson), )! as ProvisioningApiGroupsGetGroupsDetailsResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get a list of users in the specified group @@ -749,7 +712,7 @@ class ProvisioningApiGroupsClient { specifiedType: const FullType(ProvisioningApiGroupsGetGroupUsersResponseApplicationJson), )! as ProvisioningApiGroupsGetGroupUsersResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get a list of users details in the specified group @@ -808,7 +771,7 @@ class ProvisioningApiGroupsClient { specifiedType: const FullType(ProvisioningApiGroupsGetGroupUsersDetailsResponseApplicationJson), )! as ProvisioningApiGroupsGetGroupUsersDetailsResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get the list of user IDs that are a subadmin of the group @@ -857,7 +820,7 @@ class ProvisioningApiGroupsClient { specifiedType: const FullType(ProvisioningApiGroupsGetSubAdminsOfGroupResponseApplicationJson), )! as ProvisioningApiGroupsGetSubAdminsOfGroupResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get a list of users in the specified group @@ -905,7 +868,7 @@ class ProvisioningApiGroupsClient { specifiedType: const FullType(ProvisioningApiGroupsGetGroupResponseApplicationJson), )! as ProvisioningApiGroupsGetGroupResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Update a group @@ -958,7 +921,7 @@ class ProvisioningApiGroupsClient { specifiedType: const FullType(ProvisioningApiGroupsUpdateGroupResponseApplicationJson), )! as ProvisioningApiGroupsUpdateGroupResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Delete a group @@ -1007,7 +970,7 @@ class ProvisioningApiGroupsClient { specifiedType: const FullType(ProvisioningApiGroupsDeleteGroupResponseApplicationJson), )! as ProvisioningApiGroupsDeleteGroupResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -1063,7 +1026,7 @@ class ProvisioningApiPreferencesClient { specifiedType: const FullType(ProvisioningApiPreferencesSetPreferenceResponseApplicationJson), )! as ProvisioningApiPreferencesSetPreferenceResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Delete a preference for an app @@ -1111,7 +1074,7 @@ class ProvisioningApiPreferencesClient { specifiedType: const FullType(ProvisioningApiPreferencesDeletePreferenceResponseApplicationJson), )! as ProvisioningApiPreferencesDeletePreferenceResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Update multiple preference values of an app @@ -1164,7 +1127,7 @@ class ProvisioningApiPreferencesClient { specifiedType: const FullType(ProvisioningApiPreferencesSetMultiplePreferencesResponseApplicationJson), )! as ProvisioningApiPreferencesSetMultiplePreferencesResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Delete multiple preferences for an app @@ -1212,7 +1175,7 @@ class ProvisioningApiPreferencesClient { specifiedType: const FullType(ProvisioningApiPreferencesDeleteMultiplePreferenceResponseApplicationJson), )! as ProvisioningApiPreferencesDeleteMultiplePreferenceResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -1274,7 +1237,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersGetUsersResponseApplicationJson), )! as ProvisioningApiUsersGetUsersResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Create a new user @@ -1352,7 +1315,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersAddUserResponseApplicationJson), )! as ProvisioningApiUsersAddUserResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get a list of users and their details @@ -1408,7 +1371,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersGetUsersDetailsResponseApplicationJson), )! as ProvisioningApiUsersGetUsersDetailsResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Search users by their phone numbers @@ -1464,7 +1427,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersSearchByPhoneNumbersResponseApplicationJson), )! as ProvisioningApiUsersSearchByPhoneNumbersResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get the details of a user @@ -1510,7 +1473,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersGetUserResponseApplicationJson), )! as ProvisioningApiUsersGetUserResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Update a value of the user's details @@ -1560,7 +1523,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersEditUserResponseApplicationJson), )! as ProvisioningApiUsersEditUserResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Delete a user @@ -1606,7 +1569,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersDeleteUserResponseApplicationJson), )! as ProvisioningApiUsersDeleteUserResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get the details of the current user @@ -1650,7 +1613,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersGetCurrentUserResponseApplicationJson), )! as ProvisioningApiUsersGetCurrentUserResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get a list of fields that are editable for the current user @@ -1694,7 +1657,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersGetEditableFieldsResponseApplicationJson), )! as ProvisioningApiUsersGetEditableFieldsResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get a list of fields that are editable for a user @@ -1740,7 +1703,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersGetEditableFieldsForUserResponseApplicationJson), )! as ProvisioningApiUsersGetEditableFieldsForUserResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Update multiple values of the user's details @@ -1797,7 +1760,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersEditUserMultiValueResponseApplicationJson), )! as ProvisioningApiUsersEditUserMultiValueResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Wipe all devices of a user @@ -1843,7 +1806,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersWipeUserDevicesResponseApplicationJson), )! as ProvisioningApiUsersWipeUserDevicesResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Enable a user @@ -1889,7 +1852,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersEnableUserResponseApplicationJson), )! as ProvisioningApiUsersEnableUserResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Disable a user @@ -1935,7 +1898,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersDisableUserResponseApplicationJson), )! as ProvisioningApiUsersDisableUserResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get a list of groups the user belongs to @@ -1981,7 +1944,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersGetUsersGroupsResponseApplicationJson), )! as ProvisioningApiUsersGetUsersGroupsResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Add a user to a group @@ -2031,7 +1994,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersAddToGroupResponseApplicationJson), )! as ProvisioningApiUsersAddToGroupResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Remove a user from a group @@ -2079,7 +2042,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersRemoveFromGroupResponseApplicationJson), )! as ProvisioningApiUsersRemoveFromGroupResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get the groups a user is a subadmin of @@ -2127,7 +2090,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersGetUserSubAdminGroupsResponseApplicationJson), )! as ProvisioningApiUsersGetUserSubAdminGroupsResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Make a user a subadmin of a group @@ -2177,7 +2140,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersAddSubAdminResponseApplicationJson), )! as ProvisioningApiUsersAddSubAdminResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Remove a user from the subadmins of a group @@ -2227,7 +2190,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersRemoveSubAdminResponseApplicationJson), )! as ProvisioningApiUsersRemoveSubAdminResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Resend the welcome message @@ -2273,7 +2236,7 @@ class ProvisioningApiUsersClient { specifiedType: const FullType(ProvisioningApiUsersResendWelcomeMessageResponseApplicationJson), )! as ProvisioningApiUsersResendWelcomeMessageResponseApplicationJson; } - throw await ProvisioningApiApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } diff --git a/packages/nextcloud/lib/src/api/settings.openapi.dart b/packages/nextcloud/lib/src/api/settings.openapi.dart index 59bb4c91..f2123319 100644 --- a/packages/nextcloud/lib/src/api/settings.openapi.dart +++ b/packages/nextcloud/lib/src/api/settings.openapi.dart @@ -9,48 +9,11 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'settings.openapi.g.dart'; -class SettingsResponse extends DynamiteResponse { - SettingsResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'SettingsResponse(data: $data, headers: $headers)'; -} - -class SettingsApiException extends DynamiteApiException { - SettingsApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return SettingsApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'SettingsApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class SettingsClient extends DynamiteClient { SettingsClient( super.baseURL, { @@ -81,7 +44,7 @@ class SettingsLogSettingsClient { /// download logfile /// /// This endpoint requires admin access - Future> download() async { + Future> download() async { const path = '/index.php/settings/admin/log/download'; final queryParameters = {}; final headers = { @@ -113,7 +76,7 @@ class SettingsLogSettingsClient { body, ); if (response.statusCode == 200) { - return SettingsResponse( + return DynamiteResponse( await response.bodyBytes, _jsonSerializers.deserialize( response.responseHeaders, @@ -121,7 +84,7 @@ class SettingsLogSettingsClient { )! as SettingsLogSettingsLogSettingsDownloadHeaders, ); } - throw await SettingsApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } diff --git a/packages/nextcloud/lib/src/api/sharebymail.openapi.dart b/packages/nextcloud/lib/src/api/sharebymail.openapi.dart index 3358a7e5..bc71e019 100644 --- a/packages/nextcloud/lib/src/api/sharebymail.openapi.dart +++ b/packages/nextcloud/lib/src/api/sharebymail.openapi.dart @@ -7,48 +7,11 @@ import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'sharebymail.openapi.g.dart'; -class SharebymailResponse extends DynamiteResponse { - SharebymailResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'SharebymailResponse(data: $data, headers: $headers)'; -} - -class SharebymailApiException extends DynamiteApiException { - SharebymailApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return SharebymailApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'SharebymailApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class SharebymailClient extends DynamiteClient { SharebymailClient( super.baseURL, { diff --git a/packages/nextcloud/lib/src/api/theming.openapi.dart b/packages/nextcloud/lib/src/api/theming.openapi.dart index 4ed2e605..55b0e313 100644 --- a/packages/nextcloud/lib/src/api/theming.openapi.dart +++ b/packages/nextcloud/lib/src/api/theming.openapi.dart @@ -12,48 +12,11 @@ import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:dynamite_runtime/utils.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'theming.openapi.g.dart'; -class ThemingResponse extends DynamiteResponse { - ThemingResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'ThemingResponse(data: $data, headers: $headers)'; -} - -class ThemingApiException extends DynamiteApiException { - ThemingApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return ThemingApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'ThemingApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class ThemingClient extends DynamiteClient { ThemingClient( super.baseURL, { @@ -119,7 +82,7 @@ class ThemingIconClient { if (response.statusCode == 200) { return response.bodyBytes; } - throw await ThemingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Return a 512x512 icon for touch devices @@ -156,7 +119,7 @@ class ThemingIconClient { if (response.statusCode == 200) { return response.bodyBytes; } - throw await ThemingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get a themed icon @@ -198,7 +161,7 @@ class ThemingIconClient { if (response.statusCode == 200) { return response.bodyBytes; } - throw await ThemingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -253,7 +216,7 @@ class ThemingThemingClient { if (response.statusCode == 200) { return response.body; } - throw await ThemingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get an image @@ -296,7 +259,7 @@ class ThemingThemingClient { if (response.statusCode == 200) { return response.bodyBytes; } - throw await ThemingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get the manifest for an app @@ -336,7 +299,7 @@ class ThemingThemingClient { specifiedType: const FullType(ThemingThemingGetManifestResponseApplicationJson), )! as ThemingThemingGetManifestResponseApplicationJson; } - throw await ThemingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -381,7 +344,7 @@ class ThemingUserThemeClient { if (response.statusCode == 200) { return response.bodyBytes; } - throw await ThemingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Set the background @@ -433,7 +396,7 @@ class ThemingUserThemeClient { return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(ThemingBackground))! as ThemingBackground; } - throw await ThemingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Delete the background @@ -473,7 +436,7 @@ class ThemingUserThemeClient { return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(ThemingBackground))! as ThemingBackground; } - throw await ThemingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Enable theme @@ -519,7 +482,7 @@ class ThemingUserThemeClient { specifiedType: const FullType(ThemingUserThemeEnableThemeResponseApplicationJson), )! as ThemingUserThemeEnableThemeResponseApplicationJson; } - throw await ThemingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Disable theme @@ -565,7 +528,7 @@ class ThemingUserThemeClient { specifiedType: const FullType(ThemingUserThemeDisableThemeResponseApplicationJson), )! as ThemingUserThemeDisableThemeResponseApplicationJson; } - throw await ThemingApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } diff --git a/packages/nextcloud/lib/src/api/updatenotification.openapi.dart b/packages/nextcloud/lib/src/api/updatenotification.openapi.dart index 07e887e4..10d4f71e 100644 --- a/packages/nextcloud/lib/src/api/updatenotification.openapi.dart +++ b/packages/nextcloud/lib/src/api/updatenotification.openapi.dart @@ -10,48 +10,11 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'updatenotification.openapi.g.dart'; -class UpdatenotificationResponse extends DynamiteResponse { - UpdatenotificationResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'UpdatenotificationResponse(data: $data, headers: $headers)'; -} - -class UpdatenotificationApiException extends DynamiteApiException { - UpdatenotificationApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return UpdatenotificationApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'UpdatenotificationApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class UpdatenotificationClient extends DynamiteClient { UpdatenotificationClient( super.baseURL, { @@ -126,7 +89,7 @@ class UpdatenotificationApiClient { specifiedType: const FullType(UpdatenotificationApiGetAppListResponseApplicationJson), )! as UpdatenotificationApiGetAppListResponseApplicationJson; } - throw await UpdatenotificationApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } diff --git a/packages/nextcloud/lib/src/api/uppush.openapi.dart b/packages/nextcloud/lib/src/api/uppush.openapi.dart index 0fa4a625..6a766bf2 100644 --- a/packages/nextcloud/lib/src/api/uppush.openapi.dart +++ b/packages/nextcloud/lib/src/api/uppush.openapi.dart @@ -10,48 +10,11 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'uppush.openapi.g.dart'; -class UppushResponse extends DynamiteResponse { - UppushResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'UppushResponse(data: $data, headers: $headers)'; -} - -class UppushApiException extends DynamiteApiException { - UppushApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return UppushApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'UppushApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class UppushClient extends DynamiteClient { UppushClient( super.baseURL, { @@ -109,7 +72,7 @@ class UppushClient extends DynamiteClient { specifiedType: const FullType(UppushCheckResponseApplicationJson), )! as UppushCheckResponseApplicationJson; } - throw await UppushApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Set keepalive interval @@ -153,7 +116,7 @@ class UppushClient extends DynamiteClient { specifiedType: const FullType(UppushSetKeepaliveResponseApplicationJson), )! as UppushSetKeepaliveResponseApplicationJson; } - throw await UppushApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Request to create a new deviceId @@ -195,7 +158,7 @@ class UppushClient extends DynamiteClient { specifiedType: const FullType(UppushCreateDeviceResponseApplicationJson), )! as UppushCreateDeviceResponseApplicationJson; } - throw await UppushApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Request to get push messages @@ -239,7 +202,7 @@ class UppushClient extends DynamiteClient { specifiedType: const FullType(UppushSyncDeviceResponseApplicationJson), )! as UppushSyncDeviceResponseApplicationJson; } - throw await UppushApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Delete a device @@ -281,7 +244,7 @@ class UppushClient extends DynamiteClient { specifiedType: const FullType(UppushDeleteDeviceResponseApplicationJson), )! as UppushDeleteDeviceResponseApplicationJson; } - throw await UppushApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Create an authorization token for a new 3rd party service @@ -327,7 +290,7 @@ class UppushClient extends DynamiteClient { specifiedType: const FullType(UppushCreateAppResponseApplicationJson), )! as UppushCreateAppResponseApplicationJson; } - throw await UppushApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Delete an authorization token @@ -369,7 +332,7 @@ class UppushClient extends DynamiteClient { specifiedType: const FullType(UppushDeleteAppResponseApplicationJson), )! as UppushDeleteAppResponseApplicationJson; } - throw await UppushApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Unifiedpush discovery Following specifications @@ -411,7 +374,7 @@ class UppushClient extends DynamiteClient { specifiedType: const FullType(UppushUnifiedpushDiscoveryResponseApplicationJson), )! as UppushUnifiedpushDiscoveryResponseApplicationJson; } - throw await UppushApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Receive notifications from 3rd parties @@ -453,7 +416,7 @@ class UppushClient extends DynamiteClient { specifiedType: const FullType(UppushPushResponseApplicationJson), )! as UppushPushResponseApplicationJson; } - throw await UppushApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Matrix Gateway discovery @@ -494,7 +457,7 @@ class UppushClient extends DynamiteClient { specifiedType: const FullType(UppushGatewayMatrixDiscoveryResponseApplicationJson), )! as UppushGatewayMatrixDiscoveryResponseApplicationJson; } - throw await UppushApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Matrix Gateway @@ -535,7 +498,7 @@ class UppushClient extends DynamiteClient { specifiedType: const FullType(UppushGatewayMatrixResponseApplicationJson), )! as UppushGatewayMatrixResponseApplicationJson; } - throw await UppushApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } diff --git a/packages/nextcloud/lib/src/api/user_status.openapi.dart b/packages/nextcloud/lib/src/api/user_status.openapi.dart index a39ca5c2..33416074 100644 --- a/packages/nextcloud/lib/src/api/user_status.openapi.dart +++ b/packages/nextcloud/lib/src/api/user_status.openapi.dart @@ -11,48 +11,11 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'user_status.openapi.g.dart'; -class UserStatusResponse extends DynamiteResponse { - UserStatusResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'UserStatusResponse(data: $data, headers: $headers)'; -} - -class UserStatusApiException extends DynamiteApiException { - UserStatusApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return UserStatusApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'UserStatusApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class UserStatusClient extends DynamiteClient { UserStatusClient( super.baseURL, { @@ -129,7 +92,7 @@ class UserStatusHeartbeatClient { specifiedType: const FullType(UserStatusHeartbeatHeartbeatResponseApplicationJson), )! as UserStatusHeartbeatHeartbeatResponseApplicationJson; } - throw await UserStatusApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -177,7 +140,7 @@ class UserStatusPredefinedStatusClient { specifiedType: const FullType(UserStatusPredefinedStatusFindAllResponseApplicationJson), )! as UserStatusPredefinedStatusFindAllResponseApplicationJson; } - throw await UserStatusApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -235,7 +198,7 @@ class UserStatusStatusesClient { specifiedType: const FullType(UserStatusStatusesFindAllResponseApplicationJson), )! as UserStatusStatusesFindAllResponseApplicationJson; } - throw await UserStatusApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Find the status of a user @@ -281,7 +244,7 @@ class UserStatusStatusesClient { specifiedType: const FullType(UserStatusStatusesFindResponseApplicationJson), )! as UserStatusStatusesFindResponseApplicationJson; } - throw await UserStatusApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -329,7 +292,7 @@ class UserStatusUserStatusClient { specifiedType: const FullType(UserStatusUserStatusGetStatusResponseApplicationJson), )! as UserStatusUserStatusGetStatusResponseApplicationJson; } - throw await UserStatusApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Update the status type of the current user @@ -375,7 +338,7 @@ class UserStatusUserStatusClient { specifiedType: const FullType(UserStatusUserStatusSetStatusResponseApplicationJson), )! as UserStatusUserStatusSetStatusResponseApplicationJson; } - throw await UserStatusApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Set the message to a predefined message for the current user @@ -425,7 +388,7 @@ class UserStatusUserStatusClient { specifiedType: const FullType(UserStatusUserStatusSetPredefinedMessageResponseApplicationJson), )! as UserStatusUserStatusSetPredefinedMessageResponseApplicationJson; } - throw await UserStatusApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Set the message to a custom message for the current user @@ -481,7 +444,7 @@ class UserStatusUserStatusClient { specifiedType: const FullType(UserStatusUserStatusSetCustomMessageResponseApplicationJson), )! as UserStatusUserStatusSetCustomMessageResponseApplicationJson; } - throw await UserStatusApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Clear the message of the current user @@ -525,7 +488,7 @@ class UserStatusUserStatusClient { specifiedType: const FullType(UserStatusUserStatusClearMessageResponseApplicationJson), )! as UserStatusUserStatusClearMessageResponseApplicationJson; } - throw await UserStatusApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Revert the status to the previous status @@ -571,7 +534,7 @@ class UserStatusUserStatusClient { specifiedType: const FullType(UserStatusUserStatusRevertStatusResponseApplicationJson), )! as UserStatusUserStatusRevertStatusResponseApplicationJson; } - throw await UserStatusApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } diff --git a/packages/nextcloud/lib/src/api/weather_status.openapi.dart b/packages/nextcloud/lib/src/api/weather_status.openapi.dart index 86b0b8ac..5c328256 100644 --- a/packages/nextcloud/lib/src/api/weather_status.openapi.dart +++ b/packages/nextcloud/lib/src/api/weather_status.openapi.dart @@ -10,48 +10,11 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; -import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'weather_status.openapi.g.dart'; -class WeatherStatusResponse extends DynamiteResponse { - WeatherStatusResponse( - super.data, - super.headers, - ); - - @override - String toString() => 'WeatherStatusResponse(data: $data, headers: $headers)'; -} - -class WeatherStatusApiException extends DynamiteApiException { - WeatherStatusApiException( - super.statusCode, - super.headers, - super.body, - ); - - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return WeatherStatusApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - @override - String toString() => 'WeatherStatusApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - class WeatherStatusClient extends DynamiteClient { WeatherStatusClient( super.baseURL, { @@ -122,7 +85,7 @@ class WeatherStatusWeatherStatusClient { specifiedType: const FullType(WeatherStatusWeatherStatusSetModeResponseApplicationJson), )! as WeatherStatusWeatherStatusSetModeResponseApplicationJson; } - throw await WeatherStatusApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Try to use the address set in user personal settings as weather location @@ -166,7 +129,7 @@ class WeatherStatusWeatherStatusClient { specifiedType: const FullType(WeatherStatusWeatherStatusUsePersonalAddressResponseApplicationJson), )! as WeatherStatusWeatherStatusUsePersonalAddressResponseApplicationJson; } - throw await WeatherStatusApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get stored user location @@ -210,7 +173,7 @@ class WeatherStatusWeatherStatusClient { specifiedType: const FullType(WeatherStatusWeatherStatusGetLocationResponseApplicationJson), )! as WeatherStatusWeatherStatusGetLocationResponseApplicationJson; } - throw await WeatherStatusApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Set address and resolve it to get coordinates or directly set coordinates and get address with reverse geocoding @@ -266,7 +229,7 @@ class WeatherStatusWeatherStatusClient { specifiedType: const FullType(WeatherStatusWeatherStatusSetLocationResponseApplicationJson), )! as WeatherStatusWeatherStatusSetLocationResponseApplicationJson; } - throw await WeatherStatusApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get forecast for current location @@ -310,7 +273,7 @@ class WeatherStatusWeatherStatusClient { specifiedType: const FullType(WeatherStatusWeatherStatusGetForecastResponseApplicationJson), )! as WeatherStatusWeatherStatusGetForecastResponseApplicationJson; } - throw await WeatherStatusApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get favorites list @@ -354,7 +317,7 @@ class WeatherStatusWeatherStatusClient { specifiedType: const FullType(WeatherStatusWeatherStatusGetFavoritesResponseApplicationJson), )! as WeatherStatusWeatherStatusGetFavoritesResponseApplicationJson; } - throw await WeatherStatusApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Set favorites list @@ -400,7 +363,7 @@ class WeatherStatusWeatherStatusClient { specifiedType: const FullType(WeatherStatusWeatherStatusSetFavoritesResponseApplicationJson), )! as WeatherStatusWeatherStatusSetFavoritesResponseApplicationJson; } - throw await WeatherStatusApiException.fromResponse(response); // coverage:ignore-line + throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } diff --git a/packages/nextcloud/test/helper.dart b/packages/nextcloud/test/helper.dart index db2e0dd8..00f4cb75 100644 --- a/packages/nextcloud/test/helper.dart +++ b/packages/nextcloud/test/helper.dart @@ -141,7 +141,7 @@ Future getTestClient( try { await client.core.getStatus(); break; - } on CoreApiException catch (error) { + } on DynamiteApiException catch (error) { i++; await Future.delayed(const Duration(milliseconds: 100)); if (i >= 30) { From dd185cdd06c9204d9237e215f4be26ab12b937b4 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Sun, 24 Sep 2023 22:23:36 +0200 Subject: [PATCH 6/9] feat(dynamite,dynamite_runtime): generate DynamiteRawResponses for all endpoints Signed-off-by: Nikolas Rimikis --- .../dynamite/lib/src/builder/client.dart | 496 ++--- .../dynamite/lib/src/builder/imports.dart | 1 + .../lib/src/builder/resolve_mime_type.dart | 129 ++ .../dynamite/lib/src/builder/serializer.dart | 10 - .../dynamite_runtime/analysis_options.yaml | 4 - .../dynamite_runtime/lib/http_client.dart | 4 +- .../lib/src/dynamite_client.dart | 445 ++++ .../dynamite_runtime/lib/src/http_client.dart | 249 --- .../lib/src/http_extensions.dart | 43 + .../lib/src/api/comments.openapi.dart | 7 +- .../nextcloud/lib/src/api/core.openapi.dart | 1880 ++++++++++------ .../lib/src/api/dashboard.openapi.dart | 132 +- .../nextcloud/lib/src/api/dav.openapi.dart | 48 +- .../nextcloud/lib/src/api/files.openapi.dart | 531 +++-- .../lib/src/api/files_external.openapi.dart | 46 +- .../lib/src/api/files_reminders.openapi.dart | 136 +- .../lib/src/api/files_sharing.openapi.dart | 895 +++++--- .../lib/src/api/files_trashbin.openapi.dart | 47 +- .../lib/src/api/files_versions.openapi.dart | 47 +- .../nextcloud/lib/src/api/news.openapi.dart | 610 ++++-- .../nextcloud/lib/src/api/notes.openapi.dart | 272 ++- .../lib/src/api/notifications.openapi.dart | 444 ++-- .../lib/src/api/provisioning_api.openapi.dart | 1889 +++++++++++------ .../lib/src/api/settings.openapi.dart | 43 +- .../lib/src/api/sharebymail.openapi.dart | 7 +- .../lib/src/api/theming.openapi.dart | 426 ++-- .../src/api/updatenotification.openapi.dart | 51 +- .../nextcloud/lib/src/api/uppush.openapi.dart | 412 ++-- .../lib/src/api/user_status.openapi.dart | 403 ++-- .../lib/src/api/weather_status.openapi.dart | 277 ++- packages/nextcloud/lib/src/client.dart | 44 - .../nextcloud/lib/src/version_supported.dart | 4 +- packages/nextcloud/lib/src/webdav/client.dart | 6 +- packages/nextcloud/test/core_test.dart | 179 +- packages/nextcloud/test/dashboard_test.dart | 10 +- packages/nextcloud/test/news_test.dart | 259 ++- packages/nextcloud/test/notes_test.dart | 117 +- .../nextcloud/test/notifications_test.dart | 40 +- .../nextcloud/test/provisioning_api_test.dart | 36 +- packages/nextcloud/test/settings_test.dart | 5 +- packages/nextcloud/test/uppush_test.dart | 43 +- packages/nextcloud/test/user_status_test.dart | 165 +- 42 files changed, 7144 insertions(+), 3748 deletions(-) create mode 100644 packages/dynamite/dynamite/lib/src/builder/resolve_mime_type.dart create mode 100644 packages/dynamite/dynamite_runtime/lib/src/dynamite_client.dart delete mode 100644 packages/dynamite/dynamite_runtime/lib/src/http_client.dart create mode 100644 packages/dynamite/dynamite_runtime/lib/src/http_extensions.dart diff --git a/packages/dynamite/dynamite/lib/src/builder/client.dart b/packages/dynamite/dynamite/lib/src/builder/client.dart index ba62edac..d4f94276 100644 --- a/packages/dynamite/dynamite/lib/src/builder/client.dart +++ b/packages/dynamite/dynamite/lib/src/builder/client.dart @@ -1,6 +1,7 @@ import 'package:built_collection/built_collection.dart'; import 'package:code_builder/code_builder.dart'; import 'package:collection/collection.dart'; +import 'package:dynamite/src/builder/resolve_mime_type.dart'; import 'package:dynamite/src/builder/resolve_object.dart'; import 'package:dynamite/src/builder/resolve_type.dart'; import 'package:dynamite/src/builder/state.dart'; @@ -181,308 +182,245 @@ Iterable buildTags( for (final pathEntry in paths.entries) { for (final operationEntry in pathEntry.value.operations.entries) { - yield Method( - (final b) { - final httpMethod = operationEntry.key.name; - final operation = operationEntry.value; - final operationId = operation.operationId ?? toDartName('$httpMethod-${pathEntry.key}'); - final parameters = [ - ...?pathEntry.value.parameters, - ...?operation.parameters, - ]..sort(sortRequiredParameters); - b - ..name = toDartName(filterMethodName(operationId, tag ?? '')) - ..modifier = MethodModifier.async - ..docs.addAll(operation.formattedDescription); - if (operation.deprecated ?? false) { - b.annotations.add(refer('Deprecated').call([refer("''")])); - } - - var responses = >{}; - if (operation.responses != null) { - for (final responseEntry in operation.responses!.entries) { - final statusCode = int.parse(responseEntry.key); - final response = responseEntry.value; - - responses[response] ??= []; - responses[response]!.add(statusCode); - } - - if (responses.length > 1) { - print('$operationId uses more than one response schema but we only generate the first one'); - responses = Map.fromEntries([responses.entries.first]); - } - } + final httpMethod = operationEntry.key.name; + final operation = operationEntry.value; + final operationId = operation.operationId ?? toDartName('$httpMethod-${pathEntry.key}'); + final parameters = [ + ...?pathEntry.value.parameters, + ...?operation.parameters, + ]..sort(sortRequiredParameters); + final name = toDartName(filterMethodName(operationId, tag ?? '')); + + var responses = >{}; + if (operation.responses != null) { + for (final responseEntry in operation.responses!.entries) { + final statusCode = int.parse(responseEntry.key); + final response = responseEntry.value; + + responses[response] ??= []; + responses[response]!.add(statusCode); + } - final code = StringBuffer(); + if (responses.length > 1) { + print('$operationId uses more than one response schema but we only generate the first one'); + responses = Map.fromEntries([responses.entries.first]); + } + } - final acceptHeader = responses.keys - .map((final response) => response.content?.keys) - .whereNotNull() - .expand((final element) => element) - .toSet() - .join(','); + final code = StringBuffer(); + final acceptHeader = responses.keys + .map((final response) => response.content?.keys) + .whereNotNull() + .expand((final element) => element) + .toSet() + .join(','); - code.writeln(''' + code.writeln(''' var _path = '${pathEntry.key}'; final _queryParameters = {}; final _headers = {${acceptHeader.isNotEmpty ? "'Accept': '$acceptHeader'," : ''}}; Uint8List? _body; '''); - buildAuthCheck( - responses, - pathEntry, - operation, - spec, - client, - ).forEach(code.writeln); + buildAuthCheck( + responses, + pathEntry, + operation, + spec, + client, + ).forEach(code.writeln); + + final operationParameters = ListBuilder(); + final docs = operation.formattedDescription; + final annotations = operation.deprecated ?? false ? refer('Deprecated').call([refer("''")]) : null; + var returnDataType = 'void'; + var returnHeadersType = 'void'; + + for (final parameter in parameters) { + final dartParameterNullable = isDartParameterNullable( + parameter.required, + parameter.schema, + ); + + final result = resolveType( + spec, + state, + toDartName( + '$operationId-${parameter.name}', + uppercaseFirstCharacter: true, + ), + parameter.schema!, + nullable: dartParameterNullable, + ).dartType; + + buildPatternCheck(result, parameter).forEach(code.writeln); + + final defaultValueCode = parameter.schema?.$default != null + ? valueToEscapedValue(result, parameter.schema!.$default.toString()) + : null; + + operationParameters.add( + Parameter( + (final b) { + b + ..named = true + ..name = toDartName(parameter.name) + ..required = parameter.isDartRequired; + if (parameter.schema != null) { + b.type = refer(result.nullableName); + } + if (defaultValueCode != null) { + b.defaultTo = Code(defaultValueCode); + } + }, + ), + ); - for (final parameter in parameters) { - final dartParameterNullable = isDartParameterNullable( - parameter.required, - parameter.schema, + if (dartParameterNullable) { + code.writeln('if (${toDartName(parameter.name)} != null) {'); + } + final value = result.encode( + toDartName(parameter.name), + onlyChildren: result is TypeResultList && parameter.$in == 'query', + ); + if (defaultValueCode != null && parameter.$in == 'query') { + code.writeln('if (${toDartName(parameter.name)} != $defaultValueCode) {'); + } + switch (parameter.$in) { + case 'path': + code.writeln( + "_path = _path.replaceAll('{${parameter.name}}', Uri.encodeQueryComponent($value));", ); - - final result = resolveType( - spec, - state, - toDartName( - '$operationId-${parameter.name}', - uppercaseFirstCharacter: true, - ), - parameter.schema!, - nullable: dartParameterNullable, - ).dartType; - - buildPatternCheck(result, parameter).forEach(code.writeln); - - final defaultValueCode = parameter.schema?.$default != null - ? valueToEscapedValue(result, parameter.schema!.$default.toString()) - : null; - - b.optionalParameters.add( - Parameter( - (final b) { - b - ..named = true - ..name = toDartName(parameter.name) - ..required = parameter.isDartRequired; - if (parameter.schema != null) { - b.type = refer(result.nullableName); - } - if (defaultValueCode != null) { - b.defaultTo = Code(defaultValueCode); - } - }, - ), + case 'query': + code.writeln( + "_queryParameters['${parameter.name}'] = $value;", ); - - if (dartParameterNullable) { - code.write('if (${toDartName(parameter.name)} != null) {'); - } - final value = result.encode( - toDartName(parameter.name), - onlyChildren: result is TypeResultList && parameter.$in == 'query', + case 'header': + code.writeln( + "_headers['${parameter.name}'] = $value;", ); - if (defaultValueCode != null && parameter.$in == 'query') { - code.write('if (${toDartName(parameter.name)} != $defaultValueCode) {'); - } - switch (parameter.$in) { - case 'path': - code.write( - "_path = _path.replaceAll('{${parameter.name}}', Uri.encodeQueryComponent($value));", - ); - case 'query': - code.write( - "_queryParameters['${parameter.name}'] = $value;", - ); - case 'header': - code.write( - "_headers['${parameter.name}'] = $value;", - ); - default: - throw Exception('Can not work with parameter in "${parameter.$in}"'); - } - if (defaultValueCode != null && parameter.$in == 'query') { - code.write('}'); - } - if (dartParameterNullable) { - code.write('}'); - } - } + default: + throw Exception('Can not work with parameter in "${parameter.$in}"'); + } + if (defaultValueCode != null && parameter.$in == 'query') { + code.writeln('}'); + } + if (dartParameterNullable) { + code.writeln('}'); + } + } + resolveMimeTypeEncode(operation, spec, state, operationId, operationParameters).forEach(code.writeln); - if (operation.requestBody != null) { - if (operation.requestBody!.content!.length > 1) { - throw Exception('Can not work with multiple mime types right now'); - } - for (final content in operation.requestBody!.content!.entries) { - final mimeType = content.key; - final mediaType = content.value; - - code.write("_headers['Content-Type'] = '$mimeType';"); - - final dartParameterNullable = isDartParameterNullable( - operation.requestBody!.required, - mediaType.schema, - ); - - final result = resolveType( - spec, - state, - toDartName('$operationId-request-$mimeType', uppercaseFirstCharacter: true), - mediaType.schema!, - nullable: dartParameterNullable, - ); - final parameterName = toDartName(result.name.replaceFirst(state.classPrefix, '')); - switch (mimeType) { - case 'application/json': - case 'application/x-www-form-urlencoded': - final dartParameterRequired = isRequired( - operation.requestBody!.required, - mediaType.schema?.$default, - ); - b.optionalParameters.add( - Parameter( - (final b) => b - ..name = parameterName - ..type = refer(result.nullableName) - ..named = true - ..required = dartParameterRequired, - ), - ); - - if (dartParameterNullable) { - code.write('if ($parameterName != null) {'); - } - code.write( - '_body = utf8.encode(${result.encode(parameterName, mimeType: mimeType)}) as Uint8List;', - ); - if (dartParameterNullable) { - code.write('}'); - } - default: - throw Exception('Can not parse mime type "$mimeType"'); - } - } - } + for (final responseEntry in responses.entries) { + final response = responseEntry.key; + final statusCodes = responseEntry.value; - code.write( - ''' -final _response = await $client.doRequest( - '$httpMethod', - Uri(path: _path, queryParameters: _queryParameters.isNotEmpty ? _queryParameters : null), - _headers, - _body, -); -''', + TypeResult? headersType; + if (response.headers != null) { + final identifier = + '${tag != null ? toDartName(tag, uppercaseFirstCharacter: true) : null}${toDartName(operationId, uppercaseFirstCharacter: true)}Headers'; + headersType = resolveObject( + spec, + state, + identifier, + openapi.Schema( + (final b) => b + ..properties.replace( + response.headers!.map( + (final headerName, final value) => MapEntry( + headerName.toLowerCase(), + value.schema!, + ), + ), + ), + ), + isHeader: true, ); + } - for (final responseEntry in responses.entries) { - final response = responseEntry.key; - final statusCodes = responseEntry.value; - code.write( - 'if (${statusCodes.map((final statusCode) => '_response.statusCode == $statusCode').join(' || ')}) {', - ); + final dataType = resolveMimeTypeDecode( + response, + spec, + state, + toDartName( + '$operationId-response${responses.entries.length > 1 ? '-${responses.entries.toList().indexOf(responseEntry)}' : ''}', + uppercaseFirstCharacter: true, + ), + ); + + code.writeln( + 'final _uri = Uri(path: _path, queryParameters: _queryParameters.isNotEmpty ? _queryParameters : null);', + ); + + if (dataType != null) { + returnDataType = dataType.name; + } + if (headersType != null) { + returnHeadersType = headersType.name; + } - String? headersType; - String? headersValue; - if (response.headers != null) { - final identifier = - '${tag != null ? toDartName(tag, uppercaseFirstCharacter: true) : null}${toDartName(operationId, uppercaseFirstCharacter: true)}Headers'; - final result = resolveObject( - spec, - state, - identifier, - openapi.Schema( - (final b) => b - ..properties.replace( - response.headers!.map( - (final headerName, final value) => MapEntry( - headerName.toLowerCase(), - value.schema!, - ), - ), - ), - ), - isHeader: true, - ); - headersType = result.name; - headersValue = result.deserialize('_response.responseHeaders'); - } + code.writeln(''' + return DynamiteRawResponse<$returnDataType, $returnHeadersType>( + response: $client.doRequest( + '$httpMethod', + _uri, + _headers, + _body, +'''); + + if (responses.values.isNotEmpty) { + final codes = statusCodes.join(','); + code.writeln('const {$codes},'); + } - String? dataType; - String? dataValue; - bool? dataNeedsAwait; - if (response.content != null) { - if (response.content!.length > 1) { - throw Exception('Can not work with multiple mime types right now'); - } - for (final content in response.content!.entries) { - final mimeType = content.key; - final mediaType = content.value; - - final result = resolveType( - spec, - state, - toDartName( - '$operationId-response${responses.entries.length > 1 ? '-${responses.entries.toList().indexOf(responseEntry)}' : ''}-$mimeType', - uppercaseFirstCharacter: true, - ), - mediaType.schema!, - ); - - if (mimeType == '*/*' || mimeType == 'application/octet-stream' || mimeType.startsWith('image/')) { - dataType = 'Uint8List'; - dataValue = '_response.bodyBytes'; - dataNeedsAwait = true; - } else if (mimeType.startsWith('text/') || mimeType == 'application/javascript') { - dataType = 'String'; - dataValue = '_response.body'; - dataNeedsAwait = true; - } else if (mimeType == 'application/json') { - dataType = result.name; - if (result.name == 'dynamic') { - dataValue = ''; - } else if (result.name == 'String') { - dataValue = '_response.body'; - dataNeedsAwait = true; - } else if (result is TypeResultEnum || result is TypeResultBase) { - dataValue = result.deserialize(result.decode('await _response.body')); - dataNeedsAwait = false; - } else { - dataValue = result.deserialize('await _response.jsonBody'); - dataNeedsAwait = false; - } - } else { - throw Exception('Can not parse mime type "$mimeType"'); - } - } - } + code.writeln(''' + ), + bodyType: ${dataType?.fullType}, + headersType: ${headersType?.fullType}, + serializers: _jsonSerializers, + ); +'''); + } - if (headersType != null && dataType != null) { - b.returns = refer('Future>'); - code.write( - 'return DynamiteResponse<$dataType, $headersType>(${dataNeedsAwait ?? false ? 'await ' : ''}$dataValue, $headersValue,);', - ); - } else if (headersType != null) { - b.returns = refer('Future<$headersType>'); - code.write('return $headersValue;'); - } else if (dataType != null) { - b.returns = refer('Future<$dataType>'); - code.write('return $dataValue;'); - } else { - b.returns = refer('Future'); - code.write('return;'); - } + yield Method((final b) { + b + ..name = name + ..modifier = MethodModifier.async + ..docs.addAll(docs); + + if (annotations != null) { + b.annotations.add(annotations); + } - code.write('}'); + final parameters = operationParameters.build(); + final rawParameters = parameters.map((final p) => '${p.name}: ${p.name},').join('\n'); + + b + ..optionalParameters.addAll(parameters) + ..returns = refer('Future>') + ..body = Code(''' +final rawResponse = ${name}Raw( + $rawParameters +); + +return rawResponse.future; +'''); + }); + + yield Method( + (final b) { + b + ..name = '${name}Raw' + ..docs.addAll(docs); + + if (annotations != null) { + b.annotations.add(annotations); } - code.write( - 'throw await DynamiteApiException.fromResponse(_response); // coverage:ignore-line\n', - ); - b.body = Code(code.toString()); + b + ..optionalParameters.addAll(operationParameters.build()) + ..returns = refer('DynamiteRawResponse<$returnDataType, $returnHeadersType>') + ..body = Code(code.toString()); }, ); } diff --git a/packages/dynamite/dynamite/lib/src/builder/imports.dart b/packages/dynamite/dynamite/lib/src/builder/imports.dart index 97c25371..b30990f8 100644 --- a/packages/dynamite/dynamite/lib/src/builder/imports.dart +++ b/packages/dynamite/dynamite/lib/src/builder/imports.dart @@ -4,6 +4,7 @@ import 'package:path/path.dart' as p; List generateImports(final AssetId outputId) => [ const Code('// ignore_for_file: camel_case_types'), + const Code('// ignore_for_file: discarded_futures'), const Code('// ignore_for_file: public_member_api_docs'), const Code('// ignore_for_file: unreachable_switch_case'), Directive.import('dart:convert'), diff --git a/packages/dynamite/dynamite/lib/src/builder/resolve_mime_type.dart b/packages/dynamite/dynamite/lib/src/builder/resolve_mime_type.dart new file mode 100644 index 00000000..36d38222 --- /dev/null +++ b/packages/dynamite/dynamite/lib/src/builder/resolve_mime_type.dart @@ -0,0 +1,129 @@ +import 'package:built_collection/built_collection.dart'; +import 'package:code_builder/code_builder.dart'; +import 'package:dynamite/src/builder/resolve_type.dart'; +import 'package:dynamite/src/builder/state.dart'; +import 'package:dynamite/src/helpers/dart_helpers.dart'; +import 'package:dynamite/src/helpers/dynamite.dart'; +import 'package:dynamite/src/models/openapi.dart' as openapi; +import 'package:dynamite/src/models/type_result.dart'; + +TypeResult? resolveMimeTypeDecode( + final openapi.Response response, + final openapi.OpenAPI spec, + final State state, + final String identifier, +) { + if (response.content != null) { + if (response.content!.length > 1) { + throw Exception('Can not work with multiple mime types right now'); + } + + for (final content in response.content!.entries) { + final mimeType = content.key; + final mediaType = content.value; + + final result = resolveType( + spec, + state, + toDartName('$identifier-$mimeType', uppercaseFirstCharacter: true), + mediaType.schema!, + ); + + if (mimeType == '*/*' || mimeType == 'application/octet-stream' || mimeType.startsWith('image/')) { + return TypeResultObject('Uint8List'); + } else if (mimeType.startsWith('text/') || mimeType == 'application/javascript') { + return TypeResultBase('String'); + } else if (mimeType == 'application/json') { + return result; + } else { + throw Exception('Can not parse mime type "$mimeType"'); + } + } + } + return null; +} + +Iterable resolveMimeTypeEncode( + final openapi.Operation operation, + final openapi.OpenAPI spec, + final State state, + final String identifier, + final ListBuilder b, +) sync* { + if (operation.requestBody != null) { + if (operation.requestBody!.content!.length > 1) { + throw Exception('Can not work with multiple mime types right now'); + } + for (final content in operation.requestBody!.content!.entries) { + final mimeType = content.key; + final mediaType = content.value; + + yield "_headers['Content-Type'] = '$mimeType';"; + + final dartParameterNullable = isDartParameterNullable( + operation.requestBody!.required, + mediaType.schema, + ); + + final result = resolveType( + spec, + state, + toDartName('$identifier-request-$mimeType', uppercaseFirstCharacter: true), + mediaType.schema!, + nullable: dartParameterNullable, + ); + final parameterName = toDartName(result.name.replaceFirst(state.classPrefix, '')); + switch (mimeType) { + case 'application/json': + case 'application/x-www-form-urlencoded': + final dartParameterRequired = isRequired( + operation.requestBody!.required, + mediaType.schema?.$default, + ); + b.add( + Parameter( + (final b) => b + ..name = parameterName + ..type = refer(result.nullableName) + ..named = true + ..required = dartParameterRequired, + ), + ); + + if (dartParameterNullable) { + yield 'if ($parameterName != null) {'; + } + yield '_body = utf8.encode(${result.encode(parameterName, mimeType: mimeType)}) as Uint8List;'; + if (dartParameterNullable) { + yield '}'; + } + return; + case 'application/octet-stream': + final dartParameterRequired = isRequired( + operation.requestBody!.required, + mediaType.schema?.$default, + ); + b.add( + Parameter( + (final b) => b + ..name = parameterName + ..type = refer(result.nullableName) + ..named = true + ..required = dartParameterRequired, + ), + ); + + if (dartParameterNullable) { + yield 'if ($parameterName != null) {'; + } + yield '_body = ${result.encode(parameterName, mimeType: mimeType)};'; + if (dartParameterNullable) { + yield '}'; + } + return; + default: + throw Exception('Can not parse mime type "$mimeType"'); + } + } + } +} diff --git a/packages/dynamite/dynamite/lib/src/builder/serializer.dart b/packages/dynamite/dynamite/lib/src/builder/serializer.dart index bbd4d7ed..97e8b49e 100644 --- a/packages/dynamite/dynamite/lib/src/builder/serializer.dart +++ b/packages/dynamite/dynamite/lib/src/builder/serializer.dart @@ -13,19 +13,9 @@ List buildSerializer(final State state) { .map(Code.new), const Code(').build();'), const Code(''), - Code('Serializers get ${state.variablePrefix}Serializers => _serializers;'), - const Code(''), const Code( 'final Serializers _jsonSerializers = (_serializers.toBuilder()..addPlugin(StandardJsonPlugin())..addPlugin(const ContentStringPlugin())).build();', ), - const Code(''), - Code( - 'T deserialize${state.classPrefix}(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;', - ), - const Code(''), - Code( - 'Object? serialize${state.classPrefix}(final T data) => _serializers.serialize(data, specifiedType: FullType(T));', - ), const Code('// coverage:ignore-end'), ]; } diff --git a/packages/dynamite/dynamite_runtime/analysis_options.yaml b/packages/dynamite/dynamite_runtime/analysis_options.yaml index 80216cb3..447af2a6 100644 --- a/packages/dynamite/dynamite_runtime/analysis_options.yaml +++ b/packages/dynamite/dynamite_runtime/analysis_options.yaml @@ -1,9 +1,5 @@ include: package:neon_lints/dart.yaml -linter: - rules: - public_member_api_docs: false - analyzer: exclude: - '**.g.dart' diff --git a/packages/dynamite/dynamite_runtime/lib/http_client.dart b/packages/dynamite/dynamite_runtime/lib/http_client.dart index 1550b0eb..13962b5d 100644 --- a/packages/dynamite/dynamite_runtime/lib/http_client.dart +++ b/packages/dynamite/dynamite_runtime/lib/http_client.dart @@ -1 +1,3 @@ -export 'src/http_client.dart'; +export 'package:cookie_jar/cookie_jar.dart'; +export 'src/dynamite_client.dart'; +export 'src/http_extensions.dart'; diff --git a/packages/dynamite/dynamite_runtime/lib/src/dynamite_client.dart b/packages/dynamite/dynamite_runtime/lib/src/dynamite_client.dart new file mode 100644 index 00000000..b241426a --- /dev/null +++ b/packages/dynamite/dynamite_runtime/lib/src/dynamite_client.dart @@ -0,0 +1,445 @@ +import 'dart:async'; +import 'dart:convert'; +import 'dart:typed_data'; + +import 'package:built_value/serializer.dart'; +import 'package:cookie_jar/cookie_jar.dart'; +import 'package:dynamite_runtime/src/http_extensions.dart'; +import 'package:dynamite_runtime/src/uri.dart'; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; + +/// Response returned by operations of a [DynamiteClient]. +/// +/// See: +/// * [DynamiteRawResponse] for an experimental implementation that can be serialized. +/// * [DynamiteApiException] as the exception that can be thrown in operations +/// * [DynamiteAuthentication] for providing authentication methods. +/// * [DynamiteClient] for the client providing operations. +@immutable +class DynamiteResponse { + /// Creates a new dynamite response. + const DynamiteResponse( + this.statusCode, + this._body, + this._headers, + ); + + /// The status code of the response. + final int statusCode; + + final B? _body; + + final H? _headers; + + /// The decoded body of the response. + B get body => _body!; + + /// The decoded headers of the response. + H get headers => _headers!; + + @override + String toString() => 'DynamiteResponse(data: $body, headers: $headers, statusCode: $statusCode)'; +} + +/// Raw response returned by operations of a [DynamiteClient]. +/// +/// This type itself is serializable. +/// +/// The api of this type might change without a major bump. +/// Use methods that return a [DynamiteResponse] instead. +/// +/// See: +/// * [DynamiteResponse] as the response returned by an operation. +/// * [DynamiteApiException] as the exception that can be thrown in operations +/// * [DynamiteAuthentication] for providing authentication methods. +/// * [DynamiteClient] for the client providing operations. +@experimental +class DynamiteRawResponse { + /// Creates a new raw dynamite response. + /// + /// The [response] will be awaited and deserialized. + /// After [future] completes the deserialized response can be accessed + /// through [response]. + DynamiteRawResponse({ + required final Future response, + required this.bodyType, + required this.headersType, + required this.serializers, + }) { + final completer = Completer>(); + future = completer.future; + + // ignore: discarded_futures + response.then( + (final response) async { + _rawBody = switch (bodyType) { + const FullType(Uint8List) => await response.bytes, + const FullType(String) => await response.string, + _ => await response.json, + }; + _rawHeaders = response.responseHeaders; + + final body = deserializeBody(_rawBody, serializers, bodyType); + final headers = deserializeHeaders(_rawHeaders, serializers, headersType); + + _response = DynamiteResponse( + response.statusCode, + body, + headers, + ); + + completer.complete(_response); + }, + onError: completer.completeError, + ); + } + + /// Decodes a raw dynamite response from json data. + /// + /// The [future] must not be awaited and the deserialized response can be + /// accessed immediately through [response]. + factory DynamiteRawResponse.fromJson( + final Map json, { + required final Serializers serializers, + final FullType? bodyType, + final FullType? headersType, + }) { + final statusCode = json['statusCode']! as int; + final body = deserializeBody(json['body'], serializers, bodyType); + final headers = deserializeHeaders(json['headers'], serializers, headersType); + + final response = DynamiteResponse( + statusCode, + body, + headers, + ); + + return DynamiteRawResponse._fromJson( + response, + bodyType: bodyType, + headersType: headersType, + serializers: serializers, + ); + } + + DynamiteRawResponse._fromJson( + this._response, { + required this.bodyType, + required this.headersType, + required this.serializers, + }) : future = Future.value(_response); + + /// The serializers for the header and body. + final Serializers serializers; + + /// The full type of the body. + /// + /// This is `null` if the body type is void. + final FullType? bodyType; + + /// The full type of the headers. + /// + /// This is `null` if the headers type is void. + final FullType? headersType; + + /// Future of the deserialized response. + /// + /// After this future completes the response can be accessed synchronously + /// through [response]. + late final Future> future; + + /// Caches the serialized response body for later serialization in [toJson]. + /// + /// Responses revived with [DynamiteRawResponse.fromJson] are not cached as + /// they are not expected to be serialized again. + Object? _rawBody; + + /// Caches the serialized response headers for later serialization in [toJson]. + /// + /// Responses revived with [DynamiteRawResponse.fromJson] are not cached as + /// they are not expected to be serialized again. + Map? _rawHeaders; + + DynamiteResponse? _response; + + /// Returns the deserialized response synchronously. + /// + /// Throws a `StateError` if [future] has not completed yet and `this` has + /// not been instantiated through [DynamiteRawResponse.fromJson]. + DynamiteResponse get response { + final response = _response; + + if (response == null) { + throw StateError('The response did not finish yet. Make sure to await `this.future`.'); + } + + return response; + } + + /// Deserializes the body. + /// + /// Most efficient if the [serialized] value is already the correct type. + /// The [bodyType] should represent the return type [B]. + static B? deserializeBody(final Object? serialized, final Serializers serializers, final FullType? bodyType) { + // If we use the more efficient helpers from BytesStreamExtension the serialized value can already be correct. + if (serialized is B) { + return serialized; + } + + if (bodyType != null) { + return serializers.deserialize(serialized, specifiedType: bodyType) as B?; + } + + return null; + } + + /// Serializes the body. + Object? serializeBody(final B? object) { + if (bodyType != null && object != null) { + return serializers.serialize(object, specifiedType: bodyType!); + } + + return null; + } + + /// Deserializes the headers. + /// + /// Most efficient if the [serialized] value is already the correct type. + /// The [headersType] should represent the return type [H]. + static H? deserializeHeaders( + final Object? serialized, + final Serializers serializers, + final FullType? headersType, + ) { + // If we use the more efficient helpers from BytesStreamExtension the serialized value can already be correct. + if (serialized is H) { + return serialized; + } + + if (headersType != null) { + return serializers.deserialize(serialized, specifiedType: headersType) as H?; + } + + return null; + } + + /// Serializes the headers. + Object? serializeHeaders(final H? object) { + if (headersType != null && object != null) { + return serializers.serialize(object, specifiedType: headersType!); + } + + return null; + } + + /// Serializes this response into json. + /// + /// To revive it again use [DynamiteRawResponse.fromJson] with the same + /// serializer and `FullType`s as this. + Map toJson() => { + 'statusCode': response.statusCode, + 'body': _rawBody ?? serializeBody(response._body), + 'headers': _rawHeaders ?? serializeHeaders(response._headers), + }; + + @override + String toString() => 'DynamiteResponse(${toJson()})'; +} + +/// The exception thrown by operations of a [DynamiteClient]. +/// +/// +/// See: +/// * [DynamiteResponse] as the response returned by an operation. +/// * [DynamiteRawResponse] as the raw response that can be serialized. +/// * [DynamiteAuthentication] for providing authentication methods. +/// * [DynamiteClient] for the client providing operations. +@immutable +class DynamiteApiException implements Exception { + /// Creates a new dynamite exception with the given information. + const DynamiteApiException( + this.statusCode, + this.headers, + this.body, + ); + + /// Creates a new Exception from the given [response]. + /// + /// Tries to decode the `response` into a string. + static Future fromResponse(final HttpClientResponse response) async { + String body; + try { + body = await response.string; + } on FormatException { + body = 'binary'; + } + + return DynamiteApiException( + response.statusCode, + response.responseHeaders, + body, + ); + } + + /// The returned status code when the exception was thrown. + final int statusCode; + + /// The returned headers when the exception was thrown. + final Map headers; + + /// The returned body code when the exception was thrown. + final String body; + + @override + String toString() => 'DynamiteApiException(statusCode: $statusCode, headers: $headers, body: $body)'; +} + +/// Base dynamite authentication. +/// +/// See: +/// * [DynamiteResponse] as the response returned by an operation. +/// * [DynamiteRawResponse] as the raw response that can be serialized. +/// * [DynamiteApiException] as the exception that can be thrown in operations +/// * [DynamiteClient] for the client providing operations. +@immutable +sealed class DynamiteAuthentication { + /// Creates a new authentication. + const DynamiteAuthentication({ + required this.type, + required this.scheme, + }); + + /// The base type of the authentication. + final String type; + + /// The used authentication scheme. + final String scheme; + + /// The authentication headers added to a request. + Map get headers; +} + +/// Basic http authentication with username and password. +class DynamiteHttpBasicAuthentication extends DynamiteAuthentication { + /// Creates a new http basic authentication. + const DynamiteHttpBasicAuthentication({ + required this.username, + required this.password, + }) : super( + type: 'http', + scheme: 'basic', + ); + + /// The username. + final String username; + + /// The password. + final String password; + + @override + Map get headers => { + 'Authorization': 'Basic ${base64.encode(utf8.encode('$username:$password'))}', + }; +} + +/// Http bearer authentication with a token. +class DynamiteHttpBearerAuthentication extends DynamiteAuthentication { + /// Creates a new http bearer authentication. + const DynamiteHttpBearerAuthentication({ + required this.token, + }) : super( + type: 'http', + scheme: 'bearer', + ); + + /// The authentication token. + final String token; + + @override + Map get headers => { + 'Authorization': 'Bearer $token', + }; +} + +/// A client for making network requests. +/// +/// See: +/// * [DynamiteResponse] as the response returned by an operation. +/// * [DynamiteRawResponse] as the raw response that can be serialized. +/// * [DynamiteApiException] as the exception that can be thrown in operations +/// * [DynamiteAuthentication] for providing authentication methods. +class DynamiteClient { + /// Creates a new dynamite network client. + /// + /// If [httpClient] is not provided a default one will be created. + /// The [baseURL] will be normalized, removing any trailing `/`. + DynamiteClient( + final Uri baseURL, { + this.baseHeaders, + final String? userAgent, + final HttpClient? httpClient, + this.cookieJar, + this.authentications = const [], + }) : httpClient = (httpClient ?? HttpClient())..userAgent = userAgent, + baseURL = baseURL.normalizeEmptyPath(); + + /// The base server url used to build the request uri. + /// + /// See `https://swagger.io/docs/specification/api-host-and-base-path` for + /// further information. + final Uri baseURL; + + /// The base headers added to each request. + final Map? baseHeaders; + + /// The base http client. + final HttpClient httpClient; + + /// The optional cookie jar to persist the response cookies. + final CookieJar? cookieJar; + + /// The available authentications for this client. + /// + /// The first one matching the required authentication type will be used. + final List authentications; + + /// Makes a request against a given [path]. + Future doRequest( + final String method, + final Uri path, + final Map headers, + final Uint8List? body, + final Set? validStatuses, + ) async { + final uri = baseURL.replace( + path: '${baseURL.path}${path.path}', + queryParameters: { + ...baseURL.queryParameters, + ...path.queryParameters, + }, + ); + + final request = await httpClient.openUrl(method, uri); + for (final header in {...?baseHeaders, ...headers}.entries) { + request.headers.add(header.key, header.value); + } + if (body != null) { + request.add(body); + } + if (cookieJar != null) { + request.cookies.addAll(await cookieJar!.loadForRequest(uri)); + } + + final response = await request.close(); + if (cookieJar != null) { + await cookieJar!.saveFromResponse(uri, response.cookies); + } + + if (validStatuses?.contains(response.statusCode) ?? true) { + return response; + } else { + throw await DynamiteApiException.fromResponse(response); + } + } +} diff --git a/packages/dynamite/dynamite_runtime/lib/src/http_client.dart b/packages/dynamite/dynamite_runtime/lib/src/http_client.dart deleted file mode 100644 index d1a4f4b2..00000000 --- a/packages/dynamite/dynamite_runtime/lib/src/http_client.dart +++ /dev/null @@ -1,249 +0,0 @@ -import 'dart:async'; -import 'dart:convert'; -import 'dart:typed_data'; - -import 'package:cookie_jar/cookie_jar.dart'; -import 'package:dynamite_runtime/src/uri.dart'; -import 'package:meta/meta.dart'; -import 'package:universal_io/io.dart'; - -export 'package:cookie_jar/cookie_jar.dart'; - -extension DynamiteHttpClientResponseBody on HttpClientResponse { - Future get bodyBytes async { - final buffer = BytesBuilder(); - - await forEach(buffer.add); - - return buffer.toBytes(); - } - - Future get body => transform(utf8.decoder).join(); - - Future get jsonBody => transform(utf8.decoder).transform(json.decoder).first; - - Map get responseHeaders { - final responseHeaders = {}; - headers.forEach((final name, final values) { - responseHeaders[name] = values.last; - }); - - return responseHeaders; - } -} - -/// Response returned by operations of a [DynamiteClient]. -/// -/// See: -/// * [DynamiteApiException] as the exception that can be thrown in operations -/// * [DynamiteAuthentication] for providing authentication methods. -/// * [DynamiteClient] for the client providing operations. -class DynamiteResponse { - /// Creates a new dynamite response. - const DynamiteResponse( - this.statusCode, - this.body, - this.headers, - ); - - /// The status code of the response. - final int statusCode; - - /// The decoded body of the response. - final B body; - - /// The decoded headers of the response. - final H headers; - - @override - String toString() => 'DynamiteResponse(data: $body, headers: $headers, statusCode: $statusCode)'; -} - -/// The exception thrown by operations of a [DynamiteClient]. -/// -/// -/// See: -/// * [DynamiteResponse] as the response returned by an operation. -/// * [DynamiteAuthentication] for providing authentication methods. -/// * [DynamiteClient] for the client providing operations. -@immutable -class DynamiteApiException implements Exception { - /// Creates a new dynamite exception with the given information. - const DynamiteApiException( - this.statusCode, - this.headers, - this.body, - ); - - /// Creates a new Exception from the given [response]. - /// - /// Tries to decode the `response` into a string. - static Future fromResponse(final HttpClientResponse response) async { - String body; - try { - body = await response.body; - } on FormatException { - body = 'binary'; - } - - return DynamiteApiException( - response.statusCode, - response.responseHeaders, - body, - ); - } - - /// The returned status code when the exception was thrown. - final int statusCode; - - /// The returned headers when the exception was thrown. - final Map headers; - - /// The returned body code when the exception was thrown. - final String body; - - @override - String toString() => 'DynamiteApiException(statusCode: $statusCode, headers: $headers, body: $body)'; -} - -/// Base dynamite authentication. -/// -/// See: -/// * [DynamiteResponse] as the response returned by an operation. -/// * [DynamiteApiException] as the exception that can be thrown in operations -/// * [DynamiteClient] for the client providing operations. -@immutable -sealed class DynamiteAuthentication { - /// Creates a new authentication. - const DynamiteAuthentication({ - required this.type, - required this.scheme, - }); - - /// The base type of the authentication. - final String type; - - /// The used authentication scheme. - final String scheme; - - /// The authentication headers added to a request. - Map get headers; -} - -/// Basic http authentication with username and password. -class DynamiteHttpBasicAuthentication extends DynamiteAuthentication { - /// Creates a new http basic authentication. - const DynamiteHttpBasicAuthentication({ - required this.username, - required this.password, - }) : super( - type: 'http', - scheme: 'basic', - ); - - /// The username. - final String username; - - /// The password. - final String password; - - @override - Map get headers => { - 'Authorization': 'Basic ${base64.encode(utf8.encode('$username:$password'))}', - }; -} - -/// Http bearer authentication with a token. -class DynamiteHttpBearerAuthentication extends DynamiteAuthentication { - /// Creates a new http bearer authentication. - const DynamiteHttpBearerAuthentication({ - required this.token, - }) : super( - type: 'http', - scheme: 'bearer', - ); - - /// The authentication token. - final String token; - - @override - Map get headers => { - 'Authorization': 'Bearer $token', - }; -} - -/// A client for making network requests. -/// -/// See: -/// * [DynamiteResponse] as the response returned by an operation. -/// * [DynamiteApiException] as the exception that can be thrown in operations -/// * [DynamiteAuthentication] for providing authentication methods. -class DynamiteClient { - /// Creates a new dynamite network client. - /// - /// If [httpClient] is not provided a default one will be created. - /// The [baseURL] will be normalized, removing any trailing `/`. - DynamiteClient( - final Uri baseURL, { - this.baseHeaders, - final String? userAgent, - final HttpClient? httpClient, - this.cookieJar, - this.authentications = const [], - }) : httpClient = (httpClient ?? HttpClient())..userAgent = userAgent, - baseURL = baseURL.normalizeEmptyPath(); - - /// The base server url used to build the request uri. - /// - /// See `https://swagger.io/docs/specification/api-host-and-base-path` for - /// further information. - final Uri baseURL; - - /// The base headers added to each request. - final Map? baseHeaders; - - /// The base http client. - final HttpClient httpClient; - - /// The optional cookie jar to persist the response cookies. - final CookieJar? cookieJar; - - /// The available authentications for this client. - /// - /// The first one matching the required authentication type will be used. - final List authentications; - - /// Makes a request against a given [path]. - Future doRequest( - final String method, - final Uri path, - final Map headers, - final Uint8List? body, - ) async { - final uri = baseURL.replace( - path: '${baseURL.path}${path.path}', - queryParameters: { - ...baseURL.queryParameters, - ...path.queryParameters, - }, - ); - - final request = await httpClient.openUrl(method, uri); - for (final header in {...?baseHeaders, ...headers}.entries) { - request.headers.add(header.key, header.value); - } - if (body != null) { - request.add(body); - } - if (cookieJar != null) { - request.cookies.addAll(await cookieJar!.loadForRequest(uri)); - } - - final response = await request.close(); - if (cookieJar != null) { - await cookieJar!.saveFromResponse(uri, response.cookies); - } - - return response; - } -} diff --git a/packages/dynamite/dynamite_runtime/lib/src/http_extensions.dart b/packages/dynamite/dynamite_runtime/lib/src/http_extensions.dart new file mode 100644 index 00000000..005a80aa --- /dev/null +++ b/packages/dynamite/dynamite_runtime/lib/src/http_extensions.dart @@ -0,0 +1,43 @@ +import 'dart:async'; +import 'dart:convert'; +import 'dart:typed_data'; + +import 'package:universal_io/io.dart'; + +/// A stream of bytes. +/// +/// Usually a `Stream`. +typedef BytesStream = Stream>; + +final _utf8JsonDecoder = utf8.decoder.fuse(json.decoder); + +/// Extension on byte streams that enable efficient transformations. +extension BytesStreamExtension on BytesStream { + /// Returns the all bytes of the stream. + Future get bytes async { + final buffer = BytesBuilder(); + + await forEach(buffer.add); + + return buffer.toBytes(); + } + + /// Converts the stream into a `String` using the [utf8] encoding. + Future get string => transform(utf8.decoder).join(); + + /// Converts the stream into a JSON using the [utf8] encoding. + Future get json => transform(_utf8JsonDecoder).first; +} + +/// Extension on a http responses. +extension HttpClientResponseExtension on HttpClientResponse { + /// Returns a map of headers. + Map get responseHeaders { + final responseHeaders = {}; + headers.forEach((final name, final values) { + responseHeaders[name] = values.last; + }); + + return responseHeaders; + } +} diff --git a/packages/nextcloud/lib/src/api/comments.openapi.dart b/packages/nextcloud/lib/src/api/comments.openapi.dart index a37ddc5a..5200840f 100644 --- a/packages/nextcloud/lib/src/api/comments.openapi.dart +++ b/packages/nextcloud/lib/src/api/comments.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case @@ -97,14 +98,8 @@ final Serializers _serializers = (Serializers().toBuilder() ..add(CommentsCapabilities_Files.serializer)) .build(); -Serializers get commentsSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeComments(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeComments(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/api/core.openapi.dart b/packages/nextcloud/lib/src/api/core.openapi.dart index 4d2c581b..69cdd73f 100644 --- a/packages/nextcloud/lib/src/api/core.openapi.dart +++ b/packages/nextcloud/lib/src/api/core.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case import 'dart:convert'; @@ -74,7 +75,13 @@ class CoreClient extends DynamiteClient { CoreWipeClient get wipe => CoreWipeClient(this); - Future getStatus() async { + Future> getStatus() async { + final rawResponse = getStatusRaw(); + + return rawResponse.future; + } + + DynamiteRawResponse getStatusRaw() { const path = '/status.php'; final queryParameters = {}; final headers = { @@ -82,17 +89,19 @@ class CoreClient extends DynamiteClient { }; Uint8List? body; - final response = await doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreStatus), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(CoreStatus))! - as CoreStatus; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -102,7 +111,20 @@ class CoreAppPasswordClient { final CoreClient _rootClient; /// Create app password - Future getAppPassword({final bool oCSAPIRequest = true}) async { + Future> getAppPassword({ + final bool oCSAPIRequest = true, + }) async { + final rawResponse = getAppPasswordRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Create app password + DynamiteRawResponse getAppPasswordRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/core/getapppassword'; final queryParameters = {}; final headers = { @@ -128,25 +150,36 @@ class CoreAppPasswordClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreAppPasswordGetAppPasswordResponseApplicationJson), - )! as CoreAppPasswordGetAppPasswordResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreAppPasswordGetAppPasswordResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Rotate app password - Future rotateAppPassword({ + Future> rotateAppPassword({ final bool oCSAPIRequest = true, }) async { + final rawResponse = rotateAppPasswordRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Rotate app password + DynamiteRawResponse rotateAppPasswordRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/core/apppassword/rotate'; final queryParameters = {}; final headers = { @@ -172,25 +205,36 @@ class CoreAppPasswordClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreAppPasswordRotateAppPasswordResponseApplicationJson), - )! as CoreAppPasswordRotateAppPasswordResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreAppPasswordRotateAppPasswordResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Delete app password - Future deleteAppPassword({ + Future> deleteAppPassword({ final bool oCSAPIRequest = true, }) async { + final rawResponse = deleteAppPasswordRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Delete app password + DynamiteRawResponse deleteAppPasswordRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/core/apppassword'; final queryParameters = {}; final headers = { @@ -216,19 +260,19 @@ class CoreAppPasswordClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreAppPasswordDeleteAppPasswordResponseApplicationJson), - )! as CoreAppPasswordDeleteAppPasswordResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreAppPasswordDeleteAppPasswordResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -238,7 +282,7 @@ class CoreAutoCompleteClient { final CoreClient _rootClient; /// Autocomplete a query - Future $get({ + Future> $get({ required final String search, final String? itemType, final String? itemId, @@ -247,6 +291,29 @@ class CoreAutoCompleteClient { final int limit = 10, final bool oCSAPIRequest = true, }) async { + final rawResponse = $getRaw( + search: search, + itemType: itemType, + itemId: itemId, + sorter: sorter, + shareTypes: shareTypes, + limit: limit, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Autocomplete a query + DynamiteRawResponse $getRaw({ + required final String search, + final String? itemType, + final String? itemId, + final String? sorter, + final List? shareTypes, + final int limit = 10, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/core/autocomplete/get'; final queryParameters = {}; final headers = { @@ -288,19 +355,19 @@ class CoreAutoCompleteClient { queryParameters['limit'] = limit.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreAutoCompleteGetResponseApplicationJson), - )! as CoreAutoCompleteGetResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreAutoCompleteGetResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -315,6 +382,19 @@ class CoreAvatarClient { required final String userId, required final int size, }) async { + final rawResponse = getAvatarDarkRaw( + userId: userId, + size: size, + ); + + return rawResponse.future; + } + + /// Get the dark avatar + DynamiteRawResponse getAvatarDarkRaw({ + required final String userId, + required final int size, + }) { var path = '/index.php/avatar/{userId}/{size}/dark'; final queryParameters = {}; final headers = { @@ -339,22 +419,19 @@ class CoreAvatarClient { // coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); path = path.replaceAll('{size}', Uri.encodeQueryComponent(size.toString())); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return DynamiteResponse( - await response.bodyBytes, - _jsonSerializers.deserialize( - response.responseHeaders, - specifiedType: const FullType(CoreAvatarAvatarGetAvatarDarkHeaders), - )! as CoreAvatarAvatarGetAvatarDarkHeaders, - ); - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(Uint8List), + headersType: const FullType(CoreAvatarAvatarGetAvatarDarkHeaders), + serializers: _jsonSerializers, + ); } /// Get the avatar @@ -362,6 +439,19 @@ class CoreAvatarClient { required final String userId, required final int size, }) async { + final rawResponse = getAvatarRaw( + userId: userId, + size: size, + ); + + return rawResponse.future; + } + + /// Get the avatar + DynamiteRawResponse getAvatarRaw({ + required final String userId, + required final int size, + }) { var path = '/index.php/avatar/{userId}/{size}'; final queryParameters = {}; final headers = { @@ -386,22 +476,19 @@ class CoreAvatarClient { // coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); path = path.replaceAll('{size}', Uri.encodeQueryComponent(size.toString())); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return DynamiteResponse( - await response.bodyBytes, - _jsonSerializers.deserialize( - response.responseHeaders, - specifiedType: const FullType(CoreAvatarAvatarGetAvatarHeaders), - )! as CoreAvatarAvatarGetAvatarHeaders, - ); - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(Uint8List), + headersType: const FullType(CoreAvatarAvatarGetAvatarHeaders), + serializers: _jsonSerializers, + ); } } @@ -411,7 +498,16 @@ class CoreClientFlowLoginV2Client { final CoreClient _rootClient; /// Poll the login flow credentials - Future poll({required final String token}) async { + Future> poll({required final String token}) async { + final rawResponse = pollRaw( + token: token, + ); + + return rawResponse.future; + } + + /// Poll the login flow credentials + DynamiteRawResponse pollRaw({required final String token}) { const path = '/index.php/login/v2/poll'; final queryParameters = {}; final headers = { @@ -435,23 +531,30 @@ class CoreClientFlowLoginV2Client { // coverage:ignore-end queryParameters['token'] = token; - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreLoginFlowV2Credentials), - )! as CoreLoginFlowV2Credentials; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreLoginFlowV2Credentials), + headersType: null, + serializers: _jsonSerializers, + ); + } + + /// Init a login flow + Future> init() async { + final rawResponse = initRaw(); + + return rawResponse.future; } /// Init a login flow - Future init() async { + DynamiteRawResponse initRaw() { const path = '/index.php/login/v2'; final queryParameters = {}; final headers = { @@ -474,17 +577,19 @@ class CoreClientFlowLoginV2Client { } // coverage:ignore-end - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(CoreLoginFlowV2))! - as CoreLoginFlowV2; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreLoginFlowV2), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -494,10 +599,23 @@ class CoreCollaborationResourcesClient { final CoreClient _rootClient; /// Search for collections - Future searchCollections({ + Future> searchCollections({ required final String filter, final bool oCSAPIRequest = true, }) async { + final rawResponse = searchCollectionsRaw( + filter: filter, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Search for collections + DynamiteRawResponse searchCollectionsRaw({ + required final String filter, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/collaboration/resources/collections/search/{filter}'; final queryParameters = {}; final headers = { @@ -524,26 +642,39 @@ class CoreCollaborationResourcesClient { // coverage:ignore-end path = path.replaceAll('{filter}', Uri.encodeQueryComponent(filter)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreCollaborationResourcesSearchCollectionsResponseApplicationJson), - )! as CoreCollaborationResourcesSearchCollectionsResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreCollaborationResourcesSearchCollectionsResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get a collection - Future listCollection({ + Future> listCollection({ required final int collectionId, final bool oCSAPIRequest = true, }) async { + final rawResponse = listCollectionRaw( + collectionId: collectionId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a collection + DynamiteRawResponse listCollectionRaw({ + required final int collectionId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/collaboration/resources/collections/{collectionId}'; final queryParameters = {}; final headers = { @@ -570,27 +701,42 @@ class CoreCollaborationResourcesClient { // coverage:ignore-end path = path.replaceAll('{collectionId}', Uri.encodeQueryComponent(collectionId.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreCollaborationResourcesListCollectionResponseApplicationJson), - )! as CoreCollaborationResourcesListCollectionResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreCollaborationResourcesListCollectionResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Rename a collection - Future renameCollection({ + Future> renameCollection({ required final String collectionName, required final int collectionId, final bool oCSAPIRequest = true, }) async { + final rawResponse = renameCollectionRaw( + collectionName: collectionName, + collectionId: collectionId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Rename a collection + DynamiteRawResponse renameCollectionRaw({ + required final String collectionName, + required final int collectionId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/collaboration/resources/collections/{collectionId}'; final queryParameters = {}; final headers = { @@ -618,28 +764,45 @@ class CoreCollaborationResourcesClient { queryParameters['collectionName'] = collectionName; path = path.replaceAll('{collectionId}', Uri.encodeQueryComponent(collectionId.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreCollaborationResourcesRenameCollectionResponseApplicationJson), - )! as CoreCollaborationResourcesRenameCollectionResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreCollaborationResourcesRenameCollectionResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Add a resource to a collection - Future addResource({ + Future> addResource({ required final String resourceType, required final String resourceId, required final int collectionId, final bool oCSAPIRequest = true, }) async { + final rawResponse = addResourceRaw( + resourceType: resourceType, + resourceId: resourceId, + collectionId: collectionId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Add a resource to a collection + DynamiteRawResponse addResourceRaw({ + required final String resourceType, + required final String resourceId, + required final int collectionId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/collaboration/resources/collections/{collectionId}'; final queryParameters = {}; final headers = { @@ -668,28 +831,45 @@ class CoreCollaborationResourcesClient { queryParameters['resourceId'] = resourceId; path = path.replaceAll('{collectionId}', Uri.encodeQueryComponent(collectionId.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreCollaborationResourcesAddResourceResponseApplicationJson), - )! as CoreCollaborationResourcesAddResourceResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreCollaborationResourcesAddResourceResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Remove a resource from a collection - Future removeResource({ + Future> removeResource({ required final String resourceType, required final String resourceId, required final int collectionId, final bool oCSAPIRequest = true, }) async { + final rawResponse = removeResourceRaw( + resourceType: resourceType, + resourceId: resourceId, + collectionId: collectionId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Remove a resource from a collection + DynamiteRawResponse removeResourceRaw({ + required final String resourceType, + required final String resourceId, + required final int collectionId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/collaboration/resources/collections/{collectionId}'; final queryParameters = {}; final headers = { @@ -718,27 +898,44 @@ class CoreCollaborationResourcesClient { queryParameters['resourceId'] = resourceId; path = path.replaceAll('{collectionId}', Uri.encodeQueryComponent(collectionId.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreCollaborationResourcesRemoveResourceResponseApplicationJson), - )! as CoreCollaborationResourcesRemoveResourceResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreCollaborationResourcesRemoveResourceResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get collections by resource - Future getCollectionsByResource({ + Future> + getCollectionsByResource({ required final String resourceType, required final String resourceId, final bool oCSAPIRequest = true, }) async { + final rawResponse = getCollectionsByResourceRaw( + resourceType: resourceType, + resourceId: resourceId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get collections by resource + DynamiteRawResponse + getCollectionsByResourceRaw({ + required final String resourceType, + required final String resourceId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/collaboration/resources/{resourceType}/{resourceId}'; final queryParameters = {}; final headers = { @@ -766,28 +963,47 @@ class CoreCollaborationResourcesClient { path = path.replaceAll('{resourceType}', Uri.encodeQueryComponent(resourceType)); path = path.replaceAll('{resourceId}', Uri.encodeQueryComponent(resourceId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreCollaborationResourcesGetCollectionsByResourceResponseApplicationJson), - )! as CoreCollaborationResourcesGetCollectionsByResourceResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreCollaborationResourcesGetCollectionsByResourceResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Create a collection for a resource - Future createCollectionOnResource({ + Future> + createCollectionOnResource({ required final String name, required final String baseResourceType, required final String baseResourceId, final bool oCSAPIRequest = true, }) async { + final rawResponse = createCollectionOnResourceRaw( + name: name, + baseResourceType: baseResourceType, + baseResourceId: baseResourceId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Create a collection for a resource + DynamiteRawResponse + createCollectionOnResourceRaw({ + required final String name, + required final String baseResourceType, + required final String baseResourceId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/collaboration/resources/{baseResourceType}/{baseResourceId}'; final queryParameters = {}; final headers = { @@ -816,19 +1032,19 @@ class CoreCollaborationResourcesClient { path = path.replaceAll('{baseResourceType}', Uri.encodeQueryComponent(baseResourceType)); path = path.replaceAll('{baseResourceId}', Uri.encodeQueryComponent(baseResourceId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreCollaborationResourcesCreateCollectionOnResourceResponseApplicationJson), - )! as CoreCollaborationResourcesCreateCollectionOnResourceResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreCollaborationResourcesCreateCollectionOnResourceResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -839,10 +1055,23 @@ class CoreGuestAvatarClient { final CoreClient _rootClient; /// Returns a dark guest avatar image response - Future getAvatarDark({ + Future> getAvatarDark({ required final String guestName, required final String size, }) async { + final rawResponse = getAvatarDarkRaw( + guestName: guestName, + size: size, + ); + + return rawResponse.future; + } + + /// Returns a dark guest avatar image response + DynamiteRawResponse getAvatarDarkRaw({ + required final String guestName, + required final String size, + }) { var path = '/index.php/avatar/guest/{guestName}/{size}/dark'; final queryParameters = {}; final headers = { @@ -867,24 +1096,42 @@ class CoreGuestAvatarClient { // coverage:ignore-end path = path.replaceAll('{guestName}', Uri.encodeQueryComponent(guestName)); path = path.replaceAll('{size}', Uri.encodeQueryComponent(size)); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200 || response.statusCode == 201) { - return response.bodyBytes; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200, 201}, + ), + bodyType: const FullType(Uint8List), + headersType: null, + serializers: _jsonSerializers, + ); } /// Returns a guest avatar image response - Future getAvatar({ + Future> getAvatar({ required final String guestName, required final String size, final int? darkTheme = 0, }) async { + final rawResponse = getAvatarRaw( + guestName: guestName, + size: size, + darkTheme: darkTheme, + ); + + return rawResponse.future; + } + + /// Returns a guest avatar image response + DynamiteRawResponse getAvatarRaw({ + required final String guestName, + required final String size, + final int? darkTheme = 0, + }) { var path = '/index.php/avatar/guest/{guestName}/{size}'; final queryParameters = {}; final headers = { @@ -914,16 +1161,19 @@ class CoreGuestAvatarClient { queryParameters['darkTheme'] = darkTheme.toString(); } } - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200 || response.statusCode == 201) { - return response.bodyBytes; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200, 201}, + ), + bodyType: const FullType(Uint8List), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -933,10 +1183,23 @@ class CoreHoverCardClient { final CoreClient _rootClient; /// Get the user details for a hovercard - Future getUser({ + Future> getUser({ required final String userId, final bool oCSAPIRequest = true, }) async { + final rawResponse = getUserRaw( + userId: userId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the user details for a hovercard + DynamiteRawResponse getUserRaw({ + required final String userId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/hovercard/v1/{userId}'; final queryParameters = {}; final headers = { @@ -963,19 +1226,19 @@ class CoreHoverCardClient { // coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreHoverCardGetUserResponseApplicationJson), - )! as CoreHoverCardGetUserResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreHoverCardGetUserResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -985,10 +1248,23 @@ class CoreNavigationClient { final CoreClient _rootClient; /// Get the apps navigation - Future getAppsNavigation({ + Future> getAppsNavigation({ final int absolute = 0, final bool oCSAPIRequest = true, }) async { + final rawResponse = getAppsNavigationRaw( + absolute: absolute, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the apps navigation + DynamiteRawResponse getAppsNavigationRaw({ + final int absolute = 0, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/core/navigation/apps'; final queryParameters = {}; final headers = { @@ -1017,26 +1293,39 @@ class CoreNavigationClient { queryParameters['absolute'] = absolute.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreNavigationGetAppsNavigationResponseApplicationJson), - )! as CoreNavigationGetAppsNavigationResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreNavigationGetAppsNavigationResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get the settings navigation - Future getSettingsNavigation({ + Future> getSettingsNavigation({ final int absolute = 0, final bool oCSAPIRequest = true, }) async { + final rawResponse = getSettingsNavigationRaw( + absolute: absolute, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the settings navigation + DynamiteRawResponse getSettingsNavigationRaw({ + final int absolute = 0, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/core/navigation/settings'; final queryParameters = {}; final headers = { @@ -1065,19 +1354,19 @@ class CoreNavigationClient { queryParameters['absolute'] = absolute.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreNavigationGetSettingsNavigationResponseApplicationJson), - )! as CoreNavigationGetSettingsNavigationResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreNavigationGetSettingsNavigationResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -1089,6 +1378,13 @@ class CoreOcmClient { /// generate a OCMProvider with local data and send it as DataResponse. This replaces the old PHP file ocm-provider/index.php Future> discovery() async { + final rawResponse = discoveryRaw(); + + return rawResponse.future; + } + + /// generate a OCMProvider with local data and send it as DataResponse. This replaces the old PHP file ocm-provider/index.php + DynamiteRawResponse discoveryRaw() { const path = '/index.php/ocm-provider'; final queryParameters = {}; final headers = { @@ -1111,25 +1407,19 @@ class CoreOcmClient { } // coverage:ignore-end - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return DynamiteResponse( - _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreOcmDiscoveryResponseApplicationJson), - )! as CoreOcmDiscoveryResponseApplicationJson, - _jsonSerializers.deserialize( - response.responseHeaders, - specifiedType: const FullType(CoreOcmOcmDiscoveryHeaders), - )! as CoreOcmOcmDiscoveryHeaders, - ); - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreOcmDiscoveryResponseApplicationJson), + headersType: const FullType(CoreOcmOcmDiscoveryHeaders), + serializers: _jsonSerializers, + ); } } @@ -1139,7 +1429,20 @@ class CoreOcsClient { final CoreClient _rootClient; /// Get the capabilities - Future getCapabilities({final bool oCSAPIRequest = true}) async { + Future> getCapabilities({ + final bool oCSAPIRequest = true, + }) async { + final rawResponse = getCapabilitiesRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the capabilities + DynamiteRawResponse getCapabilitiesRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/cloud/capabilities'; final queryParameters = {}; final headers = { @@ -1163,19 +1466,19 @@ class CoreOcsClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreOcsGetCapabilitiesResponseApplicationJson), - )! as CoreOcsGetCapabilitiesResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreOcsGetCapabilitiesResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -1185,7 +1488,7 @@ class CorePreviewClient { final CoreClient _rootClient; /// Get a preview by file ID - Future getPreviewByFileId({ + Future> getPreviewByFileId({ final int fileId = -1, final int x = 32, final int y = 32, @@ -1194,6 +1497,29 @@ class CorePreviewClient { final String mode = 'fill', final int mimeFallback = 0, }) async { + final rawResponse = getPreviewByFileIdRaw( + fileId: fileId, + x: x, + y: y, + a: a, + forceIcon: forceIcon, + mode: mode, + mimeFallback: mimeFallback, + ); + + return rawResponse.future; + } + + /// Get a preview by file ID + DynamiteRawResponse getPreviewByFileIdRaw({ + final int fileId = -1, + final int x = 32, + final int y = 32, + final int a = 0, + final int forceIcon = 1, + final String mode = 'fill', + final int mimeFallback = 0, + }) { const path = '/index.php/core/preview'; final queryParameters = {}; final headers = { @@ -1239,20 +1565,23 @@ class CorePreviewClient { if (mimeFallback != 0) { queryParameters['mimeFallback'] = mimeFallback.toString(); } - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return response.bodyBytes; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(Uint8List), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get a preview by file path - Future getPreview({ + Future> getPreview({ final String file = '', final int x = 32, final int y = 32, @@ -1261,6 +1590,29 @@ class CorePreviewClient { final String mode = 'fill', final int mimeFallback = 0, }) async { + final rawResponse = getPreviewRaw( + file: file, + x: x, + y: y, + a: a, + forceIcon: forceIcon, + mode: mode, + mimeFallback: mimeFallback, + ); + + return rawResponse.future; + } + + /// Get a preview by file path + DynamiteRawResponse getPreviewRaw({ + final String file = '', + final int x = 32, + final int y = 32, + final int a = 0, + final int forceIcon = 1, + final String mode = 'fill', + final int mimeFallback = 0, + }) { const path = '/index.php/core/preview.png'; final queryParameters = {}; final headers = { @@ -1306,16 +1658,19 @@ class CorePreviewClient { if (mimeFallback != 0) { queryParameters['mimeFallback'] = mimeFallback.toString(); } - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return response.bodyBytes; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(Uint8List), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -1325,12 +1680,29 @@ class CoreProfileApiClient { final CoreClient _rootClient; /// Update the visibility of a parameter - Future setVisibility({ + Future> setVisibility({ required final String paramId, required final String visibility, required final String targetUserId, final bool oCSAPIRequest = true, }) async { + final rawResponse = setVisibilityRaw( + paramId: paramId, + visibility: visibility, + targetUserId: targetUserId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Update the visibility of a parameter + DynamiteRawResponse setVisibilityRaw({ + required final String paramId, + required final String visibility, + required final String targetUserId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/profile/{targetUserId}'; final queryParameters = {}; final headers = { @@ -1359,19 +1731,19 @@ class CoreProfileApiClient { queryParameters['visibility'] = visibility; path = path.replaceAll('{targetUserId}', Uri.encodeQueryComponent(targetUserId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreProfileApiSetVisibilityResponseApplicationJson), - )! as CoreProfileApiSetVisibilityResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreProfileApiSetVisibilityResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -1381,7 +1753,16 @@ class CoreReferenceClient { final CoreClient _rootClient; /// Get a preview for a reference - Future preview({required final String referenceId}) async { + Future> preview({required final String referenceId}) async { + final rawResponse = previewRaw( + referenceId: referenceId, + ); + + return rawResponse.future; + } + + /// Get a preview for a reference + DynamiteRawResponse previewRaw({required final String referenceId}) { var path = '/index.php/core/references/preview/{referenceId}'; final queryParameters = {}; final headers = { @@ -1405,16 +1786,19 @@ class CoreReferenceClient { // coverage:ignore-end path = path.replaceAll('{referenceId}', Uri.encodeQueryComponent(referenceId)); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return response.bodyBytes; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(Uint8List), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -1424,10 +1808,23 @@ class CoreReferenceApiClient { final CoreClient _rootClient; /// Resolve a reference - Future resolveOne({ + Future> resolveOne({ required final String reference, final bool oCSAPIRequest = true, }) async { + final rawResponse = resolveOneRaw( + reference: reference, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Resolve a reference + DynamiteRawResponse resolveOneRaw({ + required final String reference, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/references/resolve'; final queryParameters = {}; final headers = { @@ -1454,27 +1851,42 @@ class CoreReferenceApiClient { // coverage:ignore-end queryParameters['reference'] = reference; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreReferenceApiResolveOneResponseApplicationJson), - )! as CoreReferenceApiResolveOneResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreReferenceApiResolveOneResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Resolve multiple references - Future resolve({ + Future> resolve({ required final List references, final int limit = 1, final bool oCSAPIRequest = true, }) async { + final rawResponse = resolveRaw( + references: references, + limit: limit, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Resolve multiple references + DynamiteRawResponse resolveRaw({ + required final List references, + final int limit = 1, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/references/resolve'; final queryParameters = {}; final headers = { @@ -1504,28 +1916,45 @@ class CoreReferenceApiClient { queryParameters['limit'] = limit.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreReferenceApiResolveResponseApplicationJson), - )! as CoreReferenceApiResolveResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreReferenceApiResolveResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Extract references from a text - Future extract({ + Future> extract({ required final String text, final int resolve = 0, final int limit = 1, final bool oCSAPIRequest = true, }) async { + final rawResponse = extractRaw( + text: text, + resolve: resolve, + limit: limit, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Extract references from a text + DynamiteRawResponse extractRaw({ + required final String text, + final int resolve = 0, + final int limit = 1, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/references/extract'; final queryParameters = {}; final headers = { @@ -1558,25 +1987,36 @@ class CoreReferenceApiClient { queryParameters['limit'] = limit.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreReferenceApiExtractResponseApplicationJson), - )! as CoreReferenceApiExtractResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreReferenceApiExtractResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get the providers - Future getProvidersInfo({ + Future> getProvidersInfo({ final bool oCSAPIRequest = true, }) async { + final rawResponse = getProvidersInfoRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the providers + DynamiteRawResponse getProvidersInfoRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/references/providers'; final queryParameters = {}; final headers = { @@ -1602,27 +2042,42 @@ class CoreReferenceApiClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreReferenceApiGetProvidersInfoResponseApplicationJson), - )! as CoreReferenceApiGetProvidersInfoResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreReferenceApiGetProvidersInfoResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Touch a provider - Future touchProvider({ + Future> touchProvider({ required final String providerId, final int? timestamp, final bool oCSAPIRequest = true, }) async { + final rawResponse = touchProviderRaw( + providerId: providerId, + timestamp: timestamp, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Touch a provider + DynamiteRawResponse touchProviderRaw({ + required final String providerId, + final int? timestamp, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/references/provider/{providerId}'; final queryParameters = {}; final headers = { @@ -1652,19 +2107,19 @@ class CoreReferenceApiClient { queryParameters['timestamp'] = timestamp.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreReferenceApiTouchProviderResponseApplicationJson), - )! as CoreReferenceApiTouchProviderResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreReferenceApiTouchProviderResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -1674,7 +2129,20 @@ class CoreTextProcessingApiClient { final CoreClient _rootClient; /// This endpoint returns all available LanguageModel task types - Future taskTypes({final bool oCSAPIRequest = true}) async { + Future> taskTypes({ + final bool oCSAPIRequest = true, + }) async { + final rawResponse = taskTypesRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// This endpoint returns all available LanguageModel task types + DynamiteRawResponse taskTypesRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/textprocessing/tasktypes'; final queryParameters = {}; final headers = { @@ -1698,29 +2166,48 @@ class CoreTextProcessingApiClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreTextProcessingApiTaskTypesResponseApplicationJson), - )! as CoreTextProcessingApiTaskTypesResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreTextProcessingApiTaskTypesResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// This endpoint allows scheduling a language model task - Future schedule({ + Future> schedule({ required final String input, required final String type, required final String appId, final String identifier = '', final bool oCSAPIRequest = true, }) async { + final rawResponse = scheduleRaw( + input: input, + type: type, + appId: appId, + identifier: identifier, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// This endpoint allows scheduling a language model task + DynamiteRawResponse scheduleRaw({ + required final String input, + required final String type, + required final String appId, + final String identifier = '', + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/textprocessing/schedule'; final queryParameters = {}; final headers = { @@ -1750,26 +2237,39 @@ class CoreTextProcessingApiClient { queryParameters['identifier'] = identifier; } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreTextProcessingApiScheduleResponseApplicationJson), - )! as CoreTextProcessingApiScheduleResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreTextProcessingApiScheduleResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// This endpoint allows checking the status and results of a task. Tasks are removed 1 week after receiving their last update. - Future getTask({ + Future> getTask({ required final int id, final bool oCSAPIRequest = true, }) async { + final rawResponse = getTaskRaw( + id: id, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// This endpoint allows checking the status and results of a task. Tasks are removed 1 week after receiving their last update. + DynamiteRawResponse getTaskRaw({ + required final int id, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/textprocessing/task/{id}'; final queryParameters = {}; final headers = { @@ -1794,26 +2294,39 @@ class CoreTextProcessingApiClient { // coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreTextProcessingApiGetTaskResponseApplicationJson), - )! as CoreTextProcessingApiGetTaskResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreTextProcessingApiGetTaskResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// This endpoint allows to delete a scheduled task for a user - Future deleteTask({ + Future> deleteTask({ required final int id, final bool oCSAPIRequest = true, }) async { + final rawResponse = deleteTaskRaw( + id: id, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// This endpoint allows to delete a scheduled task for a user + DynamiteRawResponse deleteTaskRaw({ + required final int id, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/textprocessing/task/{id}'; final queryParameters = {}; final headers = { @@ -1840,27 +2353,42 @@ class CoreTextProcessingApiClient { // coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreTextProcessingApiDeleteTaskResponseApplicationJson), - )! as CoreTextProcessingApiDeleteTaskResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreTextProcessingApiDeleteTaskResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// This endpoint returns a list of tasks of a user that are related with a specific appId and optionally with an identifier - Future listTasksByApp({ + Future> listTasksByApp({ required final String appId, final String? identifier, final bool oCSAPIRequest = true, }) async { + final rawResponse = listTasksByAppRaw( + appId: appId, + identifier: identifier, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// This endpoint returns a list of tasks of a user that are related with a specific appId and optionally with an identifier + DynamiteRawResponse listTasksByAppRaw({ + required final String appId, + final String? identifier, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/textprocessing/tasks/app/{appId}'; final queryParameters = {}; final headers = { @@ -1890,19 +2418,19 @@ class CoreTextProcessingApiClient { queryParameters['identifier'] = identifier; } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreTextProcessingApiListTasksByAppResponseApplicationJson), - )! as CoreTextProcessingApiListTasksByAppResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreTextProcessingApiListTasksByAppResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -1912,7 +2440,20 @@ class CoreTranslationApiClient { final CoreClient _rootClient; /// Get the list of supported languages - Future languages({final bool oCSAPIRequest = true}) async { + Future> languages({ + final bool oCSAPIRequest = true, + }) async { + final rawResponse = languagesRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the list of supported languages + DynamiteRawResponse languagesRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/translation/languages'; final queryParameters = {}; final headers = { @@ -1936,28 +2477,45 @@ class CoreTranslationApiClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreTranslationApiLanguagesResponseApplicationJson), - )! as CoreTranslationApiLanguagesResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreTranslationApiLanguagesResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Translate a text - Future translate({ + Future> translate({ required final String text, required final String toLanguage, final String? fromLanguage, final bool oCSAPIRequest = true, }) async { + final rawResponse = translateRaw( + text: text, + toLanguage: toLanguage, + fromLanguage: fromLanguage, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Translate a text + DynamiteRawResponse translateRaw({ + required final String text, + required final String toLanguage, + final String? fromLanguage, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/translation/translate'; final queryParameters = {}; final headers = { @@ -1986,19 +2544,19 @@ class CoreTranslationApiClient { queryParameters['fromLanguage'] = fromLanguage; } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreTranslationApiTranslateResponseApplicationJson), - )! as CoreTranslationApiTranslateResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreTranslationApiTranslateResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -2008,10 +2566,23 @@ class CoreUnifiedSearchClient { final CoreClient _rootClient; /// Get the providers for unified search - Future getProviders({ + Future> getProviders({ final String from = '', final bool oCSAPIRequest = true, }) async { + final rawResponse = getProvidersRaw( + from: from, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the providers for unified search + DynamiteRawResponse getProvidersRaw({ + final String from = '', + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/search/providers'; final queryParameters = {}; final headers = { @@ -2040,23 +2611,23 @@ class CoreUnifiedSearchClient { queryParameters['from'] = from; } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreUnifiedSearchGetProvidersResponseApplicationJson), - )! as CoreUnifiedSearchGetProvidersResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreUnifiedSearchGetProvidersResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Search - Future search({ + Future> search({ required final String providerId, final String term = '', final int? sortOrder, @@ -2065,6 +2636,29 @@ class CoreUnifiedSearchClient { final String from = '', final bool oCSAPIRequest = true, }) async { + final rawResponse = searchRaw( + providerId: providerId, + term: term, + sortOrder: sortOrder, + limit: limit, + cursor: cursor, + from: from, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Search + DynamiteRawResponse searchRaw({ + required final String providerId, + final String term = '', + final int? sortOrder, + final int? limit, + final ContentString? cursor, + final String from = '', + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/search/providers/{providerId}/search'; final queryParameters = {}; final headers = { @@ -2109,19 +2703,19 @@ class CoreUnifiedSearchClient { queryParameters['from'] = from; } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreUnifiedSearchSearchResponseApplicationJson), - )! as CoreUnifiedSearchSearchResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreUnifiedSearchSearchResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -2131,7 +2725,16 @@ class CoreWhatsNewClient { final CoreClient _rootClient; /// Get the changes - Future $get({final bool oCSAPIRequest = true}) async { + Future> $get({final bool oCSAPIRequest = true}) async { + final rawResponse = $getRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the changes + DynamiteRawResponse $getRaw({final bool oCSAPIRequest = true}) { const path = '/ocs/v2.php/core/whatsnew'; final queryParameters = {}; final headers = { @@ -2157,26 +2760,39 @@ class CoreWhatsNewClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreWhatsNewGetResponseApplicationJson), - )! as CoreWhatsNewGetResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreWhatsNewGetResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Dismiss the changes - Future dismiss({ + Future> dismiss({ required final String version, final bool oCSAPIRequest = true, }) async { + final rawResponse = dismissRaw( + version: version, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Dismiss the changes + DynamiteRawResponse dismissRaw({ + required final String version, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/core/whatsnew'; final queryParameters = {}; final headers = { @@ -2203,19 +2819,19 @@ class CoreWhatsNewClient { // coverage:ignore-end queryParameters['version'] = version; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreWhatsNewDismissResponseApplicationJson), - )! as CoreWhatsNewDismissResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreWhatsNewDismissResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -2225,7 +2841,18 @@ class CoreWipeClient { final CoreClient _rootClient; /// Check if the device should be wiped - Future checkWipe({required final String token}) async { + Future> checkWipe({ + required final String token, + }) async { + final rawResponse = checkWipeRaw( + token: token, + ); + + return rawResponse.future; + } + + /// Check if the device should be wiped + DynamiteRawResponse checkWipeRaw({required final String token}) { const path = '/index.php/core/wipe/check'; final queryParameters = {}; final headers = { @@ -2249,23 +2876,32 @@ class CoreWipeClient { // coverage:ignore-end queryParameters['token'] = token; - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(CoreWipeCheckWipeResponseApplicationJson), - )! as CoreWipeCheckWipeResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(CoreWipeCheckWipeResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); + } + + /// Finish the wipe + Future> wipeDone({required final String token}) async { + final rawResponse = wipeDoneRaw( + token: token, + ); + + return rawResponse.future; } /// Finish the wipe - Future wipeDone({required final String token}) async { + DynamiteRawResponse wipeDoneRaw({required final String token}) { const path = '/index.php/core/wipe/success'; final queryParameters = {}; final headers = { @@ -2289,19 +2925,19 @@ class CoreWipeClient { // coverage:ignore-end queryParameters['token'] = token; - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200 || response.statusCode == 404) { - return _jsonSerializers.deserialize( - json.decode(await response.body), - specifiedType: const FullType(JsonObject), - )! as JsonObject; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200, 404}, + ), + bodyType: const FullType(JsonObject), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -8836,14 +9472,8 @@ final Serializers _serializers = (Serializers().toBuilder() ..add(CoreWipeCheckWipeResponseApplicationJson.serializer)) .build(); -Serializers get coreSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeCore(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeCore(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/api/dashboard.openapi.dart b/packages/nextcloud/lib/src/api/dashboard.openapi.dart index 3709a050..a551ffe8 100644 --- a/packages/nextcloud/lib/src/api/dashboard.openapi.dart +++ b/packages/nextcloud/lib/src/api/dashboard.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case import 'dart:typed_data'; @@ -43,7 +44,20 @@ class DashboardDashboardApiClient { final DashboardClient _rootClient; /// Get the widgets - Future getWidgets({final bool oCSAPIRequest = true}) async { + Future> getWidgets({ + final bool oCSAPIRequest = true, + }) async { + final rawResponse = getWidgetsRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the widgets + DynamiteRawResponse getWidgetsRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/dashboard/api/v1/widgets'; final queryParameters = {}; final headers = { @@ -69,28 +83,45 @@ class DashboardDashboardApiClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(DashboardDashboardApiGetWidgetsResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(DashboardDashboardApiGetWidgetsResponseApplicationJson), - )! as DashboardDashboardApiGetWidgetsResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get the items for the widgets - Future getWidgetItems({ + Future> getWidgetItems({ final ContentString>? sinceIds, final int limit = 7, final List widgets = const [], final bool oCSAPIRequest = true, }) async { + final rawResponse = getWidgetItemsRaw( + sinceIds: sinceIds, + limit: limit, + widgets: widgets, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the items for the widgets + DynamiteRawResponse getWidgetItemsRaw({ + final ContentString>? sinceIds, + final int limit = 7, + final List widgets = const [], + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/dashboard/api/v1/widget-items'; final queryParameters = {}; final headers = { @@ -130,28 +161,45 @@ class DashboardDashboardApiClient { queryParameters['widgets[]'] = widgets.map((final e) => e); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(DashboardDashboardApiGetWidgetItemsResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(DashboardDashboardApiGetWidgetItemsResponseApplicationJson), - )! as DashboardDashboardApiGetWidgetItemsResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get the items for the widgets - Future getWidgetItemsV2({ + Future> getWidgetItemsV2({ final ContentString>? sinceIds, final int limit = 7, final List widgets = const [], final bool oCSAPIRequest = true, }) async { + final rawResponse = getWidgetItemsV2Raw( + sinceIds: sinceIds, + limit: limit, + widgets: widgets, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the items for the widgets + DynamiteRawResponse getWidgetItemsV2Raw({ + final ContentString>? sinceIds, + final int limit = 7, + final List widgets = const [], + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/dashboard/api/v2/widget-items'; final queryParameters = {}; final headers = { @@ -191,19 +239,19 @@ class DashboardDashboardApiClient { queryParameters['widgets[]'] = widgets.map((final e) => e); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(DashboardDashboardApiGetWidgetItemsV2ResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(DashboardDashboardApiGetWidgetItemsV2ResponseApplicationJson), - )! as DashboardDashboardApiGetWidgetItemsV2ResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -661,14 +709,8 @@ final Serializers _serializers = (Serializers().toBuilder() )) .build(); -Serializers get dashboardSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeDashboard(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeDashboard(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/api/dav.openapi.dart b/packages/nextcloud/lib/src/api/dav.openapi.dart index f9838619..5b3505fb 100644 --- a/packages/nextcloud/lib/src/api/dav.openapi.dart +++ b/packages/nextcloud/lib/src/api/dav.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case import 'dart:typed_data'; @@ -42,11 +43,26 @@ class DavDirectClient { final DavClient _rootClient; /// Get a direct link to a file - Future getUrl({ + Future> getUrl({ required final int fileId, final int? expirationTime, final bool oCSAPIRequest = true, }) async { + final rawResponse = getUrlRaw( + fileId: fileId, + expirationTime: expirationTime, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a direct link to a file + DynamiteRawResponse getUrlRaw({ + required final int fileId, + final int? expirationTime, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/dav/api/v1/direct'; final queryParameters = {}; final headers = { @@ -76,19 +92,19 @@ class DavDirectClient { queryParameters['expirationTime'] = expirationTime.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(DavDirectGetUrlResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(DavDirectGetUrlResponseApplicationJson), - )! as DavDirectGetUrlResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -303,14 +319,8 @@ final Serializers _serializers = (Serializers().toBuilder() ..add(DavCapabilities_Dav.serializer)) .build(); -Serializers get davSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeDav(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeDav(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/api/files.openapi.dart b/packages/nextcloud/lib/src/api/files.openapi.dart index 6d506b3e..615b9c6e 100644 --- a/packages/nextcloud/lib/src/api/files.openapi.dart +++ b/packages/nextcloud/lib/src/api/files.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case import 'dart:typed_data'; @@ -53,11 +54,26 @@ class FilesApiClient { final FilesClient _rootClient; /// Gets a thumbnail of the specified file - Future getThumbnail({ + Future> getThumbnail({ required final int x, required final int y, required final String file, }) async { + final rawResponse = getThumbnailRaw( + x: x, + y: y, + file: file, + ); + + return rawResponse.future; + } + + /// Gets a thumbnail of the specified file + DynamiteRawResponse getThumbnailRaw({ + required final int x, + required final int y, + required final String file, + }) { var path = '/index.php/apps/files/api/v1/thumbnail/{x}/{y}/{file}'; final queryParameters = {}; final headers = { @@ -86,16 +102,19 @@ class FilesApiClient { path = path.replaceAll('{y}', Uri.encodeQueryComponent(y.toString())); checkPattern(file, RegExp(r'^.+$'), 'file'); // coverage:ignore-line path = path.replaceAll('{file}', Uri.encodeQueryComponent(file)); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(Uint8List), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return response.bodyBytes; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -105,7 +124,18 @@ class FilesDirectEditingClient { final FilesClient _rootClient; /// Get the direct editing capabilities - Future info({final bool oCSAPIRequest = true}) async { + Future> info({ + final bool oCSAPIRequest = true, + }) async { + final rawResponse = infoRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the direct editing capabilities + DynamiteRawResponse infoRaw({final bool oCSAPIRequest = true}) { const path = '/ocs/v2.php/apps/files/api/v1/directEditing'; final queryParameters = {}; final headers = { @@ -131,27 +161,42 @@ class FilesDirectEditingClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesDirectEditingInfoResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesDirectEditingInfoResponseApplicationJson), - )! as FilesDirectEditingInfoResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get the templates for direct editing - Future templates({ + Future> templates({ required final String editorId, required final String creatorId, final bool oCSAPIRequest = true, }) async { + final rawResponse = templatesRaw( + editorId: editorId, + creatorId: creatorId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the templates for direct editing + DynamiteRawResponse templatesRaw({ + required final String editorId, + required final String creatorId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/files/api/v1/directEditing/templates/{editorId}/{creatorId}'; final queryParameters = {}; final headers = { @@ -179,28 +224,45 @@ class FilesDirectEditingClient { path = path.replaceAll('{editorId}', Uri.encodeQueryComponent(editorId)); path = path.replaceAll('{creatorId}', Uri.encodeQueryComponent(creatorId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesDirectEditingTemplatesResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesDirectEditingTemplatesResponseApplicationJson), - )! as FilesDirectEditingTemplatesResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Open a file for direct editing - Future open({ + Future> open({ required final String path, final String? editorId, final int? fileId, final bool oCSAPIRequest = true, }) async { + final rawResponse = openRaw( + path: path, + editorId: editorId, + fileId: fileId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Open a file for direct editing + DynamiteRawResponse openRaw({ + required final String path, + final String? editorId, + final int? fileId, + final bool oCSAPIRequest = true, + }) { const path0 = '/ocs/v2.php/apps/files/api/v1/directEditing/open'; final queryParameters = {}; final headers = { @@ -233,29 +295,48 @@ class FilesDirectEditingClient { queryParameters['fileId'] = fileId.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path0, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path0, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesDirectEditingOpenResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesDirectEditingOpenResponseApplicationJson), - )! as FilesDirectEditingOpenResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Create a file for direct editing - Future create({ + Future> create({ required final String path, required final String editorId, required final String creatorId, final String? templateId, final bool oCSAPIRequest = true, }) async { + final rawResponse = createRaw( + path: path, + editorId: editorId, + creatorId: creatorId, + templateId: templateId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Create a file for direct editing + DynamiteRawResponse createRaw({ + required final String path, + required final String editorId, + required final String creatorId, + final String? templateId, + final bool oCSAPIRequest = true, + }) { const path0 = '/ocs/v2.php/apps/files/api/v1/directEditing/create'; final queryParameters = {}; final headers = { @@ -287,19 +368,19 @@ class FilesDirectEditingClient { queryParameters['templateId'] = templateId; } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path0, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path0, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesDirectEditingCreateResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesDirectEditingCreateResponseApplicationJson), - )! as FilesDirectEditingCreateResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -309,10 +390,23 @@ class FilesOpenLocalEditorClient { final FilesClient _rootClient; /// Create a local editor - Future create({ + Future> create({ required final String path, final bool oCSAPIRequest = true, }) async { + final rawResponse = createRaw( + path: path, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Create a local editor + DynamiteRawResponse createRaw({ + required final String path, + final bool oCSAPIRequest = true, + }) { const path0 = '/ocs/v2.php/apps/files/api/v1/openlocaleditor'; final queryParameters = {}; final headers = { @@ -339,27 +433,42 @@ class FilesOpenLocalEditorClient { // coverage:ignore-end queryParameters['path'] = path; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path0, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path0, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesOpenLocalEditorCreateResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesOpenLocalEditorCreateResponseApplicationJson), - )! as FilesOpenLocalEditorCreateResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Validate a local editor - Future validate({ + Future> validate({ required final String path, required final String token, final bool oCSAPIRequest = true, }) async { + final rawResponse = validateRaw( + path: path, + token: token, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Validate a local editor + DynamiteRawResponse validateRaw({ + required final String path, + required final String token, + final bool oCSAPIRequest = true, + }) { var path0 = '/ocs/v2.php/apps/files/api/v1/openlocaleditor/{token}'; final queryParameters = {}; final headers = { @@ -387,19 +496,19 @@ class FilesOpenLocalEditorClient { queryParameters['path'] = path; path0 = path0.replaceAll('{token}', Uri.encodeQueryComponent(token)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path0, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path0, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesOpenLocalEditorValidateResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesOpenLocalEditorValidateResponseApplicationJson), - )! as FilesOpenLocalEditorValidateResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -409,7 +518,18 @@ class FilesTemplateClient { final FilesClient _rootClient; /// List the available templates - Future list({final bool oCSAPIRequest = true}) async { + Future> list({ + final bool oCSAPIRequest = true, + }) async { + final rawResponse = listRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// List the available templates + DynamiteRawResponse listRaw({final bool oCSAPIRequest = true}) { const path = '/ocs/v2.php/apps/files/api/v1/templates'; final queryParameters = {}; final headers = { @@ -435,28 +555,45 @@ class FilesTemplateClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesTemplateListResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesTemplateListResponseApplicationJson), - )! as FilesTemplateListResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Create a template - Future create({ + Future> create({ required final String filePath, final String templatePath = '', final String templateType = 'user', final bool oCSAPIRequest = true, }) async { + final rawResponse = createRaw( + filePath: filePath, + templatePath: templatePath, + templateType: templateType, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Create a template + DynamiteRawResponse createRaw({ + required final String filePath, + final String templatePath = '', + final String templateType = 'user', + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/files/api/v1/templates/create'; final queryParameters = {}; final headers = { @@ -489,27 +626,42 @@ class FilesTemplateClient { queryParameters['templateType'] = templateType; } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesTemplateCreateResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesTemplateCreateResponseApplicationJson), - )! as FilesTemplateCreateResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Initialize the template directory - Future path({ + Future> path({ final String templatePath = '', final int copySystemTemplates = 0, final bool oCSAPIRequest = true, }) async { + final rawResponse = pathRaw( + templatePath: templatePath, + copySystemTemplates: copySystemTemplates, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Initialize the template directory + DynamiteRawResponse pathRaw({ + final String templatePath = '', + final int copySystemTemplates = 0, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/files/api/v1/templates/path'; final queryParameters = {}; final headers = { @@ -541,19 +693,19 @@ class FilesTemplateClient { queryParameters['copySystemTemplates'] = copySystemTemplates.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesTemplatePathResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesTemplatePathResponseApplicationJson), - )! as FilesTemplatePathResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -563,11 +715,26 @@ class FilesTransferOwnershipClient { final FilesClient _rootClient; /// Transfer the ownership to another user - Future transfer({ + Future> transfer({ required final String recipient, required final String path, final bool oCSAPIRequest = true, }) async { + final rawResponse = transferRaw( + recipient: recipient, + path: path, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Transfer the ownership to another user + DynamiteRawResponse transferRaw({ + required final String recipient, + required final String path, + final bool oCSAPIRequest = true, + }) { const path0 = '/ocs/v2.php/apps/files/api/v1/transferownership'; final queryParameters = {}; final headers = { @@ -595,26 +762,39 @@ class FilesTransferOwnershipClient { queryParameters['recipient'] = recipient; queryParameters['path'] = path; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path0, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path0, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200, 400, 403}, + ), + bodyType: const FullType(FilesTransferOwnershipTransferResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200 || response.statusCode == 400 || response.statusCode == 403) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesTransferOwnershipTransferResponseApplicationJson), - )! as FilesTransferOwnershipTransferResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Accept an ownership transfer - Future accept({ + Future> accept({ required final int id, final bool oCSAPIRequest = true, }) async { + final rawResponse = acceptRaw( + id: id, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Accept an ownership transfer + DynamiteRawResponse acceptRaw({ + required final int id, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/files/api/v1/transferownership/{id}'; final queryParameters = {}; final headers = { @@ -641,26 +821,39 @@ class FilesTransferOwnershipClient { // coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200, 403, 404}, + ), + bodyType: const FullType(FilesTransferOwnershipAcceptResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200 || response.statusCode == 403 || response.statusCode == 404) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesTransferOwnershipAcceptResponseApplicationJson), - )! as FilesTransferOwnershipAcceptResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Reject an ownership transfer - Future reject({ + Future> reject({ required final int id, final bool oCSAPIRequest = true, }) async { + final rawResponse = rejectRaw( + id: id, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Reject an ownership transfer + DynamiteRawResponse rejectRaw({ + required final int id, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/files/api/v1/transferownership/{id}'; final queryParameters = {}; final headers = { @@ -687,19 +880,19 @@ class FilesTransferOwnershipClient { // coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200, 403, 404}, + ), + bodyType: const FullType(FilesTransferOwnershipRejectResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200 || response.statusCode == 403 || response.statusCode == 404) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesTransferOwnershipRejectResponseApplicationJson), - )! as FilesTransferOwnershipRejectResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -2369,14 +2562,8 @@ final Serializers _serializers = (Serializers().toBuilder() ..add(FilesTemplate.serializer)) .build(); -Serializers get filesSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeFiles(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeFiles(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/api/files_external.openapi.dart b/packages/nextcloud/lib/src/api/files_external.openapi.dart index 26bc0874..abf4ce85 100644 --- a/packages/nextcloud/lib/src/api/files_external.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_external.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case import 'dart:typed_data'; @@ -44,7 +45,20 @@ class FilesExternalApiClient { final FilesExternalClient _rootClient; /// Get the mount points visible for this user - Future getUserMounts({final bool oCSAPIRequest = true}) async { + Future> getUserMounts({ + final bool oCSAPIRequest = true, + }) async { + final rawResponse = getUserMountsRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the mount points visible for this user + DynamiteRawResponse getUserMountsRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/files_external/api/v1/mounts'; final queryParameters = {}; final headers = { @@ -70,19 +84,19 @@ class FilesExternalApiClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesExternalApiGetUserMountsResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesExternalApiGetUserMountsResponseApplicationJson), - )! as FilesExternalApiGetUserMountsResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -344,14 +358,8 @@ final Serializers _serializers = (Serializers().toBuilder() )) .build(); -Serializers get filesExternalSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeFilesExternal(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeFilesExternal(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/api/files_reminders.openapi.dart b/packages/nextcloud/lib/src/api/files_reminders.openapi.dart index 3e8d897b..b6267f9c 100644 --- a/packages/nextcloud/lib/src/api/files_reminders.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_reminders.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case import 'dart:typed_data'; @@ -44,11 +45,26 @@ class FilesRemindersApiClient { final FilesRemindersClient _rootClient; /// Get a reminder - Future $get({ + Future> $get({ required final String version, required final int fileId, final bool oCSAPIRequest = true, }) async { + final rawResponse = $getRaw( + version: version, + fileId: fileId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a reminder + DynamiteRawResponse $getRaw({ + required final String version, + required final int fileId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/files_reminders/api/v{version}/{fileId}'; final queryParameters = {}; final headers = { @@ -77,28 +93,45 @@ class FilesRemindersApiClient { path = path.replaceAll('{version}', Uri.encodeQueryComponent(version)); path = path.replaceAll('{fileId}', Uri.encodeQueryComponent(fileId.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesRemindersApiGetResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesRemindersApiGetResponseApplicationJson), - )! as FilesRemindersApiGetResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Set a reminder - Future $set({ + Future> $set({ required final String dueDate, required final String version, required final int fileId, final bool oCSAPIRequest = true, }) async { + final rawResponse = $setRaw( + dueDate: dueDate, + version: version, + fileId: fileId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Set a reminder + DynamiteRawResponse $setRaw({ + required final String dueDate, + required final String version, + required final int fileId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/files_reminders/api/v{version}/{fileId}'; final queryParameters = {}; final headers = { @@ -128,31 +161,42 @@ class FilesRemindersApiClient { path = path.replaceAll('{version}', Uri.encodeQueryComponent(version)); path = path.replaceAll('{fileId}', Uri.encodeQueryComponent(fileId.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'put', + uri, + headers, + body, + const {200, 201, 400, 401, 404}, + ), + bodyType: const FullType(FilesRemindersApiSetResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200 || - response.statusCode == 201 || - response.statusCode == 400 || - response.statusCode == 401 || - response.statusCode == 404) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesRemindersApiSetResponseApplicationJson), - )! as FilesRemindersApiSetResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Remove a reminder - Future remove({ + Future> remove({ required final String version, required final int fileId, final bool oCSAPIRequest = true, }) async { + final rawResponse = removeRaw( + version: version, + fileId: fileId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Remove a reminder + DynamiteRawResponse removeRaw({ + required final String version, + required final int fileId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/files_reminders/api/v{version}/{fileId}'; final queryParameters = {}; final headers = { @@ -181,19 +225,19 @@ class FilesRemindersApiClient { path = path.replaceAll('{version}', Uri.encodeQueryComponent(version)); path = path.replaceAll('{fileId}', Uri.encodeQueryComponent(fileId.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200, 401, 404}, + ), + bodyType: const FullType(FilesRemindersApiRemoveResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200 || response.statusCode == 401 || response.statusCode == 404) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesRemindersApiRemoveResponseApplicationJson), - )! as FilesRemindersApiRemoveResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -512,14 +556,8 @@ final Serializers _serializers = (Serializers().toBuilder() ..add(FilesRemindersApiRemoveResponseApplicationJson_Ocs.serializer)) .build(); -Serializers get filesRemindersSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeFilesReminders(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeFilesReminders(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/api/files_sharing.openapi.dart b/packages/nextcloud/lib/src/api/files_sharing.openapi.dart index 600db34c..b984d898 100644 --- a/packages/nextcloud/lib/src/api/files_sharing.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_sharing.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case import 'dart:typed_data'; @@ -54,7 +55,20 @@ class FilesSharingDeletedShareapiClient { final FilesSharingClient _rootClient; /// Get a list of all deleted shares - Future list({final bool oCSAPIRequest = true}) async { + Future> list({ + final bool oCSAPIRequest = true, + }) async { + final rawResponse = listRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a list of all deleted shares + DynamiteRawResponse listRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/files_sharing/api/v1/deletedshares'; final queryParameters = {}; final headers = { @@ -80,26 +94,39 @@ class FilesSharingDeletedShareapiClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesSharingDeletedShareapiListResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesSharingDeletedShareapiListResponseApplicationJson), - )! as FilesSharingDeletedShareapiListResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Undelete a deleted share - Future undelete({ + Future> undelete({ required final String id, final bool oCSAPIRequest = true, }) async { + final rawResponse = undeleteRaw( + id: id, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Undelete a deleted share + DynamiteRawResponse undeleteRaw({ + required final String id, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/files_sharing/api/v1/deletedshares/{id}'; final queryParameters = {}; final headers = { @@ -126,19 +153,19 @@ class FilesSharingDeletedShareapiClient { // coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesSharingDeletedShareapiUndeleteResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesSharingDeletedShareapiUndeleteResponseApplicationJson), - )! as FilesSharingDeletedShareapiUndeleteResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -148,10 +175,23 @@ class FilesSharingPublicPreviewClient { final FilesSharingClient _rootClient; /// Get a direct link preview for a shared file - Future directLink({ + Future> directLink({ required final String token, final bool oCSAPIRequest = true, }) async { + final rawResponse = directLinkRaw( + token: token, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a direct link preview for a shared file + DynamiteRawResponse directLinkRaw({ + required final String token, + final bool oCSAPIRequest = true, + }) { var path = '/index.php/s/{token}/preview'; final queryParameters = {}; final headers = { @@ -176,20 +216,23 @@ class FilesSharingPublicPreviewClient { // coverage:ignore-end path = path.replaceAll('{token}', Uri.encodeQueryComponent(token)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(Uint8List), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return response.bodyBytes; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get a preview for a shared file - Future getPreview({ + Future> getPreview({ required final String token, final String file = '', final int x = 32, @@ -197,6 +240,27 @@ class FilesSharingPublicPreviewClient { final int a = 0, final bool oCSAPIRequest = true, }) async { + final rawResponse = getPreviewRaw( + token: token, + file: file, + x: x, + y: y, + a: a, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a preview for a shared file + DynamiteRawResponse getPreviewRaw({ + required final String token, + final String file = '', + final int x = 32, + final int y = 32, + final int a = 0, + final bool oCSAPIRequest = true, + }) { var path = '/index.php/apps/files_sharing/publicpreview/{token}'; final queryParameters = {}; final headers = { @@ -233,16 +297,19 @@ class FilesSharingPublicPreviewClient { queryParameters['a'] = a.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(Uint8List), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return response.bodyBytes; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -252,7 +319,20 @@ class FilesSharingRemoteClient { final FilesSharingClient _rootClient; /// Get a list of accepted remote shares - Future getShares({final bool oCSAPIRequest = true}) async { + Future> getShares({ + final bool oCSAPIRequest = true, + }) async { + final rawResponse = getSharesRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a list of accepted remote shares + DynamiteRawResponse getSharesRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/files_sharing/api/v1/remote_shares'; final queryParameters = {}; final headers = { @@ -278,25 +358,36 @@ class FilesSharingRemoteClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesSharingRemoteGetSharesResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesSharingRemoteGetSharesResponseApplicationJson), - )! as FilesSharingRemoteGetSharesResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get list of pending remote shares - Future getOpenShares({ + Future> getOpenShares({ final bool oCSAPIRequest = true, }) async { + final rawResponse = getOpenSharesRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get list of pending remote shares + DynamiteRawResponse getOpenSharesRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending'; final queryParameters = {}; final headers = { @@ -322,26 +413,39 @@ class FilesSharingRemoteClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesSharingRemoteGetOpenSharesResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesSharingRemoteGetOpenSharesResponseApplicationJson), - )! as FilesSharingRemoteGetOpenSharesResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Accept a remote share - Future acceptShare({ + Future> acceptShare({ required final int id, final bool oCSAPIRequest = true, }) async { + final rawResponse = acceptShareRaw( + id: id, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Accept a remote share + DynamiteRawResponse acceptShareRaw({ + required final int id, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/{id}'; final queryParameters = {}; final headers = { @@ -368,26 +472,39 @@ class FilesSharingRemoteClient { // coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesSharingRemoteAcceptShareResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesSharingRemoteAcceptShareResponseApplicationJson), - )! as FilesSharingRemoteAcceptShareResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Decline a remote share - Future declineShare({ + Future> declineShare({ required final int id, final bool oCSAPIRequest = true, }) async { + final rawResponse = declineShareRaw( + id: id, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Decline a remote share + DynamiteRawResponse declineShareRaw({ + required final int id, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/{id}'; final queryParameters = {}; final headers = { @@ -414,26 +531,39 @@ class FilesSharingRemoteClient { // coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesSharingRemoteDeclineShareResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesSharingRemoteDeclineShareResponseApplicationJson), - )! as FilesSharingRemoteDeclineShareResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get info of a remote share - Future getShare({ + Future> getShare({ required final int id, final bool oCSAPIRequest = true, }) async { + final rawResponse = getShareRaw( + id: id, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get info of a remote share + DynamiteRawResponse getShareRaw({ + required final int id, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/{id}'; final queryParameters = {}; final headers = { @@ -460,26 +590,39 @@ class FilesSharingRemoteClient { // coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesSharingRemoteGetShareResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesSharingRemoteGetShareResponseApplicationJson), - )! as FilesSharingRemoteGetShareResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Unshare a remote share - Future unshare({ + Future> unshare({ required final int id, final bool oCSAPIRequest = true, }) async { + final rawResponse = unshareRaw( + id: id, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Unshare a remote share + DynamiteRawResponse unshareRaw({ + required final int id, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/{id}'; final queryParameters = {}; final headers = { @@ -506,19 +649,19 @@ class FilesSharingRemoteClient { // coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesSharingRemoteUnshareResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesSharingRemoteUnshareResponseApplicationJson), - )! as FilesSharingRemoteUnshareResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -528,12 +671,29 @@ class FilesSharingShareInfoClient { final FilesSharingClient _rootClient; /// Get the info about a share - Future info({ + Future> info({ required final String t, final String? password, final String? dir, final int depth = -1, }) async { + final rawResponse = infoRaw( + t: t, + password: password, + dir: dir, + depth: depth, + ); + + return rawResponse.future; + } + + /// Get the info about a share + DynamiteRawResponse infoRaw({ + required final String t, + final String? password, + final String? dir, + final int depth = -1, + }) { const path = '/index.php/apps/files_sharing/shareinfo'; final queryParameters = {}; final headers = { @@ -566,19 +726,19 @@ class FilesSharingShareInfoClient { if (depth != -1) { queryParameters['depth'] = depth.toString(); } - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesSharingShareInfo), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesSharingShareInfo), - )! as FilesSharingShareInfo; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -588,7 +748,7 @@ class FilesSharingShareapiClient { final FilesSharingClient _rootClient; /// Get shares of the current user - Future getShares({ + Future> getShares({ final String sharedWithMe = 'false', final String reshares = 'false', final String subfiles = 'false', @@ -596,6 +756,27 @@ class FilesSharingShareapiClient { final String includeTags = 'false', final bool oCSAPIRequest = true, }) async { + final rawResponse = getSharesRaw( + sharedWithMe: sharedWithMe, + reshares: reshares, + subfiles: subfiles, + path: path, + includeTags: includeTags, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get shares of the current user + DynamiteRawResponse getSharesRaw({ + final String sharedWithMe = 'false', + final String reshares = 'false', + final String subfiles = 'false', + final String path = '', + final String includeTags = 'false', + final bool oCSAPIRequest = true, + }) { const path0 = '/ocs/v2.php/apps/files_sharing/api/v1/shares'; final queryParameters = {}; final headers = { @@ -636,23 +817,23 @@ class FilesSharingShareapiClient { queryParameters['include_tags'] = includeTags; } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path0, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path0, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesSharingShareapiGetSharesResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesSharingShareapiGetSharesResponseApplicationJson), - )! as FilesSharingShareapiGetSharesResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Create a share - Future createShare({ + Future> createShare({ final String? path, final int? permissions, final int shareType = -1, @@ -666,6 +847,39 @@ class FilesSharingShareapiClient { final String? attributes, final bool oCSAPIRequest = true, }) async { + final rawResponse = createShareRaw( + path: path, + permissions: permissions, + shareType: shareType, + shareWith: shareWith, + publicUpload: publicUpload, + password: password, + sendPasswordByTalk: sendPasswordByTalk, + expireDate: expireDate, + note: note, + label: label, + attributes: attributes, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Create a share + DynamiteRawResponse createShareRaw({ + final String? path, + final int? permissions, + final int shareType = -1, + final String? shareWith, + final String publicUpload = 'false', + final String password = '', + final String? sendPasswordByTalk, + final String expireDate = '', + final String note = '', + final String label = '', + final String? attributes, + final bool oCSAPIRequest = true, + }) { const path0 = '/ocs/v2.php/apps/files_sharing/api/v1/shares'; final queryParameters = {}; final headers = { @@ -724,26 +938,39 @@ class FilesSharingShareapiClient { queryParameters['attributes'] = attributes; } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path0, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path0, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesSharingShareapiCreateShareResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesSharingShareapiCreateShareResponseApplicationJson), - )! as FilesSharingShareapiCreateShareResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get all shares relative to a file, including parent folders shares rights - Future getInheritedShares({ + Future> getInheritedShares({ required final String path, final bool oCSAPIRequest = true, }) async { + final rawResponse = getInheritedSharesRaw( + path: path, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get all shares relative to a file, including parent folders shares rights + DynamiteRawResponse getInheritedSharesRaw({ + required final String path, + final bool oCSAPIRequest = true, + }) { const path0 = '/ocs/v2.php/apps/files_sharing/api/v1/shares/inherited'; final queryParameters = {}; final headers = { @@ -770,25 +997,36 @@ class FilesSharingShareapiClient { // coverage:ignore-end queryParameters['path'] = path; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path0, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path0, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesSharingShareapiGetInheritedSharesResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesSharingShareapiGetInheritedSharesResponseApplicationJson), - )! as FilesSharingShareapiGetInheritedSharesResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get all shares that are still pending - Future pendingShares({ + Future> pendingShares({ final bool oCSAPIRequest = true, }) async { + final rawResponse = pendingSharesRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get all shares that are still pending + DynamiteRawResponse pendingSharesRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/files_sharing/api/v1/shares/pending'; final queryParameters = {}; final headers = { @@ -814,27 +1052,42 @@ class FilesSharingShareapiClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesSharingShareapiPendingSharesResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesSharingShareapiPendingSharesResponseApplicationJson), - )! as FilesSharingShareapiPendingSharesResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get a specific share by id - Future getShare({ + Future> getShare({ required final String id, final int includeTags = 0, final bool oCSAPIRequest = true, }) async { + final rawResponse = getShareRaw( + id: id, + includeTags: includeTags, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a specific share by id + DynamiteRawResponse getShareRaw({ + required final String id, + final int includeTags = 0, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/files_sharing/api/v1/shares/{id}'; final queryParameters = {}; final headers = { @@ -864,23 +1117,23 @@ class FilesSharingShareapiClient { queryParameters['include_tags'] = includeTags.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesSharingShareapiGetShareResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesSharingShareapiGetShareResponseApplicationJson), - )! as FilesSharingShareapiGetShareResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Update a share - Future updateShare({ + Future> updateShare({ required final String id, final int? permissions, final String? password, @@ -893,6 +1146,37 @@ class FilesSharingShareapiClient { final String? attributes, final bool oCSAPIRequest = true, }) async { + final rawResponse = updateShareRaw( + id: id, + permissions: permissions, + password: password, + sendPasswordByTalk: sendPasswordByTalk, + publicUpload: publicUpload, + expireDate: expireDate, + note: note, + label: label, + hideDownload: hideDownload, + attributes: attributes, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Update a share + DynamiteRawResponse updateShareRaw({ + required final String id, + final int? permissions, + final String? password, + final String? sendPasswordByTalk, + final String? publicUpload, + final String? expireDate, + final String? note, + final String? label, + final String? hideDownload, + final String? attributes, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/files_sharing/api/v1/shares/{id}'; final queryParameters = {}; final headers = { @@ -946,26 +1230,39 @@ class FilesSharingShareapiClient { queryParameters['attributes'] = attributes; } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesSharingShareapiUpdateShareResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesSharingShareapiUpdateShareResponseApplicationJson), - )! as FilesSharingShareapiUpdateShareResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Delete a share - Future deleteShare({ + Future> deleteShare({ required final String id, final bool oCSAPIRequest = true, }) async { + final rawResponse = deleteShareRaw( + id: id, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Delete a share + DynamiteRawResponse deleteShareRaw({ + required final String id, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/files_sharing/api/v1/shares/{id}'; final queryParameters = {}; final headers = { @@ -992,26 +1289,39 @@ class FilesSharingShareapiClient { // coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesSharingShareapiDeleteShareResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesSharingShareapiDeleteShareResponseApplicationJson), - )! as FilesSharingShareapiDeleteShareResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Accept a share - Future acceptShare({ + Future> acceptShare({ required final String id, final bool oCSAPIRequest = true, }) async { + final rawResponse = acceptShareRaw( + id: id, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Accept a share + DynamiteRawResponse acceptShareRaw({ + required final String id, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/files_sharing/api/v1/shares/pending/{id}'; final queryParameters = {}; final headers = { @@ -1038,19 +1348,19 @@ class FilesSharingShareapiClient { // coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesSharingShareapiAcceptShareResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesSharingShareapiAcceptShareResponseApplicationJson), - )! as FilesSharingShareapiAcceptShareResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -1071,6 +1381,30 @@ class FilesSharingShareesapiClient { final int lookup = 0, final bool oCSAPIRequest = true, }) async { + final rawResponse = searchRaw( + search: search, + itemType: itemType, + page: page, + perPage: perPage, + shareType: shareType, + lookup: lookup, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Search for sharees + DynamiteRawResponse searchRaw({ + final String search = '', + final String? itemType, + final int page = 1, + final int perPage = 200, + final ContentString? shareType, + final int lookup = 0, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/files_sharing/api/v1/sharees'; final queryParameters = {}; final headers = { @@ -1117,34 +1451,43 @@ class FilesSharingShareesapiClient { queryParameters['lookup'] = lookup.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesSharingShareesapiSearchResponseApplicationJson), + headersType: const FullType(FilesSharingShareesapiShareesapiSearchHeaders), + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return DynamiteResponse( - _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesSharingShareesapiSearchResponseApplicationJson), - )! as FilesSharingShareesapiSearchResponseApplicationJson, - _jsonSerializers.deserialize( - response.responseHeaders, - specifiedType: const FullType(FilesSharingShareesapiShareesapiSearchHeaders), - )! as FilesSharingShareesapiShareesapiSearchHeaders, - ); - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Find recommended sharees - Future findRecommended({ + Future> findRecommended({ required final String itemType, final ContentString? shareType, final bool oCSAPIRequest = true, }) async { + final rawResponse = findRecommendedRaw( + itemType: itemType, + shareType: shareType, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Find recommended sharees + DynamiteRawResponse findRecommendedRaw({ + required final String itemType, + final ContentString? shareType, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/files_sharing/api/v1/sharees_recommended'; final queryParameters = {}; final headers = { @@ -1177,19 +1520,19 @@ class FilesSharingShareesapiClient { ); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(FilesSharingShareesapiFindRecommendedResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(FilesSharingShareesapiFindRecommendedResponseApplicationJson), - )! as FilesSharingShareesapiFindRecommendedResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -4732,14 +5075,8 @@ final Serializers _serializers = (Serializers().toBuilder() ..add(FilesSharingCapabilities_FilesSharing_Sharee.serializer)) .build(); -Serializers get filesSharingSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeFilesSharing(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeFilesSharing(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/api/files_trashbin.openapi.dart b/packages/nextcloud/lib/src/api/files_trashbin.openapi.dart index b81fcdf4..6aa8aa3f 100644 --- a/packages/nextcloud/lib/src/api/files_trashbin.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_trashbin.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case import 'dart:typed_data'; @@ -42,12 +43,29 @@ class FilesTrashbinPreviewClient { final FilesTrashbinClient _rootClient; /// Get the preview for a file - Future getPreview({ + Future> getPreview({ final int fileId = -1, final int x = 32, final int y = 32, final int a = 0, }) async { + final rawResponse = getPreviewRaw( + fileId: fileId, + x: x, + y: y, + a: a, + ); + + return rawResponse.future; + } + + /// Get the preview for a file + DynamiteRawResponse getPreviewRaw({ + final int fileId = -1, + final int x = 32, + final int y = 32, + final int a = 0, + }) { const path = '/index.php/apps/files_trashbin/preview'; final queryParameters = {}; final headers = { @@ -84,16 +102,19 @@ class FilesTrashbinPreviewClient { if (a != 0) { queryParameters['a'] = a.toString(); } - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(Uint8List), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return response.bodyBytes; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -165,14 +186,8 @@ final Serializers _serializers = (Serializers().toBuilder() ..add(FilesTrashbinCapabilities_Files.serializer)) .build(); -Serializers get filesTrashbinSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeFilesTrashbin(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeFilesTrashbin(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/api/files_versions.openapi.dart b/packages/nextcloud/lib/src/api/files_versions.openapi.dart index 76c72f92..54750077 100644 --- a/packages/nextcloud/lib/src/api/files_versions.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_versions.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case import 'dart:typed_data'; @@ -42,12 +43,29 @@ class FilesVersionsPreviewClient { final FilesVersionsClient _rootClient; /// Get the preview for a file version - Future getPreview({ + Future> getPreview({ final String file = '', final int x = 44, final int y = 44, final String version = '', }) async { + final rawResponse = getPreviewRaw( + file: file, + x: x, + y: y, + version: version, + ); + + return rawResponse.future; + } + + /// Get the preview for a file version + DynamiteRawResponse getPreviewRaw({ + final String file = '', + final int x = 44, + final int y = 44, + final String version = '', + }) { const path = '/index.php/apps/files_versions/preview'; final queryParameters = {}; final headers = { @@ -84,16 +102,19 @@ class FilesVersionsPreviewClient { if (version != '') { queryParameters['version'] = version; } - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(Uint8List), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return response.bodyBytes; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -169,14 +190,8 @@ final Serializers _serializers = (Serializers().toBuilder() ..add(FilesVersionsCapabilities_Files.serializer)) .build(); -Serializers get filesVersionsSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeFilesVersions(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeFilesVersions(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/api/news.openapi.dart b/packages/nextcloud/lib/src/api/news.openapi.dart index f893bde8..6a7581e9 100644 --- a/packages/nextcloud/lib/src/api/news.openapi.dart +++ b/packages/nextcloud/lib/src/api/news.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case import 'dart:typed_data'; @@ -35,7 +36,13 @@ class NewsClient extends DynamiteClient { authentications: client.authentications, ); - Future getSupportedApiVersions() async { + Future> getSupportedApiVersions() async { + final rawResponse = getSupportedApiVersionsRaw(); + + return rawResponse.future; + } + + DynamiteRawResponse getSupportedApiVersionsRaw() { const path = '/index.php/apps/news/api'; final queryParameters = {}; final headers = { @@ -60,22 +67,28 @@ class NewsClient extends DynamiteClient { } // coverage:ignore-end - final response = await doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(NewsSupportedAPIVersions), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(NewsSupportedAPIVersions), - )! as NewsSupportedAPIVersions; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future listFolders() async { + Future> listFolders() async { + final rawResponse = listFoldersRaw(); + + return rawResponse.future; + } + + DynamiteRawResponse listFoldersRaw() { const path = '/index.php/apps/news/api/v1-3/folders'; final queryParameters = {}; final headers = { @@ -100,20 +113,30 @@ class NewsClient extends DynamiteClient { } // coverage:ignore-end - final response = await doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(NewsListFolders), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NewsListFolders))! - as NewsListFolders; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future createFolder({required final String name}) async { + Future> createFolder({required final String name}) async { + final rawResponse = createFolderRaw( + name: name, + ); + + return rawResponse.future; + } + + DynamiteRawResponse createFolderRaw({required final String name}) { const path = '/index.php/apps/news/api/v1-3/folders'; final queryParameters = {}; final headers = { @@ -139,23 +162,37 @@ class NewsClient extends DynamiteClient { // coverage:ignore-end queryParameters['name'] = name; - final response = await doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(NewsListFolders), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NewsListFolders))! - as NewsListFolders; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future renameFolder({ + Future> renameFolder({ required final int folderId, required final String name, }) async { + final rawResponse = renameFolderRaw( + folderId: folderId, + name: name, + ); + + return rawResponse.future; + } + + DynamiteRawResponse renameFolderRaw({ + required final int folderId, + required final String name, + }) { var path = '/index.php/apps/news/api/v1-3/folders/{folderId}'; final queryParameters = {}; final headers = {}; @@ -180,19 +217,30 @@ class NewsClient extends DynamiteClient { // coverage:ignore-end path = path.replaceAll('{folderId}', Uri.encodeQueryComponent(folderId.toString())); queryParameters['name'] = name; - final response = await doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: null, + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future deleteFolder({required final int folderId}) async { + Future> deleteFolder({required final int folderId}) async { + final rawResponse = deleteFolderRaw( + folderId: folderId, + ); + + return rawResponse.future; + } + + DynamiteRawResponse deleteFolderRaw({required final int folderId}) { var path = '/index.php/apps/news/api/v1-3/folders/{folderId}'; final queryParameters = {}; final headers = {}; @@ -216,22 +264,37 @@ class NewsClient extends DynamiteClient { // coverage:ignore-end path = path.replaceAll('{folderId}', Uri.encodeQueryComponent(folderId.toString())); - final response = await doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: null, + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future markFolderAsRead({ + Future> markFolderAsRead({ required final int folderId, required final int newestItemId, }) async { + final rawResponse = markFolderAsReadRaw( + folderId: folderId, + newestItemId: newestItemId, + ); + + return rawResponse.future; + } + + DynamiteRawResponse markFolderAsReadRaw({ + required final int folderId, + required final int newestItemId, + }) { var path = '/index.php/apps/news/api/v1-3/folders/{folderId}/read'; final queryParameters = {}; final headers = {}; @@ -256,19 +319,28 @@ class NewsClient extends DynamiteClient { // coverage:ignore-end path = path.replaceAll('{folderId}', Uri.encodeQueryComponent(folderId.toString())); queryParameters['newestItemId'] = newestItemId.toString(); - final response = await doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: null, + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future listFeeds() async { + Future> listFeeds() async { + final rawResponse = listFeedsRaw(); + + return rawResponse.future; + } + + DynamiteRawResponse listFeedsRaw() { const path = '/index.php/apps/news/api/v1-3/feeds'; final queryParameters = {}; final headers = { @@ -293,23 +365,37 @@ class NewsClient extends DynamiteClient { } // coverage:ignore-end - final response = await doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(NewsListFeeds), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NewsListFeeds))! - as NewsListFeeds; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future addFeed({ + Future> addFeed({ required final String url, final int? folderId, }) async { + final rawResponse = addFeedRaw( + url: url, + folderId: folderId, + ); + + return rawResponse.future; + } + + DynamiteRawResponse addFeedRaw({ + required final String url, + final int? folderId, + }) { const path = '/index.php/apps/news/api/v1-3/feeds'; final queryParameters = {}; final headers = { @@ -338,20 +424,30 @@ class NewsClient extends DynamiteClient { if (folderId != null) { queryParameters['folderId'] = folderId.toString(); } - final response = await doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(NewsListFeeds), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NewsListFeeds))! - as NewsListFeeds; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future deleteFeed({required final int feedId}) async { + Future> deleteFeed({required final int feedId}) async { + final rawResponse = deleteFeedRaw( + feedId: feedId, + ); + + return rawResponse.future; + } + + DynamiteRawResponse deleteFeedRaw({required final int feedId}) { var path = '/index.php/apps/news/api/v1-3/feeds/{feedId}'; final queryParameters = {}; final headers = {}; @@ -375,22 +471,37 @@ class NewsClient extends DynamiteClient { // coverage:ignore-end path = path.replaceAll('{feedId}', Uri.encodeQueryComponent(feedId.toString())); - final response = await doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: null, + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future moveFeed({ + Future> moveFeed({ required final int feedId, final int? folderId, }) async { + final rawResponse = moveFeedRaw( + feedId: feedId, + folderId: folderId, + ); + + return rawResponse.future; + } + + DynamiteRawResponse moveFeedRaw({ + required final int feedId, + final int? folderId, + }) { var path = '/index.php/apps/news/api/v1-3/feeds/{feedId}/move'; final queryParameters = {}; final headers = {}; @@ -417,22 +528,37 @@ class NewsClient extends DynamiteClient { if (folderId != null) { queryParameters['folderId'] = folderId.toString(); } - final response = await doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: null, + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future renameFeed({ + Future> renameFeed({ required final int feedId, required final String feedTitle, }) async { + final rawResponse = renameFeedRaw( + feedId: feedId, + feedTitle: feedTitle, + ); + + return rawResponse.future; + } + + DynamiteRawResponse renameFeedRaw({ + required final int feedId, + required final String feedTitle, + }) { var path = '/index.php/apps/news/api/v1-3/feeds/{feedId}/rename'; final queryParameters = {}; final headers = {}; @@ -457,22 +583,37 @@ class NewsClient extends DynamiteClient { // coverage:ignore-end path = path.replaceAll('{feedId}', Uri.encodeQueryComponent(feedId.toString())); queryParameters['feedTitle'] = feedTitle; - final response = await doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: null, + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future markFeedAsRead({ + Future> markFeedAsRead({ required final int feedId, required final int newestItemId, }) async { + final rawResponse = markFeedAsReadRaw( + feedId: feedId, + newestItemId: newestItemId, + ); + + return rawResponse.future; + } + + DynamiteRawResponse markFeedAsReadRaw({ + required final int feedId, + required final int newestItemId, + }) { var path = '/index.php/apps/news/api/v1-3/feeds/{feedId}/read'; final queryParameters = {}; final headers = {}; @@ -497,19 +638,22 @@ class NewsClient extends DynamiteClient { // coverage:ignore-end path = path.replaceAll('{feedId}', Uri.encodeQueryComponent(feedId.toString())); queryParameters['newestItemId'] = newestItemId.toString(); - final response = await doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: null, + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future listArticles({ + Future> listArticles({ final int type = 3, final int id = 0, final int getRead = 1, @@ -517,6 +661,26 @@ class NewsClient extends DynamiteClient { final int offset = 0, final int oldestFirst = 0, }) async { + final rawResponse = listArticlesRaw( + type: type, + id: id, + getRead: getRead, + batchSize: batchSize, + offset: offset, + oldestFirst: oldestFirst, + ); + + return rawResponse.future; + } + + DynamiteRawResponse listArticlesRaw({ + final int type = 3, + final int id = 0, + final int getRead = 1, + final int batchSize = -1, + final int offset = 0, + final int oldestFirst = 0, + }) { const path = '/index.php/apps/news/api/v1-3/items'; final queryParameters = {}; final headers = { @@ -559,24 +723,40 @@ class NewsClient extends DynamiteClient { if (oldestFirst != 0) { queryParameters['oldestFirst'] = oldestFirst.toString(); } - final response = await doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(NewsListArticles), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NewsListArticles))! - as NewsListArticles; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future listUpdatedArticles({ + Future> listUpdatedArticles({ final int type = 3, final int id = 0, final int lastModified = 0, }) async { + final rawResponse = listUpdatedArticlesRaw( + type: type, + id: id, + lastModified: lastModified, + ); + + return rawResponse.future; + } + + DynamiteRawResponse listUpdatedArticlesRaw({ + final int type = 3, + final int id = 0, + final int lastModified = 0, + }) { const path = '/index.php/apps/news/api/v1-3/items/updated'; final queryParameters = {}; final headers = { @@ -610,20 +790,30 @@ class NewsClient extends DynamiteClient { if (lastModified != 0) { queryParameters['lastModified'] = lastModified.toString(); } - final response = await doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(NewsListArticles), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NewsListArticles))! - as NewsListArticles; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future markArticleAsRead({required final int itemId}) async { + Future> markArticleAsRead({required final int itemId}) async { + final rawResponse = markArticleAsReadRaw( + itemId: itemId, + ); + + return rawResponse.future; + } + + DynamiteRawResponse markArticleAsReadRaw({required final int itemId}) { var path = '/index.php/apps/news/api/v1-3/items/{itemId}/read'; final queryParameters = {}; final headers = {}; @@ -647,19 +837,30 @@ class NewsClient extends DynamiteClient { // coverage:ignore-end path = path.replaceAll('{itemId}', Uri.encodeQueryComponent(itemId.toString())); - final response = await doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: null, + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future markArticleAsUnread({required final int itemId}) async { + Future> markArticleAsUnread({required final int itemId}) async { + final rawResponse = markArticleAsUnreadRaw( + itemId: itemId, + ); + + return rawResponse.future; + } + + DynamiteRawResponse markArticleAsUnreadRaw({required final int itemId}) { var path = '/index.php/apps/news/api/v1-3/items/{itemId}/unread'; final queryParameters = {}; final headers = {}; @@ -683,19 +884,30 @@ class NewsClient extends DynamiteClient { // coverage:ignore-end path = path.replaceAll('{itemId}', Uri.encodeQueryComponent(itemId.toString())); - final response = await doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: null, + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future starArticle({required final int itemId}) async { + Future> starArticle({required final int itemId}) async { + final rawResponse = starArticleRaw( + itemId: itemId, + ); + + return rawResponse.future; + } + + DynamiteRawResponse starArticleRaw({required final int itemId}) { var path = '/index.php/apps/news/api/v1-3/items/{itemId}/star'; final queryParameters = {}; final headers = {}; @@ -719,19 +931,30 @@ class NewsClient extends DynamiteClient { // coverage:ignore-end path = path.replaceAll('{itemId}', Uri.encodeQueryComponent(itemId.toString())); - final response = await doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: null, + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future unstarArticle({required final int itemId}) async { + Future> unstarArticle({required final int itemId}) async { + final rawResponse = unstarArticleRaw( + itemId: itemId, + ); + + return rawResponse.future; + } + + DynamiteRawResponse unstarArticleRaw({required final int itemId}) { var path = '/index.php/apps/news/api/v1-3/items/{itemId}/unstar'; final queryParameters = {}; final headers = {}; @@ -755,16 +978,19 @@ class NewsClient extends DynamiteClient { // coverage:ignore-end path = path.replaceAll('{itemId}', Uri.encodeQueryComponent(itemId.toString())); - final response = await doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: null, + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -1097,14 +1323,8 @@ final Serializers _serializers = (Serializers().toBuilder() ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonObject)]), ListBuilder.new)) .build(); -Serializers get newsSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeNews(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeNews(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/api/notes.openapi.dart b/packages/nextcloud/lib/src/api/notes.openapi.dart index 086aed41..0eeb21f4 100644 --- a/packages/nextcloud/lib/src/api/notes.openapi.dart +++ b/packages/nextcloud/lib/src/api/notes.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case import 'dart:convert'; @@ -36,7 +37,7 @@ class NotesClient extends DynamiteClient { authentications: client.authentications, ); - Future> getNotes({ + Future, void>> getNotes({ final String? category, final String exclude = '', final int pruneBefore = 0, @@ -44,6 +45,26 @@ class NotesClient extends DynamiteClient { final String? chunkCursor, final String? ifNoneMatch, }) async { + final rawResponse = getNotesRaw( + category: category, + exclude: exclude, + pruneBefore: pruneBefore, + chunkSize: chunkSize, + chunkCursor: chunkCursor, + ifNoneMatch: ifNoneMatch, + ); + + return rawResponse.future; + } + + DynamiteRawResponse, void> getNotesRaw({ + final String? category, + final String exclude = '', + final int pruneBefore = 0, + final int chunkSize = 0, + final String? chunkCursor, + final String? ifNoneMatch, + }) { const path = '/index.php/apps/notes/api/v1/notes'; final queryParameters = {}; final headers = { @@ -86,28 +107,46 @@ class NotesClient extends DynamiteClient { if (ifNoneMatch != null) { headers['If-None-Match'] = ifNoneMatch; } - final response = await doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse, void>( + response: doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(BuiltList, [FullType(NotesNote)]), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(BuiltList, [FullType(NotesNote)]), - )! as BuiltList; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future createNote({ + Future> createNote({ final String category = '', final String title = '', final String content = '', final int modified = 0, final int favorite = 0, }) async { + final rawResponse = createNoteRaw( + category: category, + title: title, + content: content, + modified: modified, + favorite: favorite, + ); + + return rawResponse.future; + } + + DynamiteRawResponse createNoteRaw({ + final String category = '', + final String title = '', + final String content = '', + final int modified = 0, + final int favorite = 0, + }) { const path = '/index.php/apps/notes/api/v1/notes'; final queryParameters = {}; final headers = { @@ -147,24 +186,40 @@ class NotesClient extends DynamiteClient { if (favorite != 0) { queryParameters['favorite'] = favorite.toString(); } - final response = await doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(NotesNote), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NotesNote))! - as NotesNote; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future getNote({ + Future> getNote({ required final int id, final String exclude = '', final String? ifNoneMatch, }) async { + final rawResponse = getNoteRaw( + id: id, + exclude: exclude, + ifNoneMatch: ifNoneMatch, + ); + + return rawResponse.future; + } + + DynamiteRawResponse getNoteRaw({ + required final int id, + final String exclude = '', + final String? ifNoneMatch, + }) { var path = '/index.php/apps/notes/api/v1/notes/{id}'; final queryParameters = {}; final headers = { @@ -196,20 +251,22 @@ class NotesClient extends DynamiteClient { if (ifNoneMatch != null) { headers['If-None-Match'] = ifNoneMatch; } - final response = await doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(NotesNote), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NotesNote))! - as NotesNote; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future updateNote({ + Future> updateNote({ required final int id, final String? content, final int? modified, @@ -218,6 +275,28 @@ class NotesClient extends DynamiteClient { final int? favorite, final String? ifMatch, }) async { + final rawResponse = updateNoteRaw( + id: id, + content: content, + modified: modified, + title: title, + category: category, + favorite: favorite, + ifMatch: ifMatch, + ); + + return rawResponse.future; + } + + DynamiteRawResponse updateNoteRaw({ + required final int id, + final String? content, + final int? modified, + final String? title, + final String? category, + final int? favorite, + final String? ifMatch, + }) { var path = '/index.php/apps/notes/api/v1/notes/{id}'; final queryParameters = {}; final headers = { @@ -261,20 +340,30 @@ class NotesClient extends DynamiteClient { if (ifMatch != null) { headers['If-Match'] = ifMatch; } - final response = await doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(NotesNote), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NotesNote))! - as NotesNote; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future deleteNote({required final int id}) async { + Future> deleteNote({required final int id}) async { + final rawResponse = deleteNoteRaw( + id: id, + ); + + return rawResponse.future; + } + + DynamiteRawResponse deleteNoteRaw({required final int id}) { var path = '/index.php/apps/notes/api/v1/notes/{id}'; final queryParameters = {}; final headers = { @@ -300,19 +389,28 @@ class NotesClient extends DynamiteClient { // coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); - final response = await doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(String), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return response.body; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future getSettings() async { + Future> getSettings() async { + final rawResponse = getSettingsRaw(); + + return rawResponse.future; + } + + DynamiteRawResponse getSettingsRaw() { const path = '/index.php/apps/notes/api/v1/settings'; final queryParameters = {}; final headers = { @@ -337,20 +435,30 @@ class NotesClient extends DynamiteClient { } // coverage:ignore-end - final response = await doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(NotesSettings), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NotesSettings))! - as NotesSettings; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } - Future updateSettings({required final NotesSettings settings}) async { + Future> updateSettings({required final NotesSettings settings}) async { + final rawResponse = updateSettingsRaw( + settings: settings, + ); + + return rawResponse.future; + } + + DynamiteRawResponse updateSettingsRaw({required final NotesSettings settings}) { const path = '/index.php/apps/notes/api/v1/settings'; final queryParameters = {}; final headers = { @@ -378,17 +486,19 @@ class NotesClient extends DynamiteClient { headers['Content-Type'] = 'application/json'; body = utf8.encode(json.encode(_jsonSerializers.serialize(settings, specifiedType: const FullType(NotesSettings)))) as Uint8List; - final response = await doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(NotesSettings), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NotesSettings))! - as NotesSettings; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -633,14 +743,8 @@ final Serializers _serializers = (Serializers().toBuilder() ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonObject)]), ListBuilder.new)) .build(); -Serializers get notesSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeNotes(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeNotes(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/api/notifications.openapi.dart b/packages/nextcloud/lib/src/api/notifications.openapi.dart index 3ecd9e6d..a2729e74 100644 --- a/packages/nextcloud/lib/src/api/notifications.openapi.dart +++ b/packages/nextcloud/lib/src/api/notifications.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case import 'dart:typed_data'; @@ -52,13 +53,34 @@ class NotificationsApiClient { /// Generate a notification for a user /// /// This endpoint requires admin access - Future generateNotification({ + Future> generateNotification({ required final String shortMessage, required final String userId, final String longMessage = '', final NotificationsApiGenerateNotificationApiVersion apiVersion = NotificationsApiGenerateNotificationApiVersion.v2, final String oCSAPIRequest = 'true', }) async { + final rawResponse = generateNotificationRaw( + shortMessage: shortMessage, + userId: userId, + longMessage: longMessage, + apiVersion: apiVersion, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Generate a notification for a user + /// + /// This endpoint requires admin access + DynamiteRawResponse generateNotificationRaw({ + required final String shortMessage, + required final String userId, + final String longMessage = '', + final NotificationsApiGenerateNotificationApiVersion apiVersion = NotificationsApiGenerateNotificationApiVersion.v2, + final String oCSAPIRequest = 'true', + }) { var path = '/ocs/v2.php/apps/notifications/api/{apiVersion}/admin_notifications/{userId}'; final queryParameters = {}; final headers = { @@ -90,19 +112,19 @@ class NotificationsApiClient { } path = path.replaceAll('{apiVersion}', Uri.encodeQueryComponent(apiVersion.name)); headers['OCS-APIRequest'] = oCSAPIRequest; - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(NotificationsApiGenerateNotificationResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(NotificationsApiGenerateNotificationResponseApplicationJson), - )! as NotificationsApiGenerateNotificationResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -119,6 +141,21 @@ class NotificationsEndpointClient { NotificationsEndpointListNotificationsApiVersion.v2, final String oCSAPIRequest = 'true', }) async { + final rawResponse = listNotificationsRaw( + apiVersion: apiVersion, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get all notifications + DynamiteRawResponse listNotificationsRaw({ + final NotificationsEndpointListNotificationsApiVersion apiVersion = + NotificationsEndpointListNotificationsApiVersion.v2, + final String oCSAPIRequest = 'true', + }) { var path = '/ocs/v2.php/apps/notifications/api/{apiVersion}/notifications'; final queryParameters = {}; final headers = { @@ -145,34 +182,44 @@ class NotificationsEndpointClient { // coverage:ignore-end path = path.replaceAll('{apiVersion}', Uri.encodeQueryComponent(apiVersion.name)); headers['OCS-APIRequest'] = oCSAPIRequest; - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(NotificationsEndpointListNotificationsResponseApplicationJson), + headersType: const FullType(NotificationsEndpointEndpointListNotificationsHeaders), + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return DynamiteResponse( - _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(NotificationsEndpointListNotificationsResponseApplicationJson), - )! as NotificationsEndpointListNotificationsResponseApplicationJson, - _jsonSerializers.deserialize( - response.responseHeaders, - specifiedType: const FullType(NotificationsEndpointEndpointListNotificationsHeaders), - )! as NotificationsEndpointEndpointListNotificationsHeaders, - ); - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Delete all notifications - Future deleteAllNotifications({ + Future> + deleteAllNotifications({ final NotificationsEndpointDeleteAllNotificationsApiVersion apiVersion = NotificationsEndpointDeleteAllNotificationsApiVersion.v2, final String oCSAPIRequest = 'true', }) async { + final rawResponse = deleteAllNotificationsRaw( + apiVersion: apiVersion, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Delete all notifications + DynamiteRawResponse + deleteAllNotificationsRaw({ + final NotificationsEndpointDeleteAllNotificationsApiVersion apiVersion = + NotificationsEndpointDeleteAllNotificationsApiVersion.v2, + final String oCSAPIRequest = 'true', + }) { var path = '/ocs/v2.php/apps/notifications/api/{apiVersion}/notifications'; final queryParameters = {}; final headers = { @@ -199,27 +246,42 @@ class NotificationsEndpointClient { // coverage:ignore-end path = path.replaceAll('{apiVersion}', Uri.encodeQueryComponent(apiVersion.name)); headers['OCS-APIRequest'] = oCSAPIRequest; - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(NotificationsEndpointDeleteAllNotificationsResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(NotificationsEndpointDeleteAllNotificationsResponseApplicationJson), - )! as NotificationsEndpointDeleteAllNotificationsResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get a notification - Future getNotification({ + Future> getNotification({ required final int id, final NotificationsEndpointGetNotificationApiVersion apiVersion = NotificationsEndpointGetNotificationApiVersion.v2, final String oCSAPIRequest = 'true', }) async { + final rawResponse = getNotificationRaw( + id: id, + apiVersion: apiVersion, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a notification + DynamiteRawResponse getNotificationRaw({ + required final int id, + final NotificationsEndpointGetNotificationApiVersion apiVersion = NotificationsEndpointGetNotificationApiVersion.v2, + final String oCSAPIRequest = 'true', + }) { var path = '/ocs/v2.php/apps/notifications/api/{apiVersion}/notifications/{id}'; final queryParameters = {}; final headers = { @@ -247,28 +309,44 @@ class NotificationsEndpointClient { path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); path = path.replaceAll('{apiVersion}', Uri.encodeQueryComponent(apiVersion.name)); headers['OCS-APIRequest'] = oCSAPIRequest; - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(NotificationsEndpointGetNotificationResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(NotificationsEndpointGetNotificationResponseApplicationJson), - )! as NotificationsEndpointGetNotificationResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Delete a notification - Future deleteNotification({ + Future> deleteNotification({ required final int id, final NotificationsEndpointDeleteNotificationApiVersion apiVersion = NotificationsEndpointDeleteNotificationApiVersion.v2, final String oCSAPIRequest = 'true', }) async { + final rawResponse = deleteNotificationRaw( + id: id, + apiVersion: apiVersion, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Delete a notification + DynamiteRawResponse deleteNotificationRaw({ + required final int id, + final NotificationsEndpointDeleteNotificationApiVersion apiVersion = + NotificationsEndpointDeleteNotificationApiVersion.v2, + final String oCSAPIRequest = 'true', + }) { var path = '/ocs/v2.php/apps/notifications/api/{apiVersion}/notifications/{id}'; final queryParameters = {}; final headers = { @@ -296,28 +374,44 @@ class NotificationsEndpointClient { path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); path = path.replaceAll('{apiVersion}', Uri.encodeQueryComponent(apiVersion.name)); headers['OCS-APIRequest'] = oCSAPIRequest; - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(NotificationsEndpointDeleteNotificationResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(NotificationsEndpointDeleteNotificationResponseApplicationJson), - )! as NotificationsEndpointDeleteNotificationResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Check if notification IDs exist - Future confirmIdsForUser({ + Future> confirmIdsForUser({ required final List ids, final NotificationsEndpointConfirmIdsForUserApiVersion apiVersion = NotificationsEndpointConfirmIdsForUserApiVersion.v2, final String oCSAPIRequest = 'true', }) async { + final rawResponse = confirmIdsForUserRaw( + ids: ids, + apiVersion: apiVersion, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Check if notification IDs exist + DynamiteRawResponse confirmIdsForUserRaw({ + required final List ids, + final NotificationsEndpointConfirmIdsForUserApiVersion apiVersion = + NotificationsEndpointConfirmIdsForUserApiVersion.v2, + final String oCSAPIRequest = 'true', + }) { var path = '/ocs/v2.php/apps/notifications/api/{apiVersion}/notifications/exists'; final queryParameters = {}; final headers = { @@ -345,19 +439,19 @@ class NotificationsEndpointClient { queryParameters['ids[]'] = ids.map((final e) => e.toString()); path = path.replaceAll('{apiVersion}', Uri.encodeQueryComponent(apiVersion.name)); headers['OCS-APIRequest'] = oCSAPIRequest; - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200, 400}, + ), + bodyType: const FullType(NotificationsEndpointConfirmIdsForUserResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200 || response.statusCode == 400) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(NotificationsEndpointConfirmIdsForUserResponseApplicationJson), - )! as NotificationsEndpointConfirmIdsForUserResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -367,13 +461,32 @@ class NotificationsPushClient { final NotificationsClient _rootClient; /// Register device for push notifications - Future registerDevice({ + Future> registerDevice({ required final String pushTokenHash, required final String devicePublicKey, required final String proxyServer, final NotificationsPushRegisterDeviceApiVersion apiVersion = NotificationsPushRegisterDeviceApiVersion.v2, final String oCSAPIRequest = 'true', }) async { + final rawResponse = registerDeviceRaw( + pushTokenHash: pushTokenHash, + devicePublicKey: devicePublicKey, + proxyServer: proxyServer, + apiVersion: apiVersion, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Register device for push notifications + DynamiteRawResponse registerDeviceRaw({ + required final String pushTokenHash, + required final String devicePublicKey, + required final String proxyServer, + final NotificationsPushRegisterDeviceApiVersion apiVersion = NotificationsPushRegisterDeviceApiVersion.v2, + final String oCSAPIRequest = 'true', + }) { var path = '/ocs/v2.php/apps/notifications/api/{apiVersion}/push'; final queryParameters = {}; final headers = { @@ -403,26 +516,39 @@ class NotificationsPushClient { queryParameters['proxyServer'] = proxyServer; path = path.replaceAll('{apiVersion}', Uri.encodeQueryComponent(apiVersion.name)); headers['OCS-APIRequest'] = oCSAPIRequest; - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200, 201}, + ), + bodyType: const FullType(NotificationsPushRegisterDeviceResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200 || response.statusCode == 201) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(NotificationsPushRegisterDeviceResponseApplicationJson), - )! as NotificationsPushRegisterDeviceResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Remove a device from push notifications - Future removeDevice({ + Future> removeDevice({ final NotificationsPushRemoveDeviceApiVersion apiVersion = NotificationsPushRemoveDeviceApiVersion.v2, final String oCSAPIRequest = 'true', }) async { + final rawResponse = removeDeviceRaw( + apiVersion: apiVersion, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Remove a device from push notifications + DynamiteRawResponse removeDeviceRaw({ + final NotificationsPushRemoveDeviceApiVersion apiVersion = NotificationsPushRemoveDeviceApiVersion.v2, + final String oCSAPIRequest = 'true', + }) { var path = '/ocs/v2.php/apps/notifications/api/{apiVersion}/push'; final queryParameters = {}; final headers = { @@ -449,19 +575,19 @@ class NotificationsPushClient { // coverage:ignore-end path = path.replaceAll('{apiVersion}', Uri.encodeQueryComponent(apiVersion.name)); headers['OCS-APIRequest'] = oCSAPIRequest; - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200, 202, 401}, + ), + bodyType: const FullType(NotificationsPushRemoveDeviceResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200 || response.statusCode == 202 || response.statusCode == 401) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(NotificationsPushRemoveDeviceResponseApplicationJson), - )! as NotificationsPushRemoveDeviceResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -471,13 +597,32 @@ class NotificationsSettingsClient { final NotificationsClient _rootClient; /// Update personal notification settings - Future personal({ + Future> personal({ required final int batchSetting, required final String soundNotification, required final String soundTalk, final NotificationsSettingsPersonalApiVersion apiVersion = NotificationsSettingsPersonalApiVersion.v2, final String oCSAPIRequest = 'true', }) async { + final rawResponse = personalRaw( + batchSetting: batchSetting, + soundNotification: soundNotification, + soundTalk: soundTalk, + apiVersion: apiVersion, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Update personal notification settings + DynamiteRawResponse personalRaw({ + required final int batchSetting, + required final String soundNotification, + required final String soundTalk, + final NotificationsSettingsPersonalApiVersion apiVersion = NotificationsSettingsPersonalApiVersion.v2, + final String oCSAPIRequest = 'true', + }) { var path = '/ocs/v2.php/apps/notifications/api/{apiVersion}/settings'; final queryParameters = {}; final headers = { @@ -507,31 +652,52 @@ class NotificationsSettingsClient { queryParameters['soundTalk'] = soundTalk; path = path.replaceAll('{apiVersion}', Uri.encodeQueryComponent(apiVersion.name)); headers['OCS-APIRequest'] = oCSAPIRequest; - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(NotificationsSettingsPersonalResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(NotificationsSettingsPersonalResponseApplicationJson), - )! as NotificationsSettingsPersonalResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Update default notification settings for new users /// /// This endpoint requires admin access - Future admin({ + Future> admin({ required final int batchSetting, required final String soundNotification, required final String soundTalk, final NotificationsSettingsAdminApiVersion apiVersion = NotificationsSettingsAdminApiVersion.v2, final String oCSAPIRequest = 'true', }) async { + final rawResponse = adminRaw( + batchSetting: batchSetting, + soundNotification: soundNotification, + soundTalk: soundTalk, + apiVersion: apiVersion, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Update default notification settings for new users + /// + /// This endpoint requires admin access + DynamiteRawResponse adminRaw({ + required final int batchSetting, + required final String soundNotification, + required final String soundTalk, + final NotificationsSettingsAdminApiVersion apiVersion = NotificationsSettingsAdminApiVersion.v2, + final String oCSAPIRequest = 'true', + }) { var path = '/ocs/v2.php/apps/notifications/api/{apiVersion}/settings/admin'; final queryParameters = {}; final headers = { @@ -561,19 +727,19 @@ class NotificationsSettingsClient { queryParameters['soundTalk'] = soundTalk; path = path.replaceAll('{apiVersion}', Uri.encodeQueryComponent(apiVersion.name)); headers['OCS-APIRequest'] = oCSAPIRequest; - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(NotificationsSettingsAdminResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(NotificationsSettingsAdminResponseApplicationJson), - )! as NotificationsSettingsAdminResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -1917,14 +2083,8 @@ final Serializers _serializers = (Serializers().toBuilder() ..addBuilderFactory(const FullType(BuiltList, [FullType(String)]), ListBuilder.new)) .build(); -Serializers get notificationsSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeNotifications(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeNotifications(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart b/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart index 6bf28cb4..01b37ff4 100644 --- a/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart +++ b/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case import 'dart:typed_data'; @@ -55,7 +56,22 @@ class ProvisioningApiAppConfigClient { /// Get a list of apps /// /// This endpoint requires admin access - Future getApps({final bool oCSAPIRequest = true}) async { + Future> getApps({ + final bool oCSAPIRequest = true, + }) async { + final rawResponse = getAppsRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a list of apps + /// + /// This endpoint requires admin access + DynamiteRawResponse getAppsRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/provisioning_api/api/v1/config/apps'; final queryParameters = {}; final headers = { @@ -81,28 +97,43 @@ class ProvisioningApiAppConfigClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiAppConfigGetAppsResponseApplicationJson), - )! as ProvisioningApiAppConfigGetAppsResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiAppConfigGetAppsResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get the config keys of an app /// /// This endpoint requires admin access - Future getKeys({ + Future> getKeys({ required final String app, final bool oCSAPIRequest = true, }) async { + final rawResponse = getKeysRaw( + app: app, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the config keys of an app + /// + /// This endpoint requires admin access + DynamiteRawResponse getKeysRaw({ + required final String app, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/provisioning_api/api/v1/config/apps/{app}'; final queryParameters = {}; final headers = { @@ -129,30 +160,49 @@ class ProvisioningApiAppConfigClient { // coverage:ignore-end path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiAppConfigGetKeysResponseApplicationJson), - )! as ProvisioningApiAppConfigGetKeysResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiAppConfigGetKeysResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get a the config value of an app /// /// This endpoint requires admin access - Future getValue({ + Future> getValue({ required final String app, required final String key, final String defaultValue = '', final bool oCSAPIRequest = true, }) async { + final rawResponse = getValueRaw( + app: app, + key: key, + defaultValue: defaultValue, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a the config value of an app + /// + /// This endpoint requires admin access + DynamiteRawResponse getValueRaw({ + required final String app, + required final String key, + final String defaultValue = '', + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/provisioning_api/api/v1/config/apps/{app}/{key}'; final queryParameters = {}; final headers = { @@ -183,28 +233,45 @@ class ProvisioningApiAppConfigClient { queryParameters['defaultValue'] = defaultValue; } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiAppConfigGetValueResponseApplicationJson), - )! as ProvisioningApiAppConfigGetValueResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiAppConfigGetValueResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Update the config value of an app - Future setValue({ + Future> setValue({ required final String value, required final String app, required final String key, final bool oCSAPIRequest = true, }) async { + final rawResponse = setValueRaw( + value: value, + app: app, + key: key, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Update the config value of an app + DynamiteRawResponse setValueRaw({ + required final String value, + required final String app, + required final String key, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/provisioning_api/api/v1/config/apps/{app}/{key}'; final queryParameters = {}; final headers = { @@ -233,29 +300,46 @@ class ProvisioningApiAppConfigClient { path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); path = path.replaceAll('{key}', Uri.encodeQueryComponent(key)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiAppConfigSetValueResponseApplicationJson), - )! as ProvisioningApiAppConfigSetValueResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiAppConfigSetValueResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Delete a config key of an app /// /// This endpoint requires admin access - Future deleteKey({ + Future> deleteKey({ required final String app, required final String key, final bool oCSAPIRequest = true, }) async { + final rawResponse = deleteKeyRaw( + app: app, + key: key, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Delete a config key of an app + /// + /// This endpoint requires admin access + DynamiteRawResponse deleteKeyRaw({ + required final String app, + required final String key, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/provisioning_api/api/v1/config/apps/{app}/{key}'; final queryParameters = {}; final headers = { @@ -283,19 +367,19 @@ class ProvisioningApiAppConfigClient { path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); path = path.replaceAll('{key}', Uri.encodeQueryComponent(key)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiAppConfigDeleteKeyResponseApplicationJson), - )! as ProvisioningApiAppConfigDeleteKeyResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiAppConfigDeleteKeyResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -307,10 +391,25 @@ class ProvisioningApiAppsClient { /// Get a list of installed apps /// /// This endpoint requires admin access - Future getApps({ + Future> getApps({ final String? filter, final bool oCSAPIRequest = true, }) async { + final rawResponse = getAppsRaw( + filter: filter, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a list of installed apps + /// + /// This endpoint requires admin access + DynamiteRawResponse getAppsRaw({ + final String? filter, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/cloud/apps'; final queryParameters = {}; final headers = { @@ -339,28 +438,43 @@ class ProvisioningApiAppsClient { queryParameters['filter'] = filter; } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiAppsGetAppsResponseApplicationJson), - )! as ProvisioningApiAppsGetAppsResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiAppsGetAppsResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get the app info for an app /// /// This endpoint requires admin access - Future getAppInfo({ + Future> getAppInfo({ required final String app, final bool oCSAPIRequest = true, }) async { + final rawResponse = getAppInfoRaw( + app: app, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the app info for an app + /// + /// This endpoint requires admin access + DynamiteRawResponse getAppInfoRaw({ + required final String app, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/apps/{app}'; final queryParameters = {}; final headers = { @@ -387,28 +501,43 @@ class ProvisioningApiAppsClient { // coverage:ignore-end path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiAppsGetAppInfoResponseApplicationJson), - )! as ProvisioningApiAppsGetAppInfoResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiAppsGetAppInfoResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Enable an app /// /// This endpoint requires admin access - Future enable({ + Future> enable({ required final String app, final bool oCSAPIRequest = true, }) async { + final rawResponse = enableRaw( + app: app, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Enable an app + /// + /// This endpoint requires admin access + DynamiteRawResponse enableRaw({ + required final String app, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/apps/{app}'; final queryParameters = {}; final headers = { @@ -435,28 +564,43 @@ class ProvisioningApiAppsClient { // coverage:ignore-end path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiAppsEnableResponseApplicationJson), - )! as ProvisioningApiAppsEnableResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiAppsEnableResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Disable an app /// /// This endpoint requires admin access - Future disable({ + Future> disable({ required final String app, final bool oCSAPIRequest = true, }) async { + final rawResponse = disableRaw( + app: app, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Disable an app + /// + /// This endpoint requires admin access + DynamiteRawResponse disableRaw({ + required final String app, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/apps/{app}'; final queryParameters = {}; final headers = { @@ -483,19 +627,19 @@ class ProvisioningApiAppsClient { // coverage:ignore-end path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiAppsDisableResponseApplicationJson), - )! as ProvisioningApiAppsDisableResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiAppsDisableResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -505,12 +649,29 @@ class ProvisioningApiGroupsClient { final ProvisioningApiClient _rootClient; /// Get a list of groups - Future getGroups({ + Future> getGroups({ final String search = '', final int? limit, final int offset = 0, final bool oCSAPIRequest = true, }) async { + final rawResponse = getGroupsRaw( + search: search, + limit: limit, + offset: offset, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a list of groups + DynamiteRawResponse getGroupsRaw({ + final String search = '', + final int? limit, + final int offset = 0, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/cloud/groups'; final queryParameters = {}; final headers = { @@ -545,29 +706,46 @@ class ProvisioningApiGroupsClient { queryParameters['offset'] = offset.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiGroupsGetGroupsResponseApplicationJson), - )! as ProvisioningApiGroupsGetGroupsResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiGroupsGetGroupsResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Create a new group /// /// This endpoint requires admin access - Future addGroup({ + Future> addGroup({ required final String groupid, final String displayname = '', final bool oCSAPIRequest = true, }) async { + final rawResponse = addGroupRaw( + groupid: groupid, + displayname: displayname, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Create a new group + /// + /// This endpoint requires admin access + DynamiteRawResponse addGroupRaw({ + required final String groupid, + final String displayname = '', + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/cloud/groups'; final queryParameters = {}; final headers = { @@ -597,28 +775,45 @@ class ProvisioningApiGroupsClient { queryParameters['displayname'] = displayname; } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiGroupsAddGroupResponseApplicationJson), - )! as ProvisioningApiGroupsAddGroupResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiGroupsAddGroupResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get a list of groups details - Future getGroupsDetails({ + Future> getGroupsDetails({ final String search = '', final int? limit, final int offset = 0, final bool oCSAPIRequest = true, }) async { + final rawResponse = getGroupsDetailsRaw( + search: search, + limit: limit, + offset: offset, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a list of groups details + DynamiteRawResponse getGroupsDetailsRaw({ + final String search = '', + final int? limit, + final int offset = 0, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/cloud/groups/details'; final queryParameters = {}; final headers = { @@ -653,26 +848,39 @@ class ProvisioningApiGroupsClient { queryParameters['offset'] = offset.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiGroupsGetGroupsDetailsResponseApplicationJson), - )! as ProvisioningApiGroupsGetGroupsDetailsResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiGroupsGetGroupsDetailsResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get a list of users in the specified group - Future getGroupUsers({ + Future> getGroupUsers({ required final String groupId, final bool oCSAPIRequest = true, }) async { + final rawResponse = getGroupUsersRaw( + groupId: groupId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a list of users in the specified group + DynamiteRawResponse getGroupUsersRaw({ + required final String groupId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/groups/{groupId}/users'; final queryParameters = {}; final headers = { @@ -700,29 +908,49 @@ class ProvisioningApiGroupsClient { checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); // coverage:ignore-line path = path.replaceAll('{groupId}', Uri.encodeQueryComponent(groupId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiGroupsGetGroupUsersResponseApplicationJson), - )! as ProvisioningApiGroupsGetGroupUsersResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiGroupsGetGroupUsersResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get a list of users details in the specified group - Future getGroupUsersDetails({ + Future> + getGroupUsersDetails({ required final String groupId, final String search = '', final int? limit, final int offset = 0, final bool oCSAPIRequest = true, }) async { + final rawResponse = getGroupUsersDetailsRaw( + groupId: groupId, + search: search, + limit: limit, + offset: offset, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a list of users details in the specified group + DynamiteRawResponse getGroupUsersDetailsRaw({ + required final String groupId, + final String search = '', + final int? limit, + final int offset = 0, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/groups/{groupId}/users/details'; final queryParameters = {}; final headers = { @@ -759,28 +987,43 @@ class ProvisioningApiGroupsClient { queryParameters['offset'] = offset.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiGroupsGetGroupUsersDetailsResponseApplicationJson), - )! as ProvisioningApiGroupsGetGroupUsersDetailsResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiGroupsGetGroupUsersDetailsResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get the list of user IDs that are a subadmin of the group /// /// This endpoint requires admin access - Future getSubAdminsOfGroup({ + Future> getSubAdminsOfGroup({ required final String groupId, final bool oCSAPIRequest = true, }) async { + final rawResponse = getSubAdminsOfGroupRaw( + groupId: groupId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the list of user IDs that are a subadmin of the group + /// + /// This endpoint requires admin access + DynamiteRawResponse getSubAdminsOfGroupRaw({ + required final String groupId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/groups/{groupId}/subadmins'; final queryParameters = {}; final headers = { @@ -808,27 +1051,41 @@ class ProvisioningApiGroupsClient { checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); // coverage:ignore-line path = path.replaceAll('{groupId}', Uri.encodeQueryComponent(groupId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiGroupsGetSubAdminsOfGroupResponseApplicationJson), - )! as ProvisioningApiGroupsGetSubAdminsOfGroupResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiGroupsGetSubAdminsOfGroupResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get a list of users in the specified group @Deprecated('') - Future getGroup({ + Future> getGroup({ required final String groupId, final bool oCSAPIRequest = true, }) async { + final rawResponse = getGroupRaw( + groupId: groupId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a list of users in the specified group + @Deprecated('') + DynamiteRawResponse getGroupRaw({ + required final String groupId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/groups/{groupId}'; final queryParameters = {}; final headers = { @@ -856,30 +1113,49 @@ class ProvisioningApiGroupsClient { checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); // coverage:ignore-line path = path.replaceAll('{groupId}', Uri.encodeQueryComponent(groupId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiGroupsGetGroupResponseApplicationJson), - )! as ProvisioningApiGroupsGetGroupResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiGroupsGetGroupResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Update a group /// /// This endpoint requires admin access - Future updateGroup({ + Future> updateGroup({ required final String key, required final String value, required final String groupId, final bool oCSAPIRequest = true, }) async { + final rawResponse = updateGroupRaw( + key: key, + value: value, + groupId: groupId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Update a group + /// + /// This endpoint requires admin access + DynamiteRawResponse updateGroupRaw({ + required final String key, + required final String value, + required final String groupId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/groups/{groupId}'; final queryParameters = {}; final headers = { @@ -909,28 +1185,43 @@ class ProvisioningApiGroupsClient { checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); // coverage:ignore-line path = path.replaceAll('{groupId}', Uri.encodeQueryComponent(groupId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiGroupsUpdateGroupResponseApplicationJson), - )! as ProvisioningApiGroupsUpdateGroupResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiGroupsUpdateGroupResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Delete a group /// /// This endpoint requires admin access - Future deleteGroup({ + Future> deleteGroup({ required final String groupId, final bool oCSAPIRequest = true, }) async { + final rawResponse = deleteGroupRaw( + groupId: groupId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Delete a group + /// + /// This endpoint requires admin access + DynamiteRawResponse deleteGroupRaw({ + required final String groupId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/groups/{groupId}'; final queryParameters = {}; final headers = { @@ -958,19 +1249,19 @@ class ProvisioningApiGroupsClient { checkPattern(groupId, RegExp(r'^.+$'), 'groupId'); // coverage:ignore-line path = path.replaceAll('{groupId}', Uri.encodeQueryComponent(groupId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiGroupsDeleteGroupResponseApplicationJson), - )! as ProvisioningApiGroupsDeleteGroupResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiGroupsDeleteGroupResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -980,12 +1271,29 @@ class ProvisioningApiPreferencesClient { final ProvisioningApiClient _rootClient; /// Update a preference value of an app - Future setPreference({ + Future> setPreference({ required final String configValue, required final String appId, required final String configKey, final bool oCSAPIRequest = true, }) async { + final rawResponse = setPreferenceRaw( + configValue: configValue, + appId: appId, + configKey: configKey, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Update a preference value of an app + DynamiteRawResponse setPreferenceRaw({ + required final String configValue, + required final String appId, + required final String configKey, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/provisioning_api/api/v1/config/users/{appId}/{configKey}'; final queryParameters = {}; final headers = { @@ -1014,27 +1322,42 @@ class ProvisioningApiPreferencesClient { path = path.replaceAll('{appId}', Uri.encodeQueryComponent(appId)); path = path.replaceAll('{configKey}', Uri.encodeQueryComponent(configKey)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200 || response.statusCode == 400) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiPreferencesSetPreferenceResponseApplicationJson), - )! as ProvisioningApiPreferencesSetPreferenceResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200, 400}, + ), + bodyType: const FullType(ProvisioningApiPreferencesSetPreferenceResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Delete a preference for an app - Future deletePreference({ + Future> deletePreference({ required final String appId, required final String configKey, final bool oCSAPIRequest = true, }) async { + final rawResponse = deletePreferenceRaw( + appId: appId, + configKey: configKey, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Delete a preference for an app + DynamiteRawResponse deletePreferenceRaw({ + required final String appId, + required final String configKey, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/provisioning_api/api/v1/config/users/{appId}/{configKey}'; final queryParameters = {}; final headers = { @@ -1062,27 +1385,44 @@ class ProvisioningApiPreferencesClient { path = path.replaceAll('{appId}', Uri.encodeQueryComponent(appId)); path = path.replaceAll('{configKey}', Uri.encodeQueryComponent(configKey)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200 || response.statusCode == 400) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiPreferencesDeletePreferenceResponseApplicationJson), - )! as ProvisioningApiPreferencesDeletePreferenceResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200, 400}, + ), + bodyType: const FullType(ProvisioningApiPreferencesDeletePreferenceResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Update multiple preference values of an app - Future setMultiplePreferences({ + Future> + setMultiplePreferences({ required final ContentString> configs, required final String appId, final bool oCSAPIRequest = true, }) async { + final rawResponse = setMultiplePreferencesRaw( + configs: configs, + appId: appId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Update multiple preference values of an app + DynamiteRawResponse + setMultiplePreferencesRaw({ + required final ContentString> configs, + required final String appId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/provisioning_api/api/v1/config/users/{appId}'; final queryParameters = {}; final headers = { @@ -1115,27 +1455,44 @@ class ProvisioningApiPreferencesClient { ); path = path.replaceAll('{appId}', Uri.encodeQueryComponent(appId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200 || response.statusCode == 400) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiPreferencesSetMultiplePreferencesResponseApplicationJson), - )! as ProvisioningApiPreferencesSetMultiplePreferencesResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200, 400}, + ), + bodyType: const FullType(ProvisioningApiPreferencesSetMultiplePreferencesResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Delete multiple preferences for an app - Future deleteMultiplePreference({ + Future> + deleteMultiplePreference({ required final List configKeys, required final String appId, final bool oCSAPIRequest = true, }) async { + final rawResponse = deleteMultiplePreferenceRaw( + configKeys: configKeys, + appId: appId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Delete multiple preferences for an app + DynamiteRawResponse + deleteMultiplePreferenceRaw({ + required final List configKeys, + required final String appId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/provisioning_api/api/v1/config/users/{appId}'; final queryParameters = {}; final headers = { @@ -1163,19 +1520,19 @@ class ProvisioningApiPreferencesClient { queryParameters['configKeys[]'] = configKeys.map((final e) => e); path = path.replaceAll('{appId}', Uri.encodeQueryComponent(appId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200 || response.statusCode == 400) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiPreferencesDeleteMultiplePreferenceResponseApplicationJson), - )! as ProvisioningApiPreferencesDeleteMultiplePreferenceResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200, 400}, + ), + bodyType: const FullType(ProvisioningApiPreferencesDeleteMultiplePreferenceResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -1185,12 +1542,29 @@ class ProvisioningApiUsersClient { final ProvisioningApiClient _rootClient; /// Get a list of users - Future getUsers({ + Future> getUsers({ final String search = '', final int? limit, final int offset = 0, final bool oCSAPIRequest = true, }) async { + final rawResponse = getUsersRaw( + search: search, + limit: limit, + offset: offset, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a list of users + DynamiteRawResponse getUsersRaw({ + final String search = '', + final int? limit, + final int offset = 0, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/cloud/users'; final queryParameters = {}; final headers = { @@ -1225,23 +1599,23 @@ class ProvisioningApiUsersClient { queryParameters['offset'] = offset.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersGetUsersResponseApplicationJson), - )! as ProvisioningApiUsersGetUsersResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersGetUsersResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Create a new user - Future addUser({ + Future> addUser({ required final String userid, final String password = '', final String displayName = '', @@ -1253,6 +1627,35 @@ class ProvisioningApiUsersClient { final String? manager, final bool oCSAPIRequest = true, }) async { + final rawResponse = addUserRaw( + userid: userid, + password: password, + displayName: displayName, + email: email, + groups: groups, + subadmin: subadmin, + quota: quota, + language: language, + manager: manager, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Create a new user + DynamiteRawResponse addUserRaw({ + required final String userid, + final String password = '', + final String displayName = '', + final String email = '', + final List groups = const [], + final List subadmin = const [], + final String quota = '', + final String language = '', + final String? manager, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/cloud/users'; final queryParameters = {}; final headers = { @@ -1303,28 +1706,45 @@ class ProvisioningApiUsersClient { queryParameters['manager'] = manager; } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersAddUserResponseApplicationJson), - )! as ProvisioningApiUsersAddUserResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersAddUserResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get a list of users and their details - Future getUsersDetails({ + Future> getUsersDetails({ final String search = '', final int? limit, final int offset = 0, final bool oCSAPIRequest = true, }) async { + final rawResponse = getUsersDetailsRaw( + search: search, + limit: limit, + offset: offset, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a list of users and their details + DynamiteRawResponse getUsersDetailsRaw({ + final String search = '', + final int? limit, + final int offset = 0, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/cloud/users/details'; final queryParameters = {}; final headers = { @@ -1359,27 +1779,42 @@ class ProvisioningApiUsersClient { queryParameters['offset'] = offset.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersGetUsersDetailsResponseApplicationJson), - )! as ProvisioningApiUsersGetUsersDetailsResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersGetUsersDetailsResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Search users by their phone numbers - Future searchByPhoneNumbers({ + Future> searchByPhoneNumbers({ required final String location, required final ContentString>> search, final bool oCSAPIRequest = true, }) async { + final rawResponse = searchByPhoneNumbersRaw( + location: location, + search: search, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Search users by their phone numbers + DynamiteRawResponse searchByPhoneNumbersRaw({ + required final String location, + required final ContentString>> search, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/cloud/users/search/by-phone'; final queryParameters = {}; final headers = { @@ -1415,26 +1850,39 @@ class ProvisioningApiUsersClient { ]), ); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersSearchByPhoneNumbersResponseApplicationJson), - )! as ProvisioningApiUsersSearchByPhoneNumbersResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersSearchByPhoneNumbersResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get the details of a user - Future getUser({ + Future> getUser({ required final String userId, final bool oCSAPIRequest = true, }) async { + final rawResponse = getUserRaw( + userId: userId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the details of a user + DynamiteRawResponse getUserRaw({ + required final String userId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/users/{userId}'; final queryParameters = {}; final headers = { @@ -1461,28 +1909,45 @@ class ProvisioningApiUsersClient { // coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersGetUserResponseApplicationJson), - )! as ProvisioningApiUsersGetUserResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersGetUserResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Update a value of the user's details - Future editUser({ + Future> editUser({ required final String key, required final String value, required final String userId, final bool oCSAPIRequest = true, }) async { + final rawResponse = editUserRaw( + key: key, + value: value, + userId: userId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Update a value of the user's details + DynamiteRawResponse editUserRaw({ + required final String key, + required final String value, + required final String userId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/users/{userId}'; final queryParameters = {}; final headers = { @@ -1511,26 +1976,39 @@ class ProvisioningApiUsersClient { queryParameters['value'] = value; path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersEditUserResponseApplicationJson), - )! as ProvisioningApiUsersEditUserResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersEditUserResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Delete a user - Future deleteUser({ + Future> deleteUser({ required final String userId, final bool oCSAPIRequest = true, }) async { + final rawResponse = deleteUserRaw( + userId: userId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Delete a user + DynamiteRawResponse deleteUserRaw({ + required final String userId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/users/{userId}'; final queryParameters = {}; final headers = { @@ -1557,25 +2035,36 @@ class ProvisioningApiUsersClient { // coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersDeleteUserResponseApplicationJson), - )! as ProvisioningApiUsersDeleteUserResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersDeleteUserResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get the details of the current user - Future getCurrentUser({ + Future> getCurrentUser({ final bool oCSAPIRequest = true, }) async { + final rawResponse = getCurrentUserRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the details of the current user + DynamiteRawResponse getCurrentUserRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/cloud/user'; final queryParameters = {}; final headers = { @@ -1601,25 +2090,36 @@ class ProvisioningApiUsersClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersGetCurrentUserResponseApplicationJson), - )! as ProvisioningApiUsersGetCurrentUserResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersGetCurrentUserResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get a list of fields that are editable for the current user - Future getEditableFields({ + Future> getEditableFields({ final bool oCSAPIRequest = true, }) async { + final rawResponse = getEditableFieldsRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a list of fields that are editable for the current user + DynamiteRawResponse getEditableFieldsRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/cloud/user/fields'; final queryParameters = {}; final headers = { @@ -1645,26 +2145,41 @@ class ProvisioningApiUsersClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersGetEditableFieldsResponseApplicationJson), - )! as ProvisioningApiUsersGetEditableFieldsResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersGetEditableFieldsResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get a list of fields that are editable for a user - Future getEditableFieldsForUser({ + Future> + getEditableFieldsForUser({ required final String userId, final bool oCSAPIRequest = true, }) async { + final rawResponse = getEditableFieldsForUserRaw( + userId: userId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a list of fields that are editable for a user + DynamiteRawResponse + getEditableFieldsForUserRaw({ + required final String userId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/user/fields/{userId}'; final queryParameters = {}; final headers = { @@ -1691,29 +2206,48 @@ class ProvisioningApiUsersClient { // coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersGetEditableFieldsForUserResponseApplicationJson), - )! as ProvisioningApiUsersGetEditableFieldsForUserResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersGetEditableFieldsForUserResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Update multiple values of the user's details - Future editUserMultiValue({ + Future> editUserMultiValue({ required final String key, required final String value, required final String userId, required final String collectionName, final bool oCSAPIRequest = true, }) async { + final rawResponse = editUserMultiValueRaw( + key: key, + value: value, + userId: userId, + collectionName: collectionName, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Update multiple values of the user's details + DynamiteRawResponse editUserMultiValueRaw({ + required final String key, + required final String value, + required final String userId, + required final String collectionName, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/users/{userId}/{collectionName}'; final queryParameters = {}; final headers = { @@ -1748,26 +2282,39 @@ class ProvisioningApiUsersClient { ); // coverage:ignore-line path = path.replaceAll('{collectionName}', Uri.encodeQueryComponent(collectionName)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersEditUserMultiValueResponseApplicationJson), - )! as ProvisioningApiUsersEditUserMultiValueResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersEditUserMultiValueResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Wipe all devices of a user - Future wipeUserDevices({ + Future> wipeUserDevices({ required final String userId, final bool oCSAPIRequest = true, }) async { + final rawResponse = wipeUserDevicesRaw( + userId: userId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Wipe all devices of a user + DynamiteRawResponse wipeUserDevicesRaw({ + required final String userId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/users/{userId}/wipe'; final queryParameters = {}; final headers = { @@ -1794,26 +2341,39 @@ class ProvisioningApiUsersClient { // coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersWipeUserDevicesResponseApplicationJson), - )! as ProvisioningApiUsersWipeUserDevicesResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersWipeUserDevicesResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Enable a user - Future enableUser({ + Future> enableUser({ required final String userId, final bool oCSAPIRequest = true, }) async { + final rawResponse = enableUserRaw( + userId: userId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Enable a user + DynamiteRawResponse enableUserRaw({ + required final String userId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/users/{userId}/enable'; final queryParameters = {}; final headers = { @@ -1840,26 +2400,39 @@ class ProvisioningApiUsersClient { // coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersEnableUserResponseApplicationJson), - )! as ProvisioningApiUsersEnableUserResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersEnableUserResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Disable a user - Future disableUser({ + Future> disableUser({ required final String userId, final bool oCSAPIRequest = true, }) async { + final rawResponse = disableUserRaw( + userId: userId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Disable a user + DynamiteRawResponse disableUserRaw({ + required final String userId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/users/{userId}/disable'; final queryParameters = {}; final headers = { @@ -1886,26 +2459,39 @@ class ProvisioningApiUsersClient { // coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersDisableUserResponseApplicationJson), - )! as ProvisioningApiUsersDisableUserResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersDisableUserResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get a list of groups the user belongs to - Future getUsersGroups({ + Future> getUsersGroups({ required final String userId, final bool oCSAPIRequest = true, }) async { + final rawResponse = getUsersGroupsRaw( + userId: userId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get a list of groups the user belongs to + DynamiteRawResponse getUsersGroupsRaw({ + required final String userId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/users/{userId}/groups'; final queryParameters = {}; final headers = { @@ -1932,27 +2518,42 @@ class ProvisioningApiUsersClient { // coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersGetUsersGroupsResponseApplicationJson), - )! as ProvisioningApiUsersGetUsersGroupsResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersGetUsersGroupsResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Add a user to a group - Future addToGroup({ + Future> addToGroup({ required final String userId, final String groupid = '', final bool oCSAPIRequest = true, }) async { + final rawResponse = addToGroupRaw( + userId: userId, + groupid: groupid, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Add a user to a group + DynamiteRawResponse addToGroupRaw({ + required final String userId, + final String groupid = '', + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/users/{userId}/groups'; final queryParameters = {}; final headers = { @@ -1982,27 +2583,42 @@ class ProvisioningApiUsersClient { queryParameters['groupid'] = groupid; } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersAddToGroupResponseApplicationJson), - )! as ProvisioningApiUsersAddToGroupResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersAddToGroupResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Remove a user from a group - Future removeFromGroup({ + Future> removeFromGroup({ required final String groupid, required final String userId, final bool oCSAPIRequest = true, }) async { + final rawResponse = removeFromGroupRaw( + groupid: groupid, + userId: userId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Remove a user from a group + DynamiteRawResponse removeFromGroupRaw({ + required final String groupid, + required final String userId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/users/{userId}/groups'; final queryParameters = {}; final headers = { @@ -2030,28 +2646,44 @@ class ProvisioningApiUsersClient { queryParameters['groupid'] = groupid; path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersRemoveFromGroupResponseApplicationJson), - )! as ProvisioningApiUsersRemoveFromGroupResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersRemoveFromGroupResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get the groups a user is a subadmin of /// /// This endpoint requires admin access - Future getUserSubAdminGroups({ + Future> + getUserSubAdminGroups({ required final String userId, final bool oCSAPIRequest = true, }) async { + final rawResponse = getUserSubAdminGroupsRaw( + userId: userId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the groups a user is a subadmin of + /// + /// This endpoint requires admin access + DynamiteRawResponse getUserSubAdminGroupsRaw({ + required final String userId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/users/{userId}/subadmins'; final queryParameters = {}; final headers = { @@ -2078,29 +2710,46 @@ class ProvisioningApiUsersClient { // coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersGetUserSubAdminGroupsResponseApplicationJson), - )! as ProvisioningApiUsersGetUserSubAdminGroupsResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersGetUserSubAdminGroupsResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Make a user a subadmin of a group /// /// This endpoint requires admin access - Future addSubAdmin({ + Future> addSubAdmin({ required final String groupid, required final String userId, final bool oCSAPIRequest = true, }) async { + final rawResponse = addSubAdminRaw( + groupid: groupid, + userId: userId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Make a user a subadmin of a group + /// + /// This endpoint requires admin access + DynamiteRawResponse addSubAdminRaw({ + required final String groupid, + required final String userId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/users/{userId}/subadmins'; final queryParameters = {}; final headers = { @@ -2128,29 +2777,46 @@ class ProvisioningApiUsersClient { queryParameters['groupid'] = groupid; path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersAddSubAdminResponseApplicationJson), - )! as ProvisioningApiUsersAddSubAdminResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersAddSubAdminResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Remove a user from the subadmins of a group /// /// This endpoint requires admin access - Future removeSubAdmin({ + Future> removeSubAdmin({ required final String groupid, required final String userId, final bool oCSAPIRequest = true, }) async { + final rawResponse = removeSubAdminRaw( + groupid: groupid, + userId: userId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Remove a user from the subadmins of a group + /// + /// This endpoint requires admin access + DynamiteRawResponse removeSubAdminRaw({ + required final String groupid, + required final String userId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/users/{userId}/subadmins'; final queryParameters = {}; final headers = { @@ -2178,26 +2844,39 @@ class ProvisioningApiUsersClient { queryParameters['groupid'] = groupid; path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersRemoveSubAdminResponseApplicationJson), - )! as ProvisioningApiUsersRemoveSubAdminResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersRemoveSubAdminResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Resend the welcome message - Future resendWelcomeMessage({ + Future> resendWelcomeMessage({ required final String userId, final bool oCSAPIRequest = true, }) async { + final rawResponse = resendWelcomeMessageRaw( + userId: userId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Resend the welcome message + DynamiteRawResponse resendWelcomeMessageRaw({ + required final String userId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/cloud/users/{userId}/welcome'; final queryParameters = {}; final headers = { @@ -2224,19 +2903,19 @@ class ProvisioningApiUsersClient { // coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ProvisioningApiUsersResendWelcomeMessageResponseApplicationJson), - )! as ProvisioningApiUsersResendWelcomeMessageResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ProvisioningApiUsersResendWelcomeMessageResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -7181,14 +7860,8 @@ final Serializers _serializers = (Serializers().toBuilder() ..add(ProvisioningApiCapabilities_ProvisioningApi.serializer)) .build(); -Serializers get provisioningApiSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeProvisioningApi(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeProvisioningApi(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/api/settings.openapi.dart b/packages/nextcloud/lib/src/api/settings.openapi.dart index f2123319..00389a9d 100644 --- a/packages/nextcloud/lib/src/api/settings.openapi.dart +++ b/packages/nextcloud/lib/src/api/settings.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case import 'dart:typed_data'; @@ -45,6 +46,15 @@ class SettingsLogSettingsClient { /// /// This endpoint requires admin access Future> download() async { + final rawResponse = downloadRaw(); + + return rawResponse.future; + } + + /// download logfile + /// + /// This endpoint requires admin access + DynamiteRawResponse downloadRaw() { const path = '/index.php/settings/admin/log/download'; final queryParameters = {}; final headers = { @@ -69,22 +79,19 @@ class SettingsLogSettingsClient { } // coverage:ignore-end - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(Uint8List), + headersType: const FullType(SettingsLogSettingsLogSettingsDownloadHeaders), + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return DynamiteResponse( - await response.bodyBytes, - _jsonSerializers.deserialize( - response.responseHeaders, - specifiedType: const FullType(SettingsLogSettingsLogSettingsDownloadHeaders), - )! as SettingsLogSettingsLogSettingsDownloadHeaders, - ); - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -176,14 +183,8 @@ final Serializers _serializers = (Serializers().toBuilder() ..add(SettingsLogSettingsLogSettingsDownloadHeaders.serializer)) .build(); -Serializers get settingsSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeSettings(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeSettings(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/api/sharebymail.openapi.dart b/packages/nextcloud/lib/src/api/sharebymail.openapi.dart index bc71e019..79f4a197 100644 --- a/packages/nextcloud/lib/src/api/sharebymail.openapi.dart +++ b/packages/nextcloud/lib/src/api/sharebymail.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case @@ -273,14 +274,8 @@ final Serializers _serializers = (Serializers().toBuilder() ..add(SharebymailCapabilities_FilesSharing_Sharebymail_ExpireDate.serializer)) .build(); -Serializers get sharebymailSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeSharebymail(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeSharebymail(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/api/theming.openapi.dart b/packages/nextcloud/lib/src/api/theming.openapi.dart index 55b0e313..2ce57726 100644 --- a/packages/nextcloud/lib/src/api/theming.openapi.dart +++ b/packages/nextcloud/lib/src/api/theming.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case import 'dart:typed_data'; @@ -49,7 +50,16 @@ class ThemingIconClient { final ThemingClient _rootClient; /// Return a 32x32 favicon as png - Future getFavicon({final String app = 'core'}) async { + Future> getFavicon({final String app = 'core'}) async { + final rawResponse = getFaviconRaw( + app: app, + ); + + return rawResponse.future; + } + + /// Return a 32x32 favicon as png + DynamiteRawResponse getFaviconRaw({final String app = 'core'}) { var path = '/index.php/apps/theming/favicon/{app}'; final queryParameters = {}; final headers = { @@ -73,20 +83,32 @@ class ThemingIconClient { // coverage:ignore-end path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return response.bodyBytes; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(Uint8List), + headersType: null, + serializers: _jsonSerializers, + ); } /// Return a 512x512 icon for touch devices - Future getTouchIcon({final String app = 'core'}) async { + Future> getTouchIcon({final String app = 'core'}) async { + final rawResponse = getTouchIconRaw( + app: app, + ); + + return rawResponse.future; + } + + /// Return a 512x512 icon for touch devices + DynamiteRawResponse getTouchIconRaw({final String app = 'core'}) { var path = '/index.php/apps/theming/icon/{app}'; final queryParameters = {}; final headers = { @@ -110,23 +132,39 @@ class ThemingIconClient { // coverage:ignore-end path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return response.bodyBytes; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(Uint8List), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get a themed icon - Future getThemedIcon({ + Future> getThemedIcon({ required final String app, required final String image, }) async { + final rawResponse = getThemedIconRaw( + app: app, + image: image, + ); + + return rawResponse.future; + } + + /// Get a themed icon + DynamiteRawResponse getThemedIconRaw({ + required final String app, + required final String image, + }) { var path = '/index.php/apps/theming/img/{app}/{image}'; final queryParameters = {}; final headers = { @@ -152,16 +190,19 @@ class ThemingIconClient { path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); checkPattern(image, RegExp(r'^.+$'), 'image'); // coverage:ignore-line path = path.replaceAll('{image}', Uri.encodeQueryComponent(image)); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return response.bodyBytes; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(Uint8List), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -173,11 +214,26 @@ class ThemingThemingClient { final ThemingClient _rootClient; /// Get the CSS stylesheet for a theme - Future getThemeStylesheet({ + Future> getThemeStylesheet({ required final String themeId, final int plain = 0, final int withCustomCss = 0, }) async { + final rawResponse = getThemeStylesheetRaw( + themeId: themeId, + plain: plain, + withCustomCss: withCustomCss, + ); + + return rawResponse.future; + } + + /// Get the CSS stylesheet for a theme + DynamiteRawResponse getThemeStylesheetRaw({ + required final String themeId, + final int plain = 0, + final int withCustomCss = 0, + }) { var path = '/index.php/apps/theming/theme/{themeId}.css'; final queryParameters = {}; final headers = { @@ -207,23 +263,39 @@ class ThemingThemingClient { if (withCustomCss != 0) { queryParameters['withCustomCss'] = withCustomCss.toString(); } - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return response.body; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(String), + headersType: null, + serializers: _jsonSerializers, + ); } /// Get an image - Future getImage({ + Future> getImage({ required final String key, final int useSvg = 1, }) async { + final rawResponse = getImageRaw( + key: key, + useSvg: useSvg, + ); + + return rawResponse.future; + } + + /// Get an image + DynamiteRawResponse getImageRaw({ + required final String key, + final int useSvg = 1, + }) { var path = '/index.php/apps/theming/image/{key}'; final queryParameters = {}; final headers = { @@ -250,20 +322,36 @@ class ThemingThemingClient { if (useSvg != 1) { queryParameters['useSvg'] = useSvg.toString(); } - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return response.bodyBytes; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(Uint8List), + headersType: null, + serializers: _jsonSerializers, + ); + } + + /// Get the manifest for an app + Future> getManifest({ + required final String app, + }) async { + final rawResponse = getManifestRaw( + app: app, + ); + + return rawResponse.future; } /// Get the manifest for an app - Future getManifest({required final String app}) async { + DynamiteRawResponse getManifestRaw({ + required final String app, + }) { var path = '/index.php/apps/theming/manifest/{app}'; final queryParameters = {}; final headers = { @@ -287,19 +375,19 @@ class ThemingThemingClient { // coverage:ignore-end path = path.replaceAll('{app}', Uri.encodeQueryComponent(app)); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ThemingThemingGetManifestResponseApplicationJson), - )! as ThemingThemingGetManifestResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ThemingThemingGetManifestResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -309,7 +397,16 @@ class ThemingUserThemeClient { final ThemingClient _rootClient; /// Get the background image - Future getBackground({final bool oCSAPIRequest = true}) async { + Future> getBackground({final bool oCSAPIRequest = true}) async { + final rawResponse = getBackgroundRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the background image + DynamiteRawResponse getBackgroundRaw({final bool oCSAPIRequest = true}) { const path = '/index.php/apps/theming/background'; final queryParameters = {}; final headers = { @@ -335,25 +432,45 @@ class ThemingUserThemeClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return response.bodyBytes; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(Uint8List), + headersType: null, + serializers: _jsonSerializers, + ); } /// Set the background - Future setBackground({ + Future> setBackground({ required final String type, final String value = '', final String? color, final bool oCSAPIRequest = true, }) async { + final rawResponse = setBackgroundRaw( + type: type, + value: value, + color: color, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Set the background + DynamiteRawResponse setBackgroundRaw({ + required final String type, + final String value = '', + final String? color, + final bool oCSAPIRequest = true, + }) { var path = '/index.php/apps/theming/background/{type}'; final queryParameters = {}; final headers = { @@ -386,21 +503,32 @@ class ThemingUserThemeClient { queryParameters['color'] = color; } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(ThemingBackground))! - as ThemingBackground; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ThemingBackground), + headersType: null, + serializers: _jsonSerializers, + ); } /// Delete the background - Future deleteBackground({final bool oCSAPIRequest = true}) async { + Future> deleteBackground({final bool oCSAPIRequest = true}) async { + final rawResponse = deleteBackgroundRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Delete the background + DynamiteRawResponse deleteBackgroundRaw({final bool oCSAPIRequest = true}) { const path = '/index.php/apps/theming/background/custom'; final queryParameters = {}; final headers = { @@ -426,24 +554,39 @@ class ThemingUserThemeClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(ThemingBackground))! - as ThemingBackground; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ThemingBackground), + headersType: null, + serializers: _jsonSerializers, + ); } /// Enable theme - Future enableTheme({ + Future> enableTheme({ required final String themeId, final bool oCSAPIRequest = true, }) async { + final rawResponse = enableThemeRaw( + themeId: themeId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Enable theme + DynamiteRawResponse enableThemeRaw({ + required final String themeId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/theming/api/v1/theme/{themeId}/enable'; final queryParameters = {}; final headers = { @@ -470,26 +613,39 @@ class ThemingUserThemeClient { // coverage:ignore-end path = path.replaceAll('{themeId}', Uri.encodeQueryComponent(themeId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ThemingUserThemeEnableThemeResponseApplicationJson), - )! as ThemingUserThemeEnableThemeResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ThemingUserThemeEnableThemeResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } /// Disable theme - Future disableTheme({ + Future> disableTheme({ required final String themeId, final bool oCSAPIRequest = true, }) async { + final rawResponse = disableThemeRaw( + themeId: themeId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Disable theme + DynamiteRawResponse disableThemeRaw({ + required final String themeId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/theming/api/v1/theme/{themeId}'; final queryParameters = {}; final headers = { @@ -516,19 +672,19 @@ class ThemingUserThemeClient { // coverage:ignore-end path = path.replaceAll('{themeId}', Uri.encodeQueryComponent(themeId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(ThemingUserThemeDisableThemeResponseApplicationJson), - )! as ThemingUserThemeDisableThemeResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(ThemingUserThemeDisableThemeResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, + ); } } @@ -941,14 +1097,8 @@ final Serializers _serializers = (Serializers().toBuilder() ..add(ThemingPublicCapabilities_Theming.serializer)) .build(); -Serializers get themingSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeTheming(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeTheming(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/api/updatenotification.openapi.dart b/packages/nextcloud/lib/src/api/updatenotification.openapi.dart index 10d4f71e..52e28318 100644 --- a/packages/nextcloud/lib/src/api/updatenotification.openapi.dart +++ b/packages/nextcloud/lib/src/api/updatenotification.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case import 'dart:typed_data'; @@ -45,11 +46,28 @@ class UpdatenotificationApiClient { /// List available updates for apps /// /// This endpoint requires admin access - Future getAppList({ + Future> getAppList({ required final String newVersion, final UpdatenotificationApiGetAppListApiVersion apiVersion = UpdatenotificationApiGetAppListApiVersion.v1, final bool oCSAPIRequest = true, }) async { + final rawResponse = getAppListRaw( + newVersion: newVersion, + apiVersion: apiVersion, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// List available updates for apps + /// + /// This endpoint requires admin access + DynamiteRawResponse getAppListRaw({ + required final String newVersion, + final UpdatenotificationApiGetAppListApiVersion apiVersion = UpdatenotificationApiGetAppListApiVersion.v1, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/updatenotification/api/{apiVersion}/applist/{newVersion}'; final queryParameters = {}; final headers = { @@ -77,19 +95,19 @@ class UpdatenotificationApiClient { path = path.replaceAll('{newVersion}', Uri.encodeQueryComponent(newVersion)); path = path.replaceAll('{apiVersion}', Uri.encodeQueryComponent(apiVersion.name)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(UpdatenotificationApiGetAppListResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UpdatenotificationApiGetAppListResponseApplicationJson), - )! as UpdatenotificationApiGetAppListResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -305,15 +323,8 @@ final Serializers _serializers = (Serializers().toBuilder() )) .build(); -Serializers get updatenotificationSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeUpdatenotification(final Object data) => - _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeUpdatenotification(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/api/uppush.openapi.dart b/packages/nextcloud/lib/src/api/uppush.openapi.dart index 6a766bf2..55976672 100644 --- a/packages/nextcloud/lib/src/api/uppush.openapi.dart +++ b/packages/nextcloud/lib/src/api/uppush.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case import 'dart:typed_data'; @@ -35,7 +36,14 @@ class UppushClient extends DynamiteClient { ); /// Check if the UnifiedPush provider is present - Future check() async { + Future> check() async { + final rawResponse = checkRaw(); + + return rawResponse.future; + } + + /// Check if the UnifiedPush provider is present + DynamiteRawResponse checkRaw() { const path = '/index.php/apps/uppush'; final queryParameters = {}; final headers = { @@ -60,25 +68,38 @@ class UppushClient extends DynamiteClient { } // coverage:ignore-end - final response = await doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(UppushCheckResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UppushCheckResponseApplicationJson), - )! as UppushCheckResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Set keepalive interval /// /// This endpoint requires admin access - Future setKeepalive({required final int keepalive}) async { + Future> setKeepalive({ + required final int keepalive, + }) async { + final rawResponse = setKeepaliveRaw( + keepalive: keepalive, + ); + + return rawResponse.future; + } + + /// Set keepalive interval + /// + /// This endpoint requires admin access + DynamiteRawResponse setKeepaliveRaw({required final int keepalive}) { const path = '/index.php/apps/uppush/keepalive'; final queryParameters = {}; final headers = { @@ -104,23 +125,36 @@ class UppushClient extends DynamiteClient { // coverage:ignore-end queryParameters['keepalive'] = keepalive.toString(); - final response = await doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(UppushSetKeepaliveResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UppushSetKeepaliveResponseApplicationJson), - )! as UppushSetKeepaliveResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Request to create a new deviceId - Future createDevice({required final String deviceName}) async { + Future> createDevice({ + required final String deviceName, + }) async { + final rawResponse = createDeviceRaw( + deviceName: deviceName, + ); + + return rawResponse.future; + } + + /// Request to create a new deviceId + DynamiteRawResponse createDeviceRaw({ + required final String deviceName, + }) { const path = '/index.php/apps/uppush/device'; final queryParameters = {}; final headers = { @@ -146,25 +180,38 @@ class UppushClient extends DynamiteClient { // coverage:ignore-end queryParameters['deviceName'] = deviceName; - final response = await doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(UppushCreateDeviceResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UppushCreateDeviceResponseApplicationJson), - )! as UppushCreateDeviceResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Request to get push messages /// /// This is a public page since it has to be handle by the non-connected app (NextPush app and not Nextcloud-app) - Future syncDevice({required final String deviceId}) async { + Future> syncDevice({ + required final String deviceId, + }) async { + final rawResponse = syncDeviceRaw( + deviceId: deviceId, + ); + + return rawResponse.future; + } + + /// Request to get push messages + /// + /// This is a public page since it has to be handle by the non-connected app (NextPush app and not Nextcloud-app) + DynamiteRawResponse syncDeviceRaw({required final String deviceId}) { var path = '/index.php/apps/uppush/device/{deviceId}'; final queryParameters = {}; final headers = { @@ -190,23 +237,36 @@ class UppushClient extends DynamiteClient { // coverage:ignore-end path = path.replaceAll('{deviceId}', Uri.encodeQueryComponent(deviceId)); - final response = await doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'get', + uri, + headers, + body, + const {401}, + ), + bodyType: const FullType(UppushSyncDeviceResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 401) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UppushSyncDeviceResponseApplicationJson), - )! as UppushSyncDeviceResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Delete a device - Future deleteDevice({required final String deviceId}) async { + Future> deleteDevice({ + required final String deviceId, + }) async { + final rawResponse = deleteDeviceRaw( + deviceId: deviceId, + ); + + return rawResponse.future; + } + + /// Delete a device + DynamiteRawResponse deleteDeviceRaw({ + required final String deviceId, + }) { var path = '/index.php/apps/uppush/device/{deviceId}'; final queryParameters = {}; final headers = { @@ -232,26 +292,39 @@ class UppushClient extends DynamiteClient { // coverage:ignore-end path = path.replaceAll('{deviceId}', Uri.encodeQueryComponent(deviceId)); - final response = await doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(UppushDeleteDeviceResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UppushDeleteDeviceResponseApplicationJson), - )! as UppushDeleteDeviceResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Create an authorization token for a new 3rd party service - Future createApp({ + Future> createApp({ required final String deviceId, required final String appName, }) async { + final rawResponse = createAppRaw( + deviceId: deviceId, + appName: appName, + ); + + return rawResponse.future; + } + + /// Create an authorization token for a new 3rd party service + DynamiteRawResponse createAppRaw({ + required final String deviceId, + required final String appName, + }) { const path = '/index.php/apps/uppush/app'; final queryParameters = {}; final headers = { @@ -278,23 +351,34 @@ class UppushClient extends DynamiteClient { // coverage:ignore-end queryParameters['deviceId'] = deviceId; queryParameters['appName'] = appName; - final response = await doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(UppushCreateAppResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UppushCreateAppResponseApplicationJson), - )! as UppushCreateAppResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Delete an authorization token - Future deleteApp({required final String token}) async { + Future> deleteApp({ + required final String token, + }) async { + final rawResponse = deleteAppRaw( + token: token, + ); + + return rawResponse.future; + } + + /// Delete an authorization token + DynamiteRawResponse deleteAppRaw({required final String token}) { var path = '/index.php/apps/uppush/app/{token}'; final queryParameters = {}; final headers = { @@ -320,23 +404,36 @@ class UppushClient extends DynamiteClient { // coverage:ignore-end path = path.replaceAll('{token}', Uri.encodeQueryComponent(token)); - final response = await doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(UppushDeleteAppResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UppushDeleteAppResponseApplicationJson), - )! as UppushDeleteAppResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Unifiedpush discovery Following specifications - Future unifiedpushDiscovery({required final String token}) async { + Future> unifiedpushDiscovery({ + required final String token, + }) async { + final rawResponse = unifiedpushDiscoveryRaw( + token: token, + ); + + return rawResponse.future; + } + + /// Unifiedpush discovery Following specifications + DynamiteRawResponse unifiedpushDiscoveryRaw({ + required final String token, + }) { var path = '/index.php/apps/uppush/push/{token}'; final queryParameters = {}; final headers = { @@ -362,23 +459,32 @@ class UppushClient extends DynamiteClient { // coverage:ignore-end path = path.replaceAll('{token}', Uri.encodeQueryComponent(token)); - final response = await doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(UppushUnifiedpushDiscoveryResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UppushUnifiedpushDiscoveryResponseApplicationJson), - )! as UppushUnifiedpushDiscoveryResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Receive notifications from 3rd parties - Future push({required final String token}) async { + Future> push({required final String token}) async { + final rawResponse = pushRaw( + token: token, + ); + + return rawResponse.future; + } + + /// Receive notifications from 3rd parties + DynamiteRawResponse pushRaw({required final String token}) { var path = '/index.php/apps/uppush/push/{token}'; final queryParameters = {}; final headers = { @@ -404,23 +510,30 @@ class UppushClient extends DynamiteClient { // coverage:ignore-end path = path.replaceAll('{token}', Uri.encodeQueryComponent(token)); - final response = await doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'post', + uri, + headers, + body, + const {201}, + ), + bodyType: const FullType(UppushPushResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 201) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UppushPushResponseApplicationJson), - )! as UppushPushResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Matrix Gateway discovery - Future gatewayMatrixDiscovery() async { + Future> gatewayMatrixDiscovery() async { + final rawResponse = gatewayMatrixDiscoveryRaw(); + + return rawResponse.future; + } + + /// Matrix Gateway discovery + DynamiteRawResponse gatewayMatrixDiscoveryRaw() { const path = '/index.php/apps/uppush/gateway/matrix'; final queryParameters = {}; final headers = { @@ -445,23 +558,30 @@ class UppushClient extends DynamiteClient { } // coverage:ignore-end - final response = await doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(UppushGatewayMatrixDiscoveryResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UppushGatewayMatrixDiscoveryResponseApplicationJson), - )! as UppushGatewayMatrixDiscoveryResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Matrix Gateway - Future gatewayMatrix() async { + Future> gatewayMatrix() async { + final rawResponse = gatewayMatrixRaw(); + + return rawResponse.future; + } + + /// Matrix Gateway + DynamiteRawResponse gatewayMatrixRaw() { const path = '/index.php/apps/uppush/gateway/matrix'; final queryParameters = {}; final headers = { @@ -486,19 +606,19 @@ class UppushClient extends DynamiteClient { } // coverage:ignore-end - final response = await doRequest( - 'post', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: doRequest( + 'post', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(UppushGatewayMatrixResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UppushGatewayMatrixResponseApplicationJson), - )! as UppushGatewayMatrixResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -1011,14 +1131,8 @@ final Serializers _serializers = (Serializers().toBuilder() ..addBuilderFactory(const FullType(BuiltList, [FullType(String)]), ListBuilder.new)) .build(); -Serializers get uppushSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeUppush(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeUppush(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/api/user_status.openapi.dart b/packages/nextcloud/lib/src/api/user_status.openapi.dart index 33416074..2c56063c 100644 --- a/packages/nextcloud/lib/src/api/user_status.openapi.dart +++ b/packages/nextcloud/lib/src/api/user_status.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case import 'dart:typed_data'; @@ -50,10 +51,23 @@ class UserStatusHeartbeatClient { final UserStatusClient _rootClient; /// Keep the status alive - Future heartbeat({ + Future> heartbeat({ required final String status, final bool oCSAPIRequest = true, }) async { + final rawResponse = heartbeatRaw( + status: status, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Keep the status alive + DynamiteRawResponse heartbeatRaw({ + required final String status, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/user_status/api/v1/heartbeat'; final queryParameters = {}; final headers = { @@ -80,19 +94,19 @@ class UserStatusHeartbeatClient { // coverage:ignore-end queryParameters['status'] = status; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(UserStatusHeartbeatHeartbeatResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UserStatusHeartbeatHeartbeatResponseApplicationJson), - )! as UserStatusHeartbeatHeartbeatResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -102,7 +116,20 @@ class UserStatusPredefinedStatusClient { final UserStatusClient _rootClient; /// Get all predefined messages - Future findAll({final bool oCSAPIRequest = true}) async { + Future> findAll({ + final bool oCSAPIRequest = true, + }) async { + final rawResponse = findAllRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get all predefined messages + DynamiteRawResponse findAllRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/user_status/api/v1/predefined_statuses'; final queryParameters = {}; final headers = { @@ -128,19 +155,19 @@ class UserStatusPredefinedStatusClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(UserStatusPredefinedStatusFindAllResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UserStatusPredefinedStatusFindAllResponseApplicationJson), - )! as UserStatusPredefinedStatusFindAllResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -150,11 +177,26 @@ class UserStatusStatusesClient { final UserStatusClient _rootClient; /// Find statuses of users - Future findAll({ + Future> findAll({ final int? limit, final int? offset, final bool oCSAPIRequest = true, }) async { + final rawResponse = findAllRaw( + limit: limit, + offset: offset, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Find statuses of users + DynamiteRawResponse findAllRaw({ + final int? limit, + final int? offset, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/user_status/api/v1/statuses'; final queryParameters = {}; final headers = { @@ -186,26 +228,39 @@ class UserStatusStatusesClient { queryParameters['offset'] = offset.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(UserStatusStatusesFindAllResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UserStatusStatusesFindAllResponseApplicationJson), - )! as UserStatusStatusesFindAllResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Find the status of a user - Future find({ + Future> find({ required final String userId, final bool oCSAPIRequest = true, }) async { + final rawResponse = findRaw( + userId: userId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Find the status of a user + DynamiteRawResponse findRaw({ + required final String userId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/user_status/api/v1/statuses/{userId}'; final queryParameters = {}; final headers = { @@ -232,19 +287,19 @@ class UserStatusStatusesClient { // coverage:ignore-end path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(UserStatusStatusesFindResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UserStatusStatusesFindResponseApplicationJson), - )! as UserStatusStatusesFindResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -254,7 +309,20 @@ class UserStatusUserStatusClient { final UserStatusClient _rootClient; /// Get the status of the current user - Future getStatus({final bool oCSAPIRequest = true}) async { + Future> getStatus({ + final bool oCSAPIRequest = true, + }) async { + final rawResponse = getStatusRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get the status of the current user + DynamiteRawResponse getStatusRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/user_status/api/v1/user_status'; final queryParameters = {}; final headers = { @@ -280,26 +348,39 @@ class UserStatusUserStatusClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(UserStatusUserStatusGetStatusResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UserStatusUserStatusGetStatusResponseApplicationJson), - )! as UserStatusUserStatusGetStatusResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Update the status type of the current user - Future setStatus({ + Future> setStatus({ required final String statusType, final bool oCSAPIRequest = true, }) async { + final rawResponse = setStatusRaw( + statusType: statusType, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Update the status type of the current user + DynamiteRawResponse setStatusRaw({ + required final String statusType, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/user_status/api/v1/user_status/status'; final queryParameters = {}; final headers = { @@ -326,27 +407,42 @@ class UserStatusUserStatusClient { // coverage:ignore-end queryParameters['statusType'] = statusType; headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(UserStatusUserStatusSetStatusResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UserStatusUserStatusSetStatusResponseApplicationJson), - )! as UserStatusUserStatusSetStatusResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Set the message to a predefined message for the current user - Future setPredefinedMessage({ + Future> setPredefinedMessage({ required final String messageId, final int? clearAt, final bool oCSAPIRequest = true, }) async { + final rawResponse = setPredefinedMessageRaw( + messageId: messageId, + clearAt: clearAt, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Set the message to a predefined message for the current user + DynamiteRawResponse setPredefinedMessageRaw({ + required final String messageId, + final int? clearAt, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/user_status/api/v1/user_status/message/predefined'; final queryParameters = {}; final headers = { @@ -376,28 +472,45 @@ class UserStatusUserStatusClient { queryParameters['clearAt'] = clearAt.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(UserStatusUserStatusSetPredefinedMessageResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UserStatusUserStatusSetPredefinedMessageResponseApplicationJson), - )! as UserStatusUserStatusSetPredefinedMessageResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Set the message to a custom message for the current user - Future setCustomMessage({ + Future> setCustomMessage({ final String? statusIcon, final String? message, final int? clearAt, final bool oCSAPIRequest = true, }) async { + final rawResponse = setCustomMessageRaw( + statusIcon: statusIcon, + message: message, + clearAt: clearAt, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Set the message to a custom message for the current user + DynamiteRawResponse setCustomMessageRaw({ + final String? statusIcon, + final String? message, + final int? clearAt, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/user_status/api/v1/user_status/message/custom'; final queryParameters = {}; final headers = { @@ -432,25 +545,36 @@ class UserStatusUserStatusClient { queryParameters['clearAt'] = clearAt.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(UserStatusUserStatusSetCustomMessageResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UserStatusUserStatusSetCustomMessageResponseApplicationJson), - )! as UserStatusUserStatusSetCustomMessageResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Clear the message of the current user - Future clearMessage({ + Future> clearMessage({ final bool oCSAPIRequest = true, }) async { + final rawResponse = clearMessageRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Clear the message of the current user + DynamiteRawResponse clearMessageRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/user_status/api/v1/user_status/message'; final queryParameters = {}; final headers = { @@ -476,26 +600,39 @@ class UserStatusUserStatusClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(UserStatusUserStatusClearMessageResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UserStatusUserStatusClearMessageResponseApplicationJson), - )! as UserStatusUserStatusClearMessageResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Revert the status to the previous status - Future revertStatus({ + Future> revertStatus({ required final String messageId, final bool oCSAPIRequest = true, }) async { + final rawResponse = revertStatusRaw( + messageId: messageId, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Revert the status to the previous status + DynamiteRawResponse revertStatusRaw({ + required final String messageId, + final bool oCSAPIRequest = true, + }) { var path = '/ocs/v2.php/apps/user_status/api/v1/user_status/revert/{messageId}'; final queryParameters = {}; final headers = { @@ -522,19 +659,19 @@ class UserStatusUserStatusClient { // coverage:ignore-end path = path.replaceAll('{messageId}', Uri.encodeQueryComponent(messageId)); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'delete', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'delete', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(UserStatusUserStatusRevertStatusResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(UserStatusUserStatusRevertStatusResponseApplicationJson), - )! as UserStatusUserStatusRevertStatusResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -1762,14 +1899,8 @@ final Serializers _serializers = (Serializers().toBuilder() ..add(UserStatusCapabilities_UserStatus.serializer)) .build(); -Serializers get userStatusSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeUserStatus(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeUserStatus(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/api/weather_status.openapi.dart b/packages/nextcloud/lib/src/api/weather_status.openapi.dart index 5c328256..a01f6a5b 100644 --- a/packages/nextcloud/lib/src/api/weather_status.openapi.dart +++ b/packages/nextcloud/lib/src/api/weather_status.openapi.dart @@ -1,4 +1,5 @@ // ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures // ignore_for_file: public_member_api_docs // ignore_for_file: unreachable_switch_case import 'dart:typed_data'; @@ -43,10 +44,23 @@ class WeatherStatusWeatherStatusClient { final WeatherStatusClient _rootClient; /// Change the weather status mode. There are currently 2 modes: - ask the browser - use the user defined address - Future setMode({ + Future> setMode({ required final int mode, final bool oCSAPIRequest = true, }) async { + final rawResponse = setModeRaw( + mode: mode, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Change the weather status mode. There are currently 2 modes: - ask the browser - use the user defined address + DynamiteRawResponse setModeRaw({ + required final int mode, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/weather_status/api/v1/mode'; final queryParameters = {}; final headers = { @@ -73,25 +87,35 @@ class WeatherStatusWeatherStatusClient { // coverage:ignore-end queryParameters['mode'] = mode.toString(); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(WeatherStatusWeatherStatusSetModeResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(WeatherStatusWeatherStatusSetModeResponseApplicationJson), - )! as WeatherStatusWeatherStatusSetModeResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Try to use the address set in user personal settings as weather location - Future usePersonalAddress({ + Future> + usePersonalAddress({final bool oCSAPIRequest = true}) async { + final rawResponse = usePersonalAddressRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Try to use the address set in user personal settings as weather location + DynamiteRawResponse usePersonalAddressRaw({ final bool oCSAPIRequest = true, - }) async { + }) { const path = '/ocs/v2.php/apps/weather_status/api/v1/use-personal'; final queryParameters = {}; final headers = { @@ -117,25 +141,36 @@ class WeatherStatusWeatherStatusClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(WeatherStatusWeatherStatusUsePersonalAddressResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(WeatherStatusWeatherStatusUsePersonalAddressResponseApplicationJson), - )! as WeatherStatusWeatherStatusUsePersonalAddressResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get stored user location - Future getLocation({ + Future> getLocation({ final bool oCSAPIRequest = true, }) async { + final rawResponse = getLocationRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get stored user location + DynamiteRawResponse getLocationRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/weather_status/api/v1/location'; final queryParameters = {}; final headers = { @@ -161,28 +196,45 @@ class WeatherStatusWeatherStatusClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(WeatherStatusWeatherStatusGetLocationResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(WeatherStatusWeatherStatusGetLocationResponseApplicationJson), - )! as WeatherStatusWeatherStatusGetLocationResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Set address and resolve it to get coordinates or directly set coordinates and get address with reverse geocoding - Future setLocation({ + Future> setLocation({ final String? address, final num? lat, final num? lon, final bool oCSAPIRequest = true, }) async { + final rawResponse = setLocationRaw( + address: address, + lat: lat, + lon: lon, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Set address and resolve it to get coordinates or directly set coordinates and get address with reverse geocoding + DynamiteRawResponse setLocationRaw({ + final String? address, + final num? lat, + final num? lon, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/weather_status/api/v1/location'; final queryParameters = {}; final headers = { @@ -217,25 +269,36 @@ class WeatherStatusWeatherStatusClient { queryParameters['lon'] = lon.toString(); } headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(WeatherStatusWeatherStatusSetLocationResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(WeatherStatusWeatherStatusSetLocationResponseApplicationJson), - )! as WeatherStatusWeatherStatusSetLocationResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get forecast for current location - Future getForecast({ + Future> getForecast({ final bool oCSAPIRequest = true, }) async { + final rawResponse = getForecastRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get forecast for current location + DynamiteRawResponse getForecastRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/weather_status/api/v1/forecast'; final queryParameters = {}; final headers = { @@ -261,25 +324,36 @@ class WeatherStatusWeatherStatusClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(WeatherStatusWeatherStatusGetForecastResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(WeatherStatusWeatherStatusGetForecastResponseApplicationJson), - )! as WeatherStatusWeatherStatusGetForecastResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Get favorites list - Future getFavorites({ + Future> getFavorites({ final bool oCSAPIRequest = true, }) async { + final rawResponse = getFavoritesRaw( + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Get favorites list + DynamiteRawResponse getFavoritesRaw({ + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/weather_status/api/v1/favorites'; final queryParameters = {}; final headers = { @@ -305,26 +379,39 @@ class WeatherStatusWeatherStatusClient { // coverage:ignore-end headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'get', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(WeatherStatusWeatherStatusGetFavoritesResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(WeatherStatusWeatherStatusGetFavoritesResponseApplicationJson), - )! as WeatherStatusWeatherStatusGetFavoritesResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } /// Set favorites list - Future setFavorites({ + Future> setFavorites({ required final List favorites, final bool oCSAPIRequest = true, }) async { + final rawResponse = setFavoritesRaw( + favorites: favorites, + oCSAPIRequest: oCSAPIRequest, + ); + + return rawResponse.future; + } + + /// Set favorites list + DynamiteRawResponse setFavoritesRaw({ + required final List favorites, + final bool oCSAPIRequest = true, + }) { const path = '/ocs/v2.php/apps/weather_status/api/v1/favorites'; final queryParameters = {}; final headers = { @@ -351,19 +438,19 @@ class WeatherStatusWeatherStatusClient { // coverage:ignore-end queryParameters['favorites[]'] = favorites.map((final e) => e); headers['OCS-APIRequest'] = oCSAPIRequest.toString(); - final response = await _rootClient.doRequest( - 'put', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, + final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); + return DynamiteRawResponse( + response: _rootClient.doRequest( + 'put', + uri, + headers, + body, + const {200}, + ), + bodyType: const FullType(WeatherStatusWeatherStatusSetFavoritesResponseApplicationJson), + headersType: null, + serializers: _jsonSerializers, ); - if (response.statusCode == 200) { - return _jsonSerializers.deserialize( - await response.jsonBody, - specifiedType: const FullType(WeatherStatusWeatherStatusSetFavoritesResponseApplicationJson), - )! as WeatherStatusWeatherStatusSetFavoritesResponseApplicationJson; - } - throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line } } @@ -1813,14 +1900,8 @@ final Serializers _serializers = (Serializers().toBuilder() ..add(WeatherStatusCapabilities_WeatherStatus.serializer)) .build(); -Serializers get weatherStatusSerializers => _serializers; - final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); - -T deserializeWeatherStatus(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; - -Object? serializeWeatherStatus(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end diff --git a/packages/nextcloud/lib/src/client.dart b/packages/nextcloud/lib/src/client.dart index be53fd5a..c42c66ca 100644 --- a/packages/nextcloud/lib/src/client.dart +++ b/packages/nextcloud/lib/src/client.dart @@ -1,6 +1,3 @@ -import 'package:built_value/serializer.dart'; -import 'package:built_value/standard_json_plugin.dart'; -import 'package:dynamite_runtime/content_string.dart'; import 'package:nextcloud/nextcloud.dart'; // ignore: public_member_api_docs @@ -123,44 +120,3 @@ class NextcloudClient extends DynamiteClient { /// Client for the weather status APIs WeatherStatusClient get weatherStatus => _weatherStatus ??= WeatherStatusClient.fromClient(this); } - -// coverage:ignore-start - -// ignore: public_member_api_docs -final serializers = Serializers.merge([ - commentsSerializers, - coreSerializers, - dashboardSerializers, - davSerializers, - filesSerializers, - filesExternalSerializers, - filesRemindersSerializers, - filesSharingSerializers, - filesTrashbinSerializers, - filesVersionsSerializers, - newsSerializers, - notesSerializers, - notificationsSerializers, - provisioningApiSerializers, - settingsSerializers, - sharebymailSerializers, - themingSerializers, - updatenotificationSerializers, - uppushSerializers, - userStatusSerializers, - weatherStatusSerializers, -]); - -// ignore: public_member_api_docs -final Serializers jsonSerializers = (serializers.toBuilder() - ..addPlugin(StandardJsonPlugin()) - ..addPlugin(const ContentStringPlugin())) - .build(); - -// ignore: public_member_api_docs -T deserializeNextcloud(final Object data) => serializers.deserialize(data, specifiedType: FullType(T))! as T; - -// ignore: public_member_api_docs -Object? serializeNextcloud(final T data) => serializers.serialize(data, specifiedType: FullType(T)); - -// coverage:ignore-end diff --git a/packages/nextcloud/lib/src/version_supported.dart b/packages/nextcloud/lib/src/version_supported.dart index 4cf736fb..61008f20 100644 --- a/packages/nextcloud/lib/src/version_supported.dart +++ b/packages/nextcloud/lib/src/version_supported.dart @@ -35,9 +35,9 @@ extension NewsVersionSupported on NewsClient { /// /// Also returns the supported API version number Future<(bool, String)> isSupported() async { - final versions = await getSupportedApiVersions(); + final response = await getSupportedApiVersions(); return ( - versions.apiLevels!.contains(newsSupportedVersion), + response.body.apiLevels!.contains(newsSupportedVersion), newsSupportedVersion, ); } diff --git a/packages/nextcloud/lib/src/webdav/client.dart b/packages/nextcloud/lib/src/webdav/client.dart index 10114b8b..a7dd64d3 100644 --- a/packages/nextcloud/lib/src/webdav/client.dart +++ b/packages/nextcloud/lib/src/webdav/client.dart @@ -53,7 +53,7 @@ class WebDavClient { throw DynamiteApiException( response.statusCode, response.responseHeaders, - await response.body, + await response.string, ); } @@ -82,7 +82,7 @@ class WebDavClient { } Future _parseResponse(final HttpClientResponse response) async => - WebDavMultistatus.fromXmlElement(xml.XmlDocument.parse(await response.body).rootElement); + WebDavMultistatus.fromXmlElement(xml.XmlDocument.parse(await response.string).rootElement); Map _getUploadHeaders({ required final DateTime? lastModified, @@ -205,7 +205,7 @@ class WebDavClient { ); /// Gets the content of the file at [path]. - Future get(final Uri path) async => (await getStream(path)).bodyBytes; + Future get(final Uri path) async => (await getStream(path)).bytes; /// Gets the content of the file at [path]. Future getStream(final Uri path) async => _send( diff --git a/packages/nextcloud/test/core_test.dart b/packages/nextcloud/test/core_test.dart index 3e99b608..5f4a6326 100644 --- a/packages/nextcloud/test/core_test.dart +++ b/packages/nextcloud/test/core_test.dart @@ -19,55 +19,72 @@ void main() { tearDown(() => container.destroy()); test('Is supported from capabilities', () async { - final (supported, _) = client.core.isSupported((await client.core.ocs.getCapabilities()).ocs.data); + final response = await client.core.ocs.getCapabilities(); + + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + final (supported, _) = client.core.isSupported(response.body.ocs.data); expect(supported, isTrue); }); test('Is supported from status', () async { - final status = await client.core.getStatus(); - expect(status.isSupported, isTrue); + final response = await client.core.getStatus(); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.isSupported, isTrue); }); test('Get status', () async { - final status = await client.core.getStatus(); - expect(status.installed, true); - expect(status.maintenance, false); - expect(status.needsDbUpgrade, false); - expect(status.version, startsWith('$coreSupportedVersion.')); - expect(status.versionstring, startsWith('$coreSupportedVersion.')); - expect(status.edition, ''); - expect(status.productname, 'Nextcloud'); - expect(status.extendedSupport, false); + final response = await client.core.getStatus(); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.installed, isTrue); + expect(response.body.maintenance, isFalse); + expect(response.body.needsDbUpgrade, isFalse); + expect(response.body.version, startsWith('$coreSupportedVersion.')); + expect(response.body.versionstring, startsWith('$coreSupportedVersion.')); + expect(response.body.edition, ''); + expect(response.body.productname, 'Nextcloud'); + expect(response.body.extendedSupport, isFalse); }); test('Get capabilities', () async { - final capabilities = await client.core.ocs.getCapabilities(); - expect(capabilities.ocs.data.version.major, coreSupportedVersion); - expect(capabilities.ocs.data.version.string, startsWith('$coreSupportedVersion.')); - expect(capabilities.ocs.data.capabilities.commentsCapabilities, isNotNull); - expect(capabilities.ocs.data.capabilities.davCapabilities, isNotNull); - expect(capabilities.ocs.data.capabilities.filesCapabilities, isNotNull); - expect(capabilities.ocs.data.capabilities.filesSharingCapabilities, isNotNull); - expect(capabilities.ocs.data.capabilities.filesTrashbinCapabilities, isNotNull); - expect(capabilities.ocs.data.capabilities.filesVersionsCapabilities, isNotNull); - expect(capabilities.ocs.data.capabilities.notesCapabilities, isNotNull); - expect(capabilities.ocs.data.capabilities.notificationsCapabilities, isNotNull); - expect(capabilities.ocs.data.capabilities.provisioningApiCapabilities, isNotNull); - expect(capabilities.ocs.data.capabilities.sharebymailCapabilities, isNotNull); - expect(capabilities.ocs.data.capabilities.themingPublicCapabilities, isNotNull); - expect(capabilities.ocs.data.capabilities.userStatusCapabilities, isNotNull); - expect(capabilities.ocs.data.capabilities.weatherStatusCapabilities, isNotNull); + final response = await client.core.ocs.getCapabilities(); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.ocs.data.version.major, coreSupportedVersion); + expect(response.body.ocs.data.version.string, startsWith('$coreSupportedVersion.')); + expect(response.body.ocs.data.capabilities.commentsCapabilities, isNotNull); + expect(response.body.ocs.data.capabilities.davCapabilities, isNotNull); + expect(response.body.ocs.data.capabilities.filesCapabilities, isNotNull); + expect(response.body.ocs.data.capabilities.filesSharingCapabilities, isNotNull); + expect(response.body.ocs.data.capabilities.filesTrashbinCapabilities, isNotNull); + expect(response.body.ocs.data.capabilities.filesVersionsCapabilities, isNotNull); + expect(response.body.ocs.data.capabilities.notesCapabilities, isNotNull); + expect(response.body.ocs.data.capabilities.notificationsCapabilities, isNotNull); + expect(response.body.ocs.data.capabilities.provisioningApiCapabilities, isNotNull); + expect(response.body.ocs.data.capabilities.sharebymailCapabilities, isNotNull); + expect(response.body.ocs.data.capabilities.themingPublicCapabilities, isNotNull); + expect(response.body.ocs.data.capabilities.userStatusCapabilities, isNotNull); + expect(response.body.ocs.data.capabilities.weatherStatusCapabilities, isNotNull); }); test('Get navigation apps', () async { - final navigationApps = await client.core.navigation.getAppsNavigation(); - expect(navigationApps.ocs.data, hasLength(6)); - expect(navigationApps.ocs.data[0].id, 'dashboard'); - expect(navigationApps.ocs.data[1].id, 'files'); - expect(navigationApps.ocs.data[2].id, 'photos'); - expect(navigationApps.ocs.data[3].id, 'activity'); - expect(navigationApps.ocs.data[4].id, 'notes'); - expect(navigationApps.ocs.data[5].id, 'news'); + final response = await client.core.navigation.getAppsNavigation(); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + expect(response.body.ocs.data, hasLength(6)); + + expect(response.body.ocs.data[0].id, 'dashboard'); + expect(response.body.ocs.data[1].id, 'files'); + expect(response.body.ocs.data[2].id, 'photos'); + expect(response.body.ocs.data[3].id, 'activity'); + expect(response.body.ocs.data[4].id, 'notes'); + expect(response.body.ocs.data[5].id, 'news'); }); test( @@ -82,48 +99,53 @@ void main() { ShareType.group.index, ], ); - expect(response.ocs.data, hasLength(3)); - - expect(response.ocs.data[0].id, 'admin'); - expect(response.ocs.data[0].label, 'admin'); - expect(response.ocs.data[0].icon, 'icon-user'); - expect(response.ocs.data[0].source, 'users'); - expect(response.ocs.data[0].status, isEmpty); - expect(response.ocs.data[0].subline, ''); - expect(response.ocs.data[0].shareWithDisplayNameUnique, 'admin@example.com'); - - expect(response.ocs.data[1].id, 'user2'); - expect(response.ocs.data[1].label, 'User Two'); - expect(response.ocs.data[1].icon, 'icon-user'); - expect(response.ocs.data[1].source, 'users'); - expect(response.ocs.data[1].status, isEmpty); - expect(response.ocs.data[1].subline, ''); - expect(response.ocs.data[1].shareWithDisplayNameUnique, 'user2'); - - expect(response.ocs.data[2].id, 'admin'); - expect(response.ocs.data[2].label, 'admin'); - expect(response.ocs.data[2].icon, ''); - expect(response.ocs.data[2].source, 'groups'); - expect(response.ocs.data[2].status, isEmpty); - expect(response.ocs.data[2].subline, ''); - expect(response.ocs.data[2].shareWithDisplayNameUnique, ''); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + expect(response.body.ocs.data, hasLength(3)); + + expect(response.body.ocs.data[0].id, 'admin'); + expect(response.body.ocs.data[0].label, 'admin'); + expect(response.body.ocs.data[0].icon, 'icon-user'); + expect(response.body.ocs.data[0].source, 'users'); + expect(response.body.ocs.data[0].status, isEmpty); + expect(response.body.ocs.data[0].subline, ''); + expect(response.body.ocs.data[0].shareWithDisplayNameUnique, 'admin@example.com'); + + expect(response.body.ocs.data[1].id, 'user2'); + expect(response.body.ocs.data[1].label, 'User Two'); + expect(response.body.ocs.data[1].icon, 'icon-user'); + expect(response.body.ocs.data[1].source, 'users'); + expect(response.body.ocs.data[1].status, isEmpty); + expect(response.body.ocs.data[1].subline, ''); + expect(response.body.ocs.data[1].shareWithDisplayNameUnique, 'user2'); + + expect(response.body.ocs.data[2].id, 'admin'); + expect(response.body.ocs.data[2].label, 'admin'); + expect(response.body.ocs.data[2].icon, ''); + expect(response.body.ocs.data[2].source, 'groups'); + expect(response.body.ocs.data[2].status, isEmpty); + expect(response.body.ocs.data[2].subline, ''); + expect(response.body.ocs.data[2].shareWithDisplayNameUnique, ''); }, skip: true, // TODO: This test only works on 28+ due to a bug fix with the status ); test('Get preview', () async { final response = await client.core.preview.getPreview(file: 'Nextcloud.png'); - expect(response, isNotEmpty); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body, isNotEmpty); }); test('Get avatar', () async { final response = await client.core.avatar.getAvatar(userId: 'admin', size: 32); - expect(response.data, isNotEmpty); + expect(response.body, isNotEmpty); }); test('Get dark avatar', () async { final response = await client.core.avatar.getAvatarDark(userId: 'admin', size: 32); - expect(response.data, isNotEmpty); + expect(response.body, isNotEmpty); }); test('Delete app password', () async { @@ -136,7 +158,10 @@ void main() { test('Unified search providers', () async { final response = await client.core.unifiedSearch.getProviders(); - expect(response.ocs.data, hasLength(13)); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.ocs.data, hasLength(13)); }); test('Unified search', () async { @@ -144,16 +169,20 @@ void main() { providerId: 'settings', term: 'Personal info', ); - expect(response.ocs.data.name, 'Settings'); - expect(response.ocs.data.isPaginated, isFalse); - expect(response.ocs.data.entries, hasLength(1)); - expect(response.ocs.data.entries.single.thumbnailUrl, isEmpty); - expect(response.ocs.data.entries.single.title, 'Personal info'); - expect(response.ocs.data.entries.single.subline, isEmpty); - expect(response.ocs.data.entries.single.resourceUrl, isNotEmpty); - expect(response.ocs.data.entries.single.icon, 'icon-settings-dark'); - expect(response.ocs.data.entries.single.rounded, isFalse); - expect(response.ocs.data.entries.single.attributes, isEmpty); + + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.ocs.data.name, 'Settings'); + expect(response.body.ocs.data.isPaginated, isFalse); + expect(response.body.ocs.data.entries, hasLength(1)); + expect(response.body.ocs.data.entries.single.thumbnailUrl, isEmpty); + expect(response.body.ocs.data.entries.single.title, 'Personal info'); + expect(response.body.ocs.data.entries.single.subline, isEmpty); + expect(response.body.ocs.data.entries.single.resourceUrl, isNotEmpty); + expect(response.body.ocs.data.entries.single.icon, 'icon-settings-dark'); + expect(response.body.ocs.data.entries.single.rounded, isFalse); + expect(response.body.ocs.data.entries.single.attributes, isEmpty); }); }, retry: retryCount, diff --git a/packages/nextcloud/test/dashboard_test.dart b/packages/nextcloud/test/dashboard_test.dart index ef7b6801..f529f82c 100644 --- a/packages/nextcloud/test/dashboard_test.dart +++ b/packages/nextcloud/test/dashboard_test.dart @@ -19,21 +19,21 @@ void main() { test('Get widgets', () async { final response = await client.dashboard.dashboardApi.getWidgets(); - expect(response.ocs.data.keys, equals(['activity', 'notes', 'recommendations', 'user_status'])); + expect(response.body.ocs.data.keys, equals(['activity', 'notes', 'recommendations', 'user_status'])); }); group('Get widget items', () { test('v1', () async { final response = await client.dashboard.dashboardApi.getWidgetItems(); - expect(response.ocs.data.keys, equals(['recommendations'])); - final items = response.ocs.data['recommendations']!; + expect(response.body.ocs.data.keys, equals(['recommendations'])); + final items = response.body.ocs.data['recommendations']!; expect(items, hasLength(7)); }); test('v2', () async { final response = await client.dashboard.dashboardApi.getWidgetItemsV2(); - expect(response.ocs.data.keys, equals(['recommendations'])); - final items = response.ocs.data['recommendations']!.items; + expect(response.body.ocs.data.keys, equals(['recommendations'])); + final items = response.body.ocs.data['recommendations']!.items; expect(items, hasLength(7)); }); }); diff --git a/packages/nextcloud/test/news_test.dart b/packages/nextcloud/test/news_test.dart index 36c944e6..8e54491f 100644 --- a/packages/nextcloud/test/news_test.dart +++ b/packages/nextcloud/test/news_test.dart @@ -26,12 +26,13 @@ void main() { }); tearDown(() => container.destroy()); - Future addWikipediaFeed([final int? folderID]) async => client.news.addFeed( + Future> addWikipediaFeed([final int? folderID]) async => + client.news.addFeed( url: 'http://host.docker.internal:${rssServer.port}/wikipedia.xml', folderId: folderID, ); - Future addNasaFeed() async => client.news.addFeed( + Future> addNasaFeed() async => client.news.addFeed( url: 'http://host.docker.internal:${rssServer.port}/nasa.xml', ); @@ -42,26 +43,38 @@ void main() { test('Add feed', () async { var response = await client.news.listFeeds(); - expect(response.starredCount, 0); - expect(response.newestItemId, null); - expect(response.feeds, hasLength(0)); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.starredCount, 0); + expect(response.body.newestItemId, null); + expect(response.body.feeds, hasLength(0)); response = await addWikipediaFeed(); - expect(response.starredCount, null); - expect(response.newestItemId, isNotNull); - expect(response.feeds, hasLength(1)); - expect(response.feeds[0].url, 'http://host.docker.internal:${rssServer.port}/wikipedia.xml'); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.starredCount, null); + expect(response.body.newestItemId, isNotNull); + expect(response.body.feeds, hasLength(1)); + expect(response.body.feeds[0].url, 'http://host.docker.internal:${rssServer.port}/wikipedia.xml'); response = await client.news.listFeeds(); - expect(response.starredCount, 0); - expect(response.newestItemId, isNotNull); - expect(response.feeds, hasLength(1)); - expect(response.feeds[0].url, 'http://host.docker.internal:${rssServer.port}/wikipedia.xml'); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.starredCount, 0); + expect(response.body.newestItemId, isNotNull); + expect(response.body.feeds, hasLength(1)); + expect(response.body.feeds[0].url, 'http://host.docker.internal:${rssServer.port}/wikipedia.xml'); }); test('Rename feed', () async { var response = await addWikipediaFeed(); - expect(response.feeds[0].title, 'Wikipedia featured articles feed'); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.feeds[0].title, 'Wikipedia featured articles feed'); await client.news.renameFeed( feedId: 1, @@ -69,7 +82,10 @@ void main() { ); response = await client.news.listFeeds(); - expect(response.feeds[0].title, 'test1'); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.feeds[0].title, 'test1'); }); test('Move feed to folder', () async { @@ -81,40 +97,57 @@ void main() { ); final response = await client.news.listFolders(); - expect(response.folders, hasLength(1)); - expect(response.folders[0].id, 1); - expect(response.folders[0].name, 'test1'); - expect(response.folders[0].opened, true); - expect(response.folders[0].feeds, hasLength(0)); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.folders, hasLength(1)); + expect(response.body.folders[0].id, 1); + expect(response.body.folders[0].name, 'test1'); + expect(response.body.folders[0].opened, true); + expect(response.body.folders[0].feeds, hasLength(0)); }); test('Mark feed as read', () async { final feedsResponse = await addWikipediaFeed(); - var articlesResponse = await client.news.listArticles(type: NewsListType.unread.index); - expect(articlesResponse.items.length, greaterThan(0)); + var response = await client.news.listArticles(type: NewsListType.unread.index); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.items.length, greaterThan(0)); await client.news.markFeedAsRead( - feedId: feedsResponse.feeds[0].id, - newestItemId: feedsResponse.newestItemId!, + feedId: feedsResponse.body.feeds[0].id, + newestItemId: feedsResponse.body.newestItemId!, ); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + response = await client.news.listArticles(type: NewsListType.unread.index); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); - articlesResponse = await client.news.listArticles(type: NewsListType.unread.index); - expect(articlesResponse.items, hasLength(0)); + expect(response.body.items, hasLength(0)); }); test('List articles', () async { var response = await client.news.listArticles(); - expect(response.items, hasLength(0)); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.items, hasLength(0)); await addWikipediaFeed(); response = await client.news.listArticles(); - expect(response.items.length, greaterThan(0)); - expect(response.items[0].body, isNotNull); - expect(response.items[0].feedId, 1); - expect(response.items[0].unread, true); - expect(response.items[0].starred, false); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.items.length, greaterThan(0)); + expect(response.body.items[0].body, isNotNull); + expect(response.body.items[0].feedId, 1); + expect(response.body.items[0].unread, true); + expect(response.body.items[0].starred, false); }); test('List updated articles', () async { @@ -126,146 +159,212 @@ void main() { await addWikipediaFeed(); var response = await client.news.listArticles(); - final wikipediaArticles = response.items.length; + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + final wikipediaArticles = response.body.items.length; expect(wikipediaArticles, greaterThan(0)); await addNasaFeed(); response = await client.news.listArticles(); - final nasaArticles = response.items.length - wikipediaArticles; + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + final nasaArticles = response.body.items.length - wikipediaArticles; expect(nasaArticles, greaterThan(0)); response = await client.news.listUpdatedArticles( - lastModified: response.items[response.items.length - 1 - nasaArticles].lastModified, + lastModified: response.body.items[response.body.items.length - 1 - nasaArticles].lastModified, ); - expect(response.items, hasLength(nasaArticles)); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.items, hasLength(nasaArticles)); }); test('Mark article as read', () async { await addWikipediaFeed(); var response = await client.news.listArticles(type: NewsListType.unread.index); - final unreadArticles = response.items.length; + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + final unreadArticles = response.body.items.length; expect(unreadArticles, greaterThan(0)); await client.news.markArticleAsRead( - itemId: response.items[0].id, + itemId: response.body.items[0].id, ); response = await client.news.listArticles(type: NewsListType.unread.index); - expect(response.items, hasLength(unreadArticles - 1)); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.items, hasLength(unreadArticles - 1)); }); test('Mark article as unread', () async { await addWikipediaFeed(); var response = await client.news.listArticles(type: NewsListType.unread.index); - final readArticle = response.items[0]; + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + final readArticle = response.body.items[0]; await client.news.markArticleAsRead(itemId: readArticle.id); response = await client.news.listArticles(type: NewsListType.unread.index); - final unreadArticles = response.items.length; + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + final unreadArticles = response.body.items.length; expect(unreadArticles, greaterThan(0)); await client.news.markArticleAsUnread(itemId: readArticle.id); response = await client.news.listArticles(type: NewsListType.unread.index); - expect(response.items, hasLength(unreadArticles + 1)); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.items, hasLength(unreadArticles + 1)); }); test('Star article', () async { await addWikipediaFeed(); var response = await client.news.listArticles(type: NewsListType.starred.index); - final starredArticles = response.items.length; + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + final starredArticles = response.body.items.length; expect(starredArticles, 0); response = await client.news.listArticles(); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + await client.news.starArticle( - itemId: response.items[0].id, + itemId: response.body.items[0].id, ); response = await client.news.listArticles(type: NewsListType.starred.index); - expect(response.items, hasLength(1)); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.items, hasLength(1)); }); test('Unstar article', () async { await addWikipediaFeed(); var response = await client.news.listArticles(); - final item = response.items[0]; + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + final item = response.body.items[0]; await client.news.starArticle( itemId: item.id, ); response = await client.news.listArticles(type: NewsListType.starred.index); - expect(response.items, hasLength(1)); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.items, hasLength(1)); await client.news.unstarArticle( itemId: item.id, ); response = await client.news.listArticles(type: NewsListType.starred.index); - expect(response.items, hasLength(0)); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.items, hasLength(0)); }); test('Create folder', () async { var response = await client.news.listFolders(); - expect(response.folders, hasLength(0)); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.folders, hasLength(0)); response = await client.news.createFolder(name: 'test1'); - expect(response.folders, hasLength(1)); - expect(response.folders[0].id, 1); - expect(response.folders[0].name, 'test1'); - expect(response.folders[0].opened, true); - expect(response.folders[0].feeds, hasLength(0)); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.folders, hasLength(1)); + expect(response.body.folders[0].id, 1); + expect(response.body.folders[0].name, 'test1'); + expect(response.body.folders[0].opened, true); + expect(response.body.folders[0].feeds, hasLength(0)); response = await client.news.listFolders(); - expect(response.folders, hasLength(1)); - expect(response.folders[0].id, 1); - expect(response.folders[0].name, 'test1'); - expect(response.folders[0].opened, true); - expect(response.folders[0].feeds, hasLength(0)); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.folders, hasLength(1)); + expect(response.body.folders[0].id, 1); + expect(response.body.folders[0].name, 'test1'); + expect(response.body.folders[0].opened, true); + expect(response.body.folders[0].feeds, hasLength(0)); }); test('List folders', () async { var response = await client.news.listFolders(); - expect(response.folders, hasLength(0)); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.folders, hasLength(0)); await client.news.createFolder(name: 'test1'); await client.news.createFolder(name: 'test2'); response = response = await client.news.listFolders(); - expect(response.folders, hasLength(2)); - expect(response.folders[0].id, 1); - expect(response.folders[0].name, 'test1'); - expect(response.folders[0].opened, true); - expect(response.folders[0].feeds, hasLength(0)); - expect(response.folders[1].id, 2); - expect(response.folders[1].name, 'test2'); - expect(response.folders[1].opened, true); - expect(response.folders[1].feeds, hasLength(0)); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.folders, hasLength(2)); + expect(response.body.folders[0].id, 1); + expect(response.body.folders[0].name, 'test1'); + expect(response.body.folders[0].opened, true); + expect(response.body.folders[0].feeds, hasLength(0)); + expect(response.body.folders[1].id, 2); + expect(response.body.folders[1].name, 'test2'); + expect(response.body.folders[1].opened, true); + expect(response.body.folders[1].feeds, hasLength(0)); }); test('Add feed to folder', () async { await client.news.createFolder(name: 'test1'); final response = await addWikipediaFeed(1); - expect(response.starredCount, null); - expect(response.newestItemId, isNotNull); - expect(response.feeds, hasLength(1)); - expect(response.feeds[0].folderId, 1); - expect(response.feeds[0].url, 'http://host.docker.internal:${rssServer.port}/wikipedia.xml'); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.starredCount, null); + expect(response.body.newestItemId, isNotNull); + expect(response.body.feeds, hasLength(1)); + expect(response.body.feeds[0].folderId, 1); + expect(response.body.feeds[0].url, 'http://host.docker.internal:${rssServer.port}/wikipedia.xml'); }); test('Mark folder as read', () async { final foldersResponse = await client.news.createFolder(name: 'test1'); final feedsResponse = await addWikipediaFeed(1); - var articlesResponse = await client.news.listArticles(type: NewsListType.unread.index); - expect(articlesResponse.items.length, greaterThan(0)); + var response = await client.news.listArticles(type: NewsListType.unread.index); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.items.length, greaterThan(0)); await client.news.markFolderAsRead( - folderId: foldersResponse.folders[0].id, - newestItemId: feedsResponse.newestItemId!, + folderId: foldersResponse.body.folders[0].id, + newestItemId: feedsResponse.body.newestItemId!, ); - articlesResponse = await client.news.listArticles(type: NewsListType.unread.index); - expect(articlesResponse.items, hasLength(0)); + response = await client.news.listArticles(type: NewsListType.unread.index); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.items, hasLength(0)); }); }, retry: retryCount, diff --git a/packages/nextcloud/test/notes_test.dart b/packages/nextcloud/test/notes_test.dart index 149298a1..c8f8b429 100644 --- a/packages/nextcloud/test/notes_test.dart +++ b/packages/nextcloud/test/notes_test.dart @@ -19,7 +19,11 @@ void main() { tearDown(() => container.destroy()); test('Is supported', () async { - final (supported, _) = client.notes.isSupported((await client.core.ocs.getCapabilities()).ocs.data); + final response = await client.core.ocs.getCapabilities(); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + final (supported, _) = client.notes.isSupported(response.body.ocs.data); expect(supported, isTrue); }); @@ -30,14 +34,17 @@ void main() { category: 'c', favorite: 1, ); - expect(response.id, isPositive); - expect(response.title, 'a'); - expect(response.content, 'b'); - expect(response.category, 'c'); - expect(response.favorite, true); - expect(response.readonly, false); - expect(response.etag, isNotNull); - expect(response.modified, isNotNull); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.id, isPositive); + expect(response.body.title, 'a'); + expect(response.body.content, 'b'); + expect(response.body.category, 'c'); + expect(response.body.favorite, true); + expect(response.body.readonly, false); + expect(response.body.etag, isNotNull); + expect(response.body.modified, isNotNull); }); test('Create note not favorite', () async { @@ -46,14 +53,17 @@ void main() { content: 'b', category: 'c', ); - expect(response.id, isPositive); - expect(response.title, 'a'); - expect(response.content, 'b'); - expect(response.category, 'c'); - expect(response.favorite, false); - expect(response.readonly, false); - expect(response.etag, isNotNull); - expect(response.modified, isNotNull); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.id, isPositive); + expect(response.body.title, 'a'); + expect(response.body.content, 'b'); + expect(response.body.category, 'c'); + expect(response.body.favorite, false); + expect(response.body.readonly, false); + expect(response.body.etag, isNotNull); + expect(response.body.modified, isNotNull); }); test('Get notes', () async { @@ -61,63 +71,84 @@ void main() { await client.notes.createNote(title: 'b'); final response = await client.notes.getNotes(); - expect(response, hasLength(2)); - expect(response[0].title, 'a'); - expect(response[1].title, 'b'); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body, hasLength(2)); + expect(response.body[0].title, 'a'); + expect(response.body[1].title, 'b'); }); test('Get note', () async { final response = await client.notes.getNote( - id: (await client.notes.createNote(title: 'a')).id, + id: (await client.notes.createNote(title: 'a')).body.id, ); - expect(response.title, 'a'); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.title, 'a'); }); test('Update note', () async { - final id = (await client.notes.createNote(title: 'a')).id; + final id = (await client.notes.createNote(title: 'a')).body.id; await client.notes.updateNote( id: id, title: 'b', ); final response = await client.notes.getNote(id: id); - expect(response.title, 'b'); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.title, 'b'); }); test('Update note fail changed on server', () async { final response = await client.notes.createNote(title: 'a'); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + await client.notes.updateNote( - id: response.id, + id: response.body.id, title: 'b', - ifMatch: '"${response.etag}"', + ifMatch: '"${response.body.etag}"', ); expect( () => client.notes.updateNote( - id: response.id, + id: response.body.id, title: 'c', - ifMatch: '"${response.etag}"', + ifMatch: '"${response.body.etag}"', ), throwsA(predicate((final e) => (e! as DynamiteApiException).statusCode == 412)), ); }); test('Delete note', () async { - final id = (await client.notes.createNote(title: 'a')).id; + final id = (await client.notes.createNote(title: 'a')).body.id; var response = await client.notes.getNotes(); - expect(response, hasLength(1)); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body, hasLength(1)); await client.notes.deleteNote(id: id); response = await client.notes.getNotes(); - expect(response, hasLength(0)); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body, hasLength(0)); }); test('Get settings', () async { final response = await client.notes.getSettings(); - expect(response.notesPath, 'Notes'); - expect(response.fileSuffix, '.md'); - expect(response.noteMode, NotesSettings_NoteMode.rich); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.notesPath, 'Notes'); + expect(response.body.fileSuffix, '.md'); + expect(response.body.noteMode, NotesSettings_NoteMode.rich); }); test('Update settings', () async { @@ -129,14 +160,20 @@ void main() { ..noteMode = NotesSettings_NoteMode.preview, ), ); - expect(response.notesPath, 'Test Notes'); - expect(response.fileSuffix, '.txt'); - expect(response.noteMode, NotesSettings_NoteMode.preview); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.notesPath, 'Test Notes'); + expect(response.body.fileSuffix, '.txt'); + expect(response.body.noteMode, NotesSettings_NoteMode.preview); response = await client.notes.getSettings(); - expect(response.notesPath, 'Test Notes'); - expect(response.fileSuffix, '.txt'); - expect(response.noteMode, NotesSettings_NoteMode.preview); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.notesPath, 'Test Notes'); + expect(response.body.fileSuffix, '.txt'); + expect(response.body.noteMode, NotesSettings_NoteMode.preview); }); }, retry: retryCount, diff --git a/packages/nextcloud/test/notifications_test.dart b/packages/nextcloud/test/notifications_test.dart index 62f245be..4afc936f 100644 --- a/packages/nextcloud/test/notifications_test.dart +++ b/packages/nextcloud/test/notifications_test.dart @@ -37,7 +37,7 @@ void main() { await sendTestNotification(); final startTime = DateTime.now().toUtc(); - final response = (await client.notifications.endpoint.listNotifications()).data; + final response = (await client.notifications.endpoint.listNotifications()).body; expect(response.ocs.data, hasLength(2)); expect(response.ocs.data[0].notificationId, 2); expect(response.ocs.data[0].app, 'admin_notifications'); @@ -61,28 +61,31 @@ void main() { final startTime = DateTime.now().toUtc(); final response = await client.notifications.endpoint.getNotification(id: 2); - expect(response.ocs.data.notificationId, 2); - expect(response.ocs.data.app, 'admin_notifications'); - expect(response.ocs.data.user, 'admin'); - expectDateInReasonableTimeRange(DateTime.parse(response.ocs.data.datetime), startTime); - expect(response.ocs.data.objectType, 'admin_notifications'); - expect(response.ocs.data.objectId, isNotNull); - expect(response.ocs.data.subject, '123'); - expect(response.ocs.data.message, '456'); - expect(response.ocs.data.link, ''); - expect(response.ocs.data.subjectRich, ''); - expect(response.ocs.data.subjectRichParameters, isEmpty); - expect(response.ocs.data.messageRich, ''); - expect(response.ocs.data.messageRichParameters, isEmpty); - expect(response.ocs.data.icon, isNotEmpty); - expect(response.ocs.data.actions, hasLength(0)); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.ocs.data.notificationId, 2); + expect(response.body.ocs.data.app, 'admin_notifications'); + expect(response.body.ocs.data.user, 'admin'); + expectDateInReasonableTimeRange(DateTime.parse(response.body.ocs.data.datetime), startTime); + expect(response.body.ocs.data.objectType, 'admin_notifications'); + expect(response.body.ocs.data.objectId, isNotNull); + expect(response.body.ocs.data.subject, '123'); + expect(response.body.ocs.data.message, '456'); + expect(response.body.ocs.data.link, ''); + expect(response.body.ocs.data.subjectRich, ''); + expect(response.body.ocs.data.subjectRichParameters, isEmpty); + expect(response.body.ocs.data.messageRich, ''); + expect(response.body.ocs.data.messageRichParameters, isEmpty); + expect(response.body.ocs.data.icon, isNotEmpty); + expect(response.body.ocs.data.actions, hasLength(0)); }); test('Delete notification', () async { await sendTestNotification(); await client.notifications.endpoint.deleteNotification(id: 2); - final response = (await client.notifications.endpoint.listNotifications()).data; + final response = (await client.notifications.endpoint.listNotifications()).body; expect(response.ocs.data, hasLength(1)); }); @@ -91,7 +94,7 @@ void main() { await sendTestNotification(); await client.notifications.endpoint.deleteAllNotifications(); - final response = (await client.notifications.endpoint.listNotifications()).data; + final response = (await client.notifications.endpoint.listNotifications()).body; expect(response.ocs.data, hasLength(0)); }); }); @@ -126,6 +129,7 @@ void main() { devicePublicKey: keypair.publicKey.toFormattedPEM(), proxyServer: 'https://example.com/', )) + .body .ocs .data; expect(subscription.publicKey, hasLength(451)); diff --git a/packages/nextcloud/test/provisioning_api_test.dart b/packages/nextcloud/test/provisioning_api_test.dart index f214e807..0df22560 100644 --- a/packages/nextcloud/test/provisioning_api_test.dart +++ b/packages/nextcloud/test/provisioning_api_test.dart @@ -22,30 +22,40 @@ void main() { group('Users', () { test('Get current user', () async { - final user = await client.provisioningApi.users.getCurrentUser(); - expect(user.ocs.data.id, 'admin'); - expect(user.ocs.data.displayName, 'admin'); - expect(user.ocs.data.displaynameScope, 'v2-federated'); - expect(user.ocs.data.language, 'en'); + final response = await client.provisioningApi.users.getCurrentUser(); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.ocs.data.id, 'admin'); + expect(response.body.ocs.data.displayName, 'admin'); + expect(response.body.ocs.data.displaynameScope, 'v2-federated'); + expect(response.body.ocs.data.language, 'en'); }); test('Get user by username', () async { - final user = await client.provisioningApi.users.getUser(userId: 'user1'); - expect(user.ocs.data.id, 'user1'); - expect(user.ocs.data.displayname, 'User One'); - expect(user.ocs.data.displaynameScope, null); - expect(user.ocs.data.language, 'en'); + final response = await client.provisioningApi.users.getUser(userId: 'user1'); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.ocs.data.id, 'user1'); + expect(response.body.ocs.data.displayname, 'User One'); + expect(response.body.ocs.data.displaynameScope, null); + expect(response.body.ocs.data.language, 'en'); }); }); group('Apps', () { test('Get apps', () async { final response = await client.provisioningApi.apps.getApps(); - expect(response.ocs.data.apps, hasLength(40)); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + expect(response.body.ocs.data.apps, hasLength(40)); - for (final id in response.ocs.data.apps) { + for (final id in response.body.ocs.data.apps) { final app = await client.provisioningApi.apps.getAppInfo(app: id); - expect(app.ocs.data.id, isNotEmpty); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + expect(app.body.ocs.data.id, isNotEmpty); } }); }); diff --git a/packages/nextcloud/test/settings_test.dart b/packages/nextcloud/test/settings_test.dart index b6d27e22..dd6036ab 100644 --- a/packages/nextcloud/test/settings_test.dart +++ b/packages/nextcloud/test/settings_test.dart @@ -22,8 +22,9 @@ Future run(final DockerImage image) async { tearDown(() => container.destroy()); test('Download log file', () async { - final response = utf8.decode((await client.settings.logSettings.download()).data); - expect(response, await container.nextcloudLogs()); + final response = await client.settings.logSettings.download(); + final logs = utf8.decode(response.body); + expect(logs, await container.nextcloudLogs()); }); }); } diff --git a/packages/nextcloud/test/uppush_test.dart b/packages/nextcloud/test/uppush_test.dart index bdd98898..e521a5cc 100644 --- a/packages/nextcloud/test/uppush_test.dart +++ b/packages/nextcloud/test/uppush_test.dart @@ -22,43 +22,64 @@ void main() { test('Is installed', () async { final response = await client.uppush.check(); - expect(response.success, isTrue); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.success, isTrue); }); test('Set keepalive', () async { final response = await client.uppush.setKeepalive(keepalive: 10); - expect(response.success, isTrue); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.success, isTrue); }); test('Create device', () async { final response = await client.uppush.createDevice(deviceName: 'Test'); - expect(response.success, isTrue); - expect(response.deviceId, isNotEmpty); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.success, isTrue); + expect(response.body.deviceId, isNotEmpty); }); test('Delete device', () async { - final deviceId = (await client.uppush.createDevice(deviceName: 'Test')).deviceId; + final deviceId = (await client.uppush.createDevice(deviceName: 'Test')).body.deviceId; final response = await client.uppush.deleteDevice(deviceId: deviceId); - expect(response.success, isTrue); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.success, isTrue); }); test('Create app', () async { - final deviceId = (await client.uppush.createDevice(deviceName: 'Test')).deviceId; + final deviceId = (await client.uppush.createDevice(deviceName: 'Test')).body.deviceId; final response = await client.uppush.createApp(deviceId: deviceId, appName: 'Test'); - expect(response.success, isTrue); - expect(response.token, isNotEmpty); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.success, isTrue); + expect(response.body.token, isNotEmpty); }); test('UnifiedPush discovery', () async { final response = await client.uppush.unifiedpushDiscovery(token: 'example'); - expect(response.unifiedpush.version, 1); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.unifiedpush.version, 1); }); test('Matrix gateway discovery', () async { final response = await client.uppush.gatewayMatrixDiscovery(); - expect(response.unifiedpush.gateway, 'matrix'); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.unifiedpush.gateway, 'matrix'); }); // Deleting an app, sending a notification (also via matrix gateway) or listening for notifications is not possible because redis is not set up diff --git a/packages/nextcloud/test/user_status_test.dart b/packages/nextcloud/test/user_status_test.dart index 7c4b55aa..4d11ec88 100644 --- a/packages/nextcloud/test/user_status_test.dart +++ b/packages/nextcloud/test/user_status_test.dart @@ -21,45 +21,50 @@ void main() { test('Find all predefined statuses', () async { final expectedStatusIDs = ['meeting', 'commuting', 'remote-work', 'sick-leave', 'vacationing']; final response = await client.userStatus.predefinedStatus.findAll(); - expect(response.ocs.data, hasLength(5)); - final responseIDs = response.ocs.data.map((final status) => status.id); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.ocs.data, hasLength(5)); + final responseIDs = response.body.ocs.data.map((final status) => status.id); expect(expectedStatusIDs.map(responseIDs.contains).contains(false), false); - for (final status in response.ocs.data) { + for (final status in response.body.ocs.data) { expect(status.icon, isNotNull); expect(status.message, isNotNull); } - final meeting = response.ocs.data.singleWhere((final s) => s.id == 'meeting').clearAt!; + final meeting = response.body.ocs.data.singleWhere((final s) => s.id == 'meeting').clearAt!; expect(meeting.type, UserStatusClearAt_Type.period); expect(meeting.time.$int, 3600); - final commuting = response.ocs.data.singleWhere((final s) => s.id == 'commuting').clearAt!; + final commuting = response.body.ocs.data.singleWhere((final s) => s.id == 'commuting').clearAt!; expect(commuting.type, UserStatusClearAt_Type.period); expect(commuting.time.$int, 1800); - final remoteWork = response.ocs.data.singleWhere((final s) => s.id == 'remote-work').clearAt!; + final remoteWork = response.body.ocs.data.singleWhere((final s) => s.id == 'remote-work').clearAt!; expect(remoteWork.type, UserStatusClearAt_Type.endOf); expect(remoteWork.time.clearAtTimeType, UserStatusClearAtTimeType.day); - final sickLeave = response.ocs.data.singleWhere((final s) => s.id == 'sick-leave').clearAt!; + final sickLeave = response.body.ocs.data.singleWhere((final s) => s.id == 'sick-leave').clearAt!; expect(sickLeave.type, UserStatusClearAt_Type.endOf); expect(sickLeave.time.clearAtTimeType, UserStatusClearAtTimeType.day); - final vacationing = response.ocs.data.singleWhere((final s) => s.id == 'vacationing').clearAt; + final vacationing = response.body.ocs.data.singleWhere((final s) => s.id == 'vacationing').clearAt; expect(vacationing, null); }); test('Set status', () async { final response = await client.userStatus.userStatus.setStatus(statusType: 'online'); - - expect(response.ocs.data.userId, 'user1'); - expect(response.ocs.data.message, null); - expect(response.ocs.data.messageId, null); - expect(response.ocs.data.messageIsPredefined, false); - expect(response.ocs.data.icon, null); - expect(response.ocs.data.clearAt, null); - expect(response.ocs.data.status, 'online'); - expect(response.ocs.data.statusIsUserDefined, true); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.ocs.data.userId, 'user1'); + expect(response.body.ocs.data.message, null); + expect(response.body.ocs.data.messageId, null); + expect(response.body.ocs.data.messageIsPredefined, false); + expect(response.body.ocs.data.icon, null); + expect(response.body.ocs.data.clearAt, null); + expect(response.body.ocs.data.status, 'online'); + expect(response.body.ocs.data.statusIsUserDefined, true); }); test('Get status', () async { @@ -68,29 +73,36 @@ void main() { await client.userStatus.userStatus.setStatus(statusType: 'online'); final response = await client.userStatus.userStatus.getStatus(); - expect(response.ocs.data.userId, 'user1'); - expect(response.ocs.data.message, null); - expect(response.ocs.data.messageId, null); - expect(response.ocs.data.messageIsPredefined, false); - expect(response.ocs.data.icon, null); - expect(response.ocs.data.clearAt, null); - expect(response.ocs.data.status, 'online'); - expect(response.ocs.data.statusIsUserDefined, true); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.ocs.data.userId, 'user1'); + expect(response.body.ocs.data.message, null); + expect(response.body.ocs.data.messageId, null); + expect(response.body.ocs.data.messageIsPredefined, false); + expect(response.body.ocs.data.icon, null); + expect(response.body.ocs.data.clearAt, null); + expect(response.body.ocs.data.status, 'online'); + expect(response.body.ocs.data.statusIsUserDefined, true); }); test('Find all statuses', () async { var response = await client.userStatus.statuses.findAll(); - expect(response.ocs.data, hasLength(0)); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + expect(response.body.ocs.data, hasLength(0)); await client.userStatus.userStatus.setStatus(statusType: 'online'); response = await client.userStatus.statuses.findAll(); - expect(response.ocs.data, hasLength(1)); - expect(response.ocs.data[0].userId, 'user1'); - expect(response.ocs.data[0].message, null); - expect(response.ocs.data[0].icon, null); - expect(response.ocs.data[0].clearAt, null); - expect(response.ocs.data[0].status, 'online'); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + expect(response.body.ocs.data, hasLength(1)); + expect(response.body.ocs.data[0].userId, 'user1'); + expect(response.body.ocs.data[0].message, null); + expect(response.body.ocs.data[0].icon, null); + expect(response.body.ocs.data[0].clearAt, null); + expect(response.body.ocs.data[0].status, 'online'); }); test('Find status', () async { @@ -98,11 +110,14 @@ void main() { await client.userStatus.userStatus.setStatus(statusType: 'online'); final response = await client.userStatus.statuses.find(userId: 'user1'); - expect(response.ocs.data.userId, 'user1'); - expect(response.ocs.data.message, null); - expect(response.ocs.data.icon, null); - expect(response.ocs.data.clearAt, null); - expect(response.ocs.data.status, 'online'); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.ocs.data.userId, 'user1'); + expect(response.body.ocs.data.message, null); + expect(response.body.ocs.data.icon, null); + expect(response.body.ocs.data.clearAt, null); + expect(response.body.ocs.data.status, 'online'); }); test('Set predefined message', () async { @@ -111,14 +126,17 @@ void main() { messageId: 'meeting', clearAt: clearAt, ); - expect(response.ocs.data.userId, 'user1'); - expect(response.ocs.data.message, null); - expect(response.ocs.data.messageId, 'meeting'); - expect(response.ocs.data.messageIsPredefined, true); - expect(response.ocs.data.icon, null); - expect(response.ocs.data.clearAt, clearAt); - expect(response.ocs.data.status, 'offline'); - expect(response.ocs.data.statusIsUserDefined, false); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.ocs.data.userId, 'user1'); + expect(response.body.ocs.data.message, null); + expect(response.body.ocs.data.messageId, 'meeting'); + expect(response.body.ocs.data.messageIsPredefined, true); + expect(response.body.ocs.data.icon, null); + expect(response.body.ocs.data.clearAt, clearAt); + expect(response.body.ocs.data.status, 'offline'); + expect(response.body.ocs.data.statusIsUserDefined, false); }); test('Set custom message', () async { @@ -128,14 +146,17 @@ void main() { message: 'bla', clearAt: clearAt, ); - expect(response.ocs.data.userId, 'user1'); - expect(response.ocs.data.message, 'bla'); - expect(response.ocs.data.messageId, null); - expect(response.ocs.data.messageIsPredefined, false); - expect(response.ocs.data.icon, '😀'); - expect(response.ocs.data.clearAt, clearAt); - expect(response.ocs.data.status, 'offline'); - expect(response.ocs.data.statusIsUserDefined, false); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.ocs.data.userId, 'user1'); + expect(response.body.ocs.data.message, 'bla'); + expect(response.body.ocs.data.messageId, null); + expect(response.body.ocs.data.messageIsPredefined, false); + expect(response.body.ocs.data.icon, '😀'); + expect(response.body.ocs.data.clearAt, clearAt); + expect(response.body.ocs.data.status, 'offline'); + expect(response.body.ocs.data.statusIsUserDefined, false); }); test('Clear message', () async { @@ -148,26 +169,32 @@ void main() { await client.userStatus.userStatus.clearMessage(); final response = await client.userStatus.userStatus.getStatus(); - expect(response.ocs.data.userId, 'user1'); - expect(response.ocs.data.message, null); - expect(response.ocs.data.messageId, null); - expect(response.ocs.data.messageIsPredefined, false); - expect(response.ocs.data.icon, null); - expect(response.ocs.data.clearAt, null); - expect(response.ocs.data.status, 'offline'); - expect(response.ocs.data.statusIsUserDefined, false); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.ocs.data.userId, 'user1'); + expect(response.body.ocs.data.message, null); + expect(response.body.ocs.data.messageId, null); + expect(response.body.ocs.data.messageIsPredefined, false); + expect(response.body.ocs.data.icon, null); + expect(response.body.ocs.data.clearAt, null); + expect(response.body.ocs.data.status, 'offline'); + expect(response.body.ocs.data.statusIsUserDefined, false); }); test('Heartbeat', () async { final response = await client.userStatus.heartbeat.heartbeat(status: 'online'); - expect(response.ocs.data.userId, 'user1'); - expect(response.ocs.data.message, null); - expect(response.ocs.data.messageId, null); - expect(response.ocs.data.messageIsPredefined, false); - expect(response.ocs.data.icon, null); - expect(response.ocs.data.clearAt, null); - expect(response.ocs.data.status, 'online'); - expect(response.ocs.data.statusIsUserDefined, false); + expect(response.statusCode, 200); + expect(() => response.headers, isA()); + + expect(response.body.ocs.data.userId, 'user1'); + expect(response.body.ocs.data.message, null); + expect(response.body.ocs.data.messageId, null); + expect(response.body.ocs.data.messageIsPredefined, false); + expect(response.body.ocs.data.icon, null); + expect(response.body.ocs.data.clearAt, null); + expect(response.body.ocs.data.status, 'online'); + expect(response.body.ocs.data.statusIsUserDefined, false); }); }, retry: retryCount, From 279bcc2d1319cfb10d2bccd5cbc58f0d2871cbdf Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Wed, 13 Sep 2023 16:24:46 +0200 Subject: [PATCH 7/9] docs(dynamite): document operations with parameters Signed-off-by: Nikolas Rimikis --- .../dynamite/lib/src/builder/client.dart | 11 +- .../dynamite/lib/src/builder/imports.dart | 1 + .../dynamite/lib/src/helpers/docs.dart | 8 +- .../lib/src/models/openapi/operation.dart | 61 +- .../lib/src/models/openapi/parameter.dart | 16 + .../nextcloud/lib/src/api/core.openapi.dart | 1623 ++++++++++++++++- .../lib/src/api/dashboard.openapi.dart | 107 +- .../nextcloud/lib/src/api/dav.openapi.dart | 43 +- .../nextcloud/lib/src/api/files.openapi.dart | 485 ++++- .../lib/src/api/files_external.openapi.dart | 33 +- .../lib/src/api/files_reminders.openapi.dart | 123 +- .../lib/src/api/files_sharing.openapi.dart | 817 ++++++++- .../lib/src/api/files_trashbin.openapi.dart | 43 +- .../lib/src/api/files_versions.openapi.dart | 43 +- .../nextcloud/lib/src/api/news.openapi.dart | 416 ++++- .../nextcloud/lib/src/api/notes.openapi.dart | 189 ++ .../lib/src/api/notifications.openapi.dart | 400 +++- .../lib/src/api/provisioning_api.openapi.dart | 1583 ++++++++++++++-- .../lib/src/api/settings.openapi.dart | 31 +- .../lib/src/api/theming.openapi.dart | 397 +++- .../src/api/updatenotification.openapi.dart | 43 +- .../nextcloud/lib/src/api/uppush.openapi.dart | 305 +++- .../lib/src/api/user_status.openapi.dart | 350 +++- .../lib/src/api/weather_status.openapi.dart | 231 ++- 24 files changed, 6939 insertions(+), 420 deletions(-) diff --git a/packages/dynamite/dynamite/lib/src/builder/client.dart b/packages/dynamite/dynamite/lib/src/builder/client.dart index d4f94276..a5d6b3db 100644 --- a/packages/dynamite/dynamite/lib/src/builder/client.dart +++ b/packages/dynamite/dynamite/lib/src/builder/client.dart @@ -119,7 +119,7 @@ super( ); } - b.methods.addAll(buildTags(spec, state, tags, null)); + b.methods.addAll(buildTags(spec, state, null)); }, ); @@ -167,14 +167,13 @@ Class buildClient( ); } - b.methods.addAll(buildTags(spec, state, tags, tag)); + b.methods.addAll(buildTags(spec, state, tag)); }, ); Iterable buildTags( final openapi.OpenAPI spec, final State state, - final List tags, final String? tag, ) sync* { final client = tag == null ? 'this' : '_rootClient'; @@ -231,7 +230,6 @@ Iterable buildTags( ).forEach(code.writeln); final operationParameters = ListBuilder(); - final docs = operation.formattedDescription; final annotations = operation.deprecated ?? false ? refer('Deprecated').call([refer("''")]) : null; var returnDataType = 'void'; var returnHeadersType = 'void'; @@ -386,7 +384,7 @@ Iterable buildTags( b ..name = name ..modifier = MethodModifier.async - ..docs.addAll(docs); + ..docs.addAll(operation.formattedDescription(name)); if (annotations != null) { b.annotations.add(annotations); @@ -411,7 +409,8 @@ return rawResponse.future; (final b) { b ..name = '${name}Raw' - ..docs.addAll(docs); + ..docs.addAll(operation.formattedDescription(name, isRawRequest: true)) + ..annotations.add(refer('experimental')); if (annotations != null) { b.annotations.add(annotations); diff --git a/packages/dynamite/dynamite/lib/src/builder/imports.dart b/packages/dynamite/dynamite/lib/src/builder/imports.dart index b30990f8..236fedfc 100644 --- a/packages/dynamite/dynamite/lib/src/builder/imports.dart +++ b/packages/dynamite/dynamite/lib/src/builder/imports.dart @@ -19,6 +19,7 @@ List generateImports(final AssetId outputId) => [ Directive.import('package:dynamite_runtime/content_string.dart'), Directive.import('package:dynamite_runtime/http_client.dart'), Directive.import('package:dynamite_runtime/utils.dart'), + Directive.import('package:meta/meta.dart'), Directive.import('package:universal_io/io.dart'), const Code(''), Directive.export('package:dynamite_runtime/http_client.dart'), diff --git a/packages/dynamite/dynamite/lib/src/helpers/docs.dart b/packages/dynamite/dynamite/lib/src/helpers/docs.dart index 87b2501b..450b0516 100644 --- a/packages/dynamite/dynamite/lib/src/helpers/docs.dart +++ b/packages/dynamite/dynamite/lib/src/helpers/docs.dart @@ -3,7 +3,13 @@ const docsSeparator = '///'; Iterable descriptionToDocs(final String? description) sync* { if (description != null && description.isNotEmpty) { for (final line in description.split('\n')) { - yield '$docsSeparator $line'; + final buffer = StringBuffer('$docsSeparator ')..write(line); + + if (!line.endsWith('.')) { + buffer.write('.'); + } + + yield buffer.toString(); } } } diff --git a/packages/dynamite/dynamite/lib/src/models/openapi/operation.dart b/packages/dynamite/dynamite/lib/src/models/openapi/operation.dart index 88a8df11..bd431f39 100644 --- a/packages/dynamite/dynamite/lib/src/models/openapi/operation.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/operation.dart @@ -35,13 +35,66 @@ abstract class Operation implements Built { BuiltList>>? get security; - Iterable get formattedDescription sync* { - yield* descriptionToDocs(summary); + Iterable formattedDescription( + final String methodName, { + final bool isRawRequest = false, + final bool requiresAuth = false, + }) sync* { + if (summary != null && summary!.isNotEmpty) { + yield* descriptionToDocs(summary); + yield docsSeparator; + } - if (summary != null && summary!.isNotEmpty && description != null && description!.isNotEmpty) { + if (description != null && description!.isNotEmpty) { + yield* descriptionToDocs(description); yield docsSeparator; } - yield* descriptionToDocs(description); + if (isRawRequest) { + yield ''' +$docsSeparator This method and the response it returns is experimental. The API might change without a major version bump. +$docsSeparator +$docsSeparator Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers.'''; + } else { + yield '$docsSeparator Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers.'; + } + yield '$docsSeparator Throws a [DynamiteApiException] if the API call does not return an expected status code.'; + yield docsSeparator; + + if (parameters != null && parameters!.isNotEmpty) { + yield '$docsSeparator Parameters:'; + for (final parameter in parameters!) { + yield parameter.formattedDescription; + } + yield docsSeparator; + } + + if (responses != null && responses!.isNotEmpty) { + yield '$docsSeparator Status codes:'; + for (final response in responses!.entries) { + final statusCode = response.key; + final description = response.value.description; + + final buffer = StringBuffer() + ..write('$docsSeparator ') + ..write(' * $statusCode'); + + if (description.isNotEmpty) { + buffer + ..write(': ') + ..write(description); + } + + yield buffer.toString(); + } + yield docsSeparator; + } + + yield '$docsSeparator See:'; + if (isRawRequest) { + yield '$docsSeparator * [$methodName] for an operation that returns a [DynamiteResponse] with a stable API.'; + } else { + yield '$docsSeparator * [${methodName}Raw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized.'; + } } } diff --git a/packages/dynamite/dynamite/lib/src/models/openapi/parameter.dart b/packages/dynamite/dynamite/lib/src/models/openapi/parameter.dart index de74945e..d23147f6 100644 --- a/packages/dynamite/dynamite/lib/src/models/openapi/parameter.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/parameter.dart @@ -1,5 +1,7 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; +import 'package:dynamite/src/helpers/dart_helpers.dart'; +import 'package:dynamite/src/helpers/docs.dart'; import 'package:dynamite/src/helpers/dynamite.dart'; import 'package:dynamite/src/models/openapi/schema.dart'; @@ -25,4 +27,18 @@ abstract class Parameter implements Built { Schema? get schema; bool get isDartRequired => isRequired(required, schema?.$default); + + String get formattedDescription { + final name = toDartName(this.name); + + final buffer = StringBuffer() + ..write('$docsSeparator * ') + ..write('[$name]'); + + if (description != null) { + buffer.write(' $description'); + } + + return buffer.toString(); + } } diff --git a/packages/nextcloud/lib/src/api/core.openapi.dart b/packages/nextcloud/lib/src/api/core.openapi.dart index 69cdd73f..317a6241 100644 --- a/packages/nextcloud/lib/src/api/core.openapi.dart +++ b/packages/nextcloud/lib/src/api/core.openapi.dart @@ -13,6 +13,8 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -75,12 +77,31 @@ class CoreClient extends DynamiteClient { CoreWipeClient get wipe => CoreWipeClient(this); + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200: Status returned + /// + /// See: + /// * [getStatusRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getStatus() async { final rawResponse = getStatusRaw(); return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200: Status returned + /// + /// See: + /// * [getStatus] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getStatusRaw() { const path = '/status.php'; final queryParameters = {}; @@ -110,7 +131,20 @@ class CoreAppPasswordClient { final CoreClient _rootClient; - /// Create app password + /// Create app password. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: App password returned + /// * 403: Creating app password is not allowed + /// + /// See: + /// * [getAppPasswordRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getAppPassword({ final bool oCSAPIRequest = true, }) async { @@ -121,7 +155,23 @@ class CoreAppPasswordClient { return rawResponse.future; } - /// Create app password + /// Create app password. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: App password returned + /// * 403: Creating app password is not allowed + /// + /// See: + /// * [getAppPassword] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getAppPasswordRaw({ final bool oCSAPIRequest = true, }) { @@ -165,7 +215,20 @@ class CoreAppPasswordClient { ); } - /// Rotate app password + /// Rotate app password. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: App password returned + /// * 403: Rotating app password is not allowed + /// + /// See: + /// * [rotateAppPasswordRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> rotateAppPassword({ final bool oCSAPIRequest = true, }) async { @@ -176,7 +239,23 @@ class CoreAppPasswordClient { return rawResponse.future; } - /// Rotate app password + /// Rotate app password. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: App password returned + /// * 403: Rotating app password is not allowed + /// + /// See: + /// * [rotateAppPassword] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse rotateAppPasswordRaw({ final bool oCSAPIRequest = true, }) { @@ -220,7 +299,20 @@ class CoreAppPasswordClient { ); } - /// Delete app password + /// Delete app password. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: App password deleted successfully + /// * 403: Deleting app password is not allowed + /// + /// See: + /// * [deleteAppPasswordRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> deleteAppPassword({ final bool oCSAPIRequest = true, }) async { @@ -231,7 +323,23 @@ class CoreAppPasswordClient { return rawResponse.future; } - /// Delete app password + /// Delete app password. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: App password deleted successfully + /// * 403: Deleting app password is not allowed + /// + /// See: + /// * [deleteAppPassword] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse deleteAppPasswordRaw({ final bool oCSAPIRequest = true, }) { @@ -281,7 +389,25 @@ class CoreAutoCompleteClient { final CoreClient _rootClient; - /// Autocomplete a query + /// Autocomplete a query. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [search] Text to search for + /// * [itemType] Type of the items to search for + /// * [itemId] ID of the items to search for + /// * [sorter] can be piped, top prio first, e.g.: "commenters|share-recipients" + /// * [shareTypes] Types of shares to search for + /// * [limit] Maximum number of results to return + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Autocomplete results returned + /// + /// See: + /// * [$getRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> $get({ required final String search, final String? itemType, @@ -304,7 +430,28 @@ class CoreAutoCompleteClient { return rawResponse.future; } - /// Autocomplete a query + /// Autocomplete a query. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [search] Text to search for + /// * [itemType] Type of the items to search for + /// * [itemId] ID of the items to search for + /// * [sorter] can be piped, top prio first, e.g.: "commenters|share-recipients" + /// * [shareTypes] Types of shares to search for + /// * [limit] Maximum number of results to return + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Autocomplete results returned + /// + /// See: + /// * [$get] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse $getRaw({ required final String search, final String? itemType, @@ -371,13 +518,27 @@ class CoreAutoCompleteClient { } } -/// Class AvatarController +/// Class AvatarController. class CoreAvatarClient { CoreAvatarClient(this._rootClient); final CoreClient _rootClient; - /// Get the dark avatar + /// Get the dark avatar. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [size] Size of the avatar + /// + /// Status codes: + /// * 200: Avatar returned + /// * 404: Avatar not found + /// + /// See: + /// * [getAvatarDarkRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getAvatarDark({ required final String userId, required final int size, @@ -390,7 +551,24 @@ class CoreAvatarClient { return rawResponse.future; } - /// Get the dark avatar + /// Get the dark avatar. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [size] Size of the avatar + /// + /// Status codes: + /// * 200: Avatar returned + /// * 404: Avatar not found + /// + /// See: + /// * [getAvatarDark] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getAvatarDarkRaw({ required final String userId, required final int size, @@ -434,7 +612,21 @@ class CoreAvatarClient { ); } - /// Get the avatar + /// Get the avatar. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [size] Size of the avatar + /// + /// Status codes: + /// * 200: Avatar returned + /// * 404: Avatar not found + /// + /// See: + /// * [getAvatarRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getAvatar({ required final String userId, required final int size, @@ -447,7 +639,24 @@ class CoreAvatarClient { return rawResponse.future; } - /// Get the avatar + /// Get the avatar. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [size] Size of the avatar + /// + /// Status codes: + /// * 200: Avatar returned + /// * 404: Avatar not found + /// + /// See: + /// * [getAvatar] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getAvatarRaw({ required final String userId, required final int size, @@ -497,7 +706,20 @@ class CoreClientFlowLoginV2Client { final CoreClient _rootClient; - /// Poll the login flow credentials + /// Poll the login flow credentials. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [token] Token of the flow + /// + /// Status codes: + /// * 200: Login flow credentials returned + /// * 404: Login flow not found or completed + /// + /// See: + /// * [pollRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> poll({required final String token}) async { final rawResponse = pollRaw( token: token, @@ -506,7 +728,23 @@ class CoreClientFlowLoginV2Client { return rawResponse.future; } - /// Poll the login flow credentials + /// Poll the login flow credentials. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [token] Token of the flow + /// + /// Status codes: + /// * 200: Login flow credentials returned + /// * 404: Login flow not found or completed + /// + /// See: + /// * [poll] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse pollRaw({required final String token}) { const path = '/index.php/login/v2/poll'; final queryParameters = {}; @@ -546,14 +784,35 @@ class CoreClientFlowLoginV2Client { ); } - /// Init a login flow + /// Init a login flow. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200: Login flow init returned + /// + /// See: + /// * [initRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> init() async { final rawResponse = initRaw(); return rawResponse.future; } - /// Init a login flow + /// Init a login flow. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200: Login flow init returned + /// + /// See: + /// * [init] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse initRaw() { const path = '/index.php/login/v2'; final queryParameters = {}; @@ -598,7 +857,21 @@ class CoreCollaborationResourcesClient { final CoreClient _rootClient; - /// Search for collections + /// Search for collections. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [filter] Filter collections + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Collections returned + /// * 404: Collection not found + /// + /// See: + /// * [searchCollectionsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> searchCollections({ required final String filter, final bool oCSAPIRequest = true, @@ -611,7 +884,24 @@ class CoreCollaborationResourcesClient { return rawResponse.future; } - /// Search for collections + /// Search for collections. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [filter] Filter collections + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Collections returned + /// * 404: Collection not found + /// + /// See: + /// * [searchCollections] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse searchCollectionsRaw({ required final String filter, final bool oCSAPIRequest = true, @@ -657,7 +947,22 @@ class CoreCollaborationResourcesClient { ); } - /// Get a collection + /// Get a collection. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [collectionId] ID of the collection + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Collection returned + /// * 404: Collection not found + /// * 500 + /// + /// See: + /// * [listCollectionRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> listCollection({ required final int collectionId, final bool oCSAPIRequest = true, @@ -670,7 +975,25 @@ class CoreCollaborationResourcesClient { return rawResponse.future; } - /// Get a collection + /// Get a collection. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [collectionId] ID of the collection + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Collection returned + /// * 404: Collection not found + /// * 500 + /// + /// See: + /// * [listCollection] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse listCollectionRaw({ required final int collectionId, final bool oCSAPIRequest = true, @@ -716,7 +1039,23 @@ class CoreCollaborationResourcesClient { ); } - /// Rename a collection + /// Rename a collection. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [collectionName] New name + /// * [collectionId] ID of the collection + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Collection returned + /// * 404: Collection not found + /// * 500 + /// + /// See: + /// * [renameCollectionRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> renameCollection({ required final String collectionName, required final int collectionId, @@ -731,7 +1070,26 @@ class CoreCollaborationResourcesClient { return rawResponse.future; } - /// Rename a collection + /// Rename a collection. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [collectionName] New name + /// * [collectionId] ID of the collection + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Collection returned + /// * 404: Collection not found + /// * 500 + /// + /// See: + /// * [renameCollection] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse renameCollectionRaw({ required final String collectionName, required final int collectionId, @@ -779,7 +1137,24 @@ class CoreCollaborationResourcesClient { ); } - /// Add a resource to a collection + /// Add a resource to a collection. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [resourceType] Name of the resource + /// * [resourceId] ID of the resource + /// * [collectionId] ID of the collection + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Collection returned + /// * 404: Collection not found or resource inaccessible + /// * 500 + /// + /// See: + /// * [addResourceRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> addResource({ required final String resourceType, required final String resourceId, @@ -796,7 +1171,27 @@ class CoreCollaborationResourcesClient { return rawResponse.future; } - /// Add a resource to a collection + /// Add a resource to a collection. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [resourceType] Name of the resource + /// * [resourceId] ID of the resource + /// * [collectionId] ID of the collection + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Collection returned + /// * 404: Collection not found or resource inaccessible + /// * 500 + /// + /// See: + /// * [addResource] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse addResourceRaw({ required final String resourceType, required final String resourceId, @@ -846,7 +1241,24 @@ class CoreCollaborationResourcesClient { ); } - /// Remove a resource from a collection + /// Remove a resource from a collection. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [resourceType] Name of the resource + /// * [resourceId] ID of the resource + /// * [collectionId] ID of the collection + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Collection returned + /// * 404: Collection or resource not found + /// * 500 + /// + /// See: + /// * [removeResourceRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> removeResource({ required final String resourceType, required final String resourceId, @@ -863,7 +1275,27 @@ class CoreCollaborationResourcesClient { return rawResponse.future; } - /// Remove a resource from a collection + /// Remove a resource from a collection. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [resourceType] Name of the resource + /// * [resourceId] ID of the resource + /// * [collectionId] ID of the collection + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Collection returned + /// * 404: Collection or resource not found + /// * 500 + /// + /// See: + /// * [removeResource] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse removeResourceRaw({ required final String resourceType, required final String resourceId, @@ -913,7 +1345,22 @@ class CoreCollaborationResourcesClient { ); } - /// Get collections by resource + /// Get collections by resource. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [resourceType] Type of the resource + /// * [resourceId] ID of the resource + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Collections returned + /// * 404: Resource not accessible + /// + /// See: + /// * [getCollectionsByResourceRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getCollectionsByResource({ required final String resourceType, @@ -929,7 +1376,25 @@ class CoreCollaborationResourcesClient { return rawResponse.future; } - /// Get collections by resource + /// Get collections by resource. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [resourceType] Type of the resource + /// * [resourceId] ID of the resource + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Collections returned + /// * 404: Resource not accessible + /// + /// See: + /// * [getCollectionsByResource] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getCollectionsByResourceRaw({ required final String resourceType, @@ -978,7 +1443,25 @@ class CoreCollaborationResourcesClient { ); } - /// Create a collection for a resource + /// Create a collection for a resource. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [name] Name of the collection + /// * [baseResourceType] Type of the base resource + /// * [baseResourceId] ID of the base resource + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Collection returned + /// * 400: Creating collection is not possible + /// * 404: Resource inaccessible + /// * 500 + /// + /// See: + /// * [createCollectionOnResourceRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> createCollectionOnResource({ required final String name, @@ -996,7 +1479,28 @@ class CoreCollaborationResourcesClient { return rawResponse.future; } - /// Create a collection for a resource + /// Create a collection for a resource. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [name] Name of the collection + /// * [baseResourceType] Type of the base resource + /// * [baseResourceId] ID of the base resource + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Collection returned + /// * 400: Creating collection is not possible + /// * 404: Resource inaccessible + /// * 500 + /// + /// See: + /// * [createCollectionOnResource] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse createCollectionOnResourceRaw({ required final String name, @@ -1054,7 +1558,22 @@ class CoreGuestAvatarClient { final CoreClient _rootClient; - /// Returns a dark guest avatar image response + /// Returns a dark guest avatar image response. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [guestName] The guest name, e.g. "Albert" + /// * [size] The desired avatar size, e.g. 64 for 64x64px + /// + /// Status codes: + /// * 200: Custom avatar returned + /// * 201: Avatar returned + /// * 500 + /// + /// See: + /// * [getAvatarDarkRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getAvatarDark({ required final String guestName, required final String size, @@ -1067,7 +1586,25 @@ class CoreGuestAvatarClient { return rawResponse.future; } - /// Returns a dark guest avatar image response + /// Returns a dark guest avatar image response. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [guestName] The guest name, e.g. "Albert" + /// * [size] The desired avatar size, e.g. 64 for 64x64px + /// + /// Status codes: + /// * 200: Custom avatar returned + /// * 201: Avatar returned + /// * 500 + /// + /// See: + /// * [getAvatarDark] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getAvatarDarkRaw({ required final String guestName, required final String size, @@ -1111,7 +1648,23 @@ class CoreGuestAvatarClient { ); } - /// Returns a guest avatar image response + /// Returns a guest avatar image response. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [darkTheme] Return dark avatar + /// * [guestName] The guest name, e.g. "Albert" + /// * [size] The desired avatar size, e.g. 64 for 64x64px + /// + /// Status codes: + /// * 200: Custom avatar returned + /// * 201: Avatar returned + /// * 500 + /// + /// See: + /// * [getAvatarRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getAvatar({ required final String guestName, required final String size, @@ -1126,7 +1679,26 @@ class CoreGuestAvatarClient { return rawResponse.future; } - /// Returns a guest avatar image response + /// Returns a guest avatar image response. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [darkTheme] Return dark avatar + /// * [guestName] The guest name, e.g. "Albert" + /// * [size] The desired avatar size, e.g. 64 for 64x64px + /// + /// Status codes: + /// * 200: Custom avatar returned + /// * 201: Avatar returned + /// * 500 + /// + /// See: + /// * [getAvatar] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getAvatarRaw({ required final String guestName, required final String size, @@ -1182,7 +1754,21 @@ class CoreHoverCardClient { final CoreClient _rootClient; - /// Get the user details for a hovercard + /// Get the user details for a hovercard. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User details returned + /// * 404: User not found + /// + /// See: + /// * [getUserRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getUser({ required final String userId, final bool oCSAPIRequest = true, @@ -1195,7 +1781,24 @@ class CoreHoverCardClient { return rawResponse.future; } - /// Get the user details for a hovercard + /// Get the user details for a hovercard. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User details returned + /// * 404: User not found + /// + /// See: + /// * [getUser] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getUserRaw({ required final String userId, final bool oCSAPIRequest = true, @@ -1247,7 +1850,21 @@ class CoreNavigationClient { final CoreClient _rootClient; - /// Get the apps navigation + /// Get the apps navigation. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [absolute] Rewrite URLs to absolute ones + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Apps navigation returned + /// * 304: No apps navigation changed + /// + /// See: + /// * [getAppsNavigationRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getAppsNavigation({ final int absolute = 0, final bool oCSAPIRequest = true, @@ -1260,7 +1877,24 @@ class CoreNavigationClient { return rawResponse.future; } - /// Get the apps navigation + /// Get the apps navigation. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [absolute] Rewrite URLs to absolute ones + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Apps navigation returned + /// * 304: No apps navigation changed + /// + /// See: + /// * [getAppsNavigation] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getAppsNavigationRaw({ final int absolute = 0, final bool oCSAPIRequest = true, @@ -1308,7 +1942,21 @@ class CoreNavigationClient { ); } - /// Get the settings navigation + /// Get the settings navigation. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [absolute] Rewrite URLs to absolute ones + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Apps navigation returned + /// * 304: No apps navigation changed + /// + /// See: + /// * [getSettingsNavigationRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getSettingsNavigation({ final int absolute = 0, final bool oCSAPIRequest = true, @@ -1321,7 +1969,24 @@ class CoreNavigationClient { return rawResponse.future; } - /// Get the settings navigation + /// Get the settings navigation. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [absolute] Rewrite URLs to absolute ones + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Apps navigation returned + /// * 304: No apps navigation changed + /// + /// See: + /// * [getSettingsNavigation] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getSettingsNavigationRaw({ final int absolute = 0, final bool oCSAPIRequest = true, @@ -1370,20 +2035,43 @@ class CoreNavigationClient { } } -/// Controller about the endpoint /ocm-provider/ +/// Controller about the endpoint /ocm-provider/. class CoreOcmClient { CoreOcmClient(this._rootClient); final CoreClient _rootClient; - /// generate a OCMProvider with local data and send it as DataResponse. This replaces the old PHP file ocm-provider/index.php + /// generate a OCMProvider with local data and send it as DataResponse. This replaces the old PHP file ocm-provider/index.php. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200: OCM Provider details returned + /// * 500: OCM not supported + /// + /// See: + /// * [discoveryRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> discovery() async { final rawResponse = discoveryRaw(); return rawResponse.future; } - /// generate a OCMProvider with local data and send it as DataResponse. This replaces the old PHP file ocm-provider/index.php + /// generate a OCMProvider with local data and send it as DataResponse. This replaces the old PHP file ocm-provider/index.php. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200: OCM Provider details returned + /// * 500: OCM not supported + /// + /// See: + /// * [discovery] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse discoveryRaw() { const path = '/index.php/ocm-provider'; final queryParameters = {}; @@ -1428,7 +2116,19 @@ class CoreOcsClient { final CoreClient _rootClient; - /// Get the capabilities + /// Get the capabilities. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Capabilities returned + /// + /// See: + /// * [getCapabilitiesRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getCapabilities({ final bool oCSAPIRequest = true, }) async { @@ -1439,7 +2139,22 @@ class CoreOcsClient { return rawResponse.future; } - /// Get the capabilities + /// Get the capabilities. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Capabilities returned + /// + /// See: + /// * [getCapabilities] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getCapabilitiesRaw({ final bool oCSAPIRequest = true, }) { @@ -1487,7 +2202,29 @@ class CorePreviewClient { final CoreClient _rootClient; - /// Get a preview by file ID + /// Get a preview by file ID. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [fileId] ID of the file + /// * [x] Width of the preview + /// * [y] Height of the preview + /// * [a] Whether to not crop the preview + /// * [forceIcon] Force returning an icon + /// * [mode] How to crop the image + /// * [mimeFallback] Whether to fallback to the mime icon if no preview is available + /// + /// Status codes: + /// * 200: Preview returned + /// * 400: Getting preview is not possible + /// * 403: Getting preview is not allowed + /// * 404: Preview not found + /// * 303: Redirect to the mime icon url if mimeFallback is true + /// + /// See: + /// * [getPreviewByFileIdRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getPreviewByFileId({ final int fileId = -1, final int x = 32, @@ -1510,7 +2247,32 @@ class CorePreviewClient { return rawResponse.future; } - /// Get a preview by file ID + /// Get a preview by file ID. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [fileId] ID of the file + /// * [x] Width of the preview + /// * [y] Height of the preview + /// * [a] Whether to not crop the preview + /// * [forceIcon] Force returning an icon + /// * [mode] How to crop the image + /// * [mimeFallback] Whether to fallback to the mime icon if no preview is available + /// + /// Status codes: + /// * 200: Preview returned + /// * 400: Getting preview is not possible + /// * 403: Getting preview is not allowed + /// * 404: Preview not found + /// * 303: Redirect to the mime icon url if mimeFallback is true + /// + /// See: + /// * [getPreviewByFileId] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getPreviewByFileIdRaw({ final int fileId = -1, final int x = 32, @@ -1580,7 +2342,29 @@ class CorePreviewClient { ); } - /// Get a preview by file path + /// Get a preview by file path. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [file] Path of the file + /// * [x] Width of the preview + /// * [y] Height of the preview + /// * [a] Whether to not crop the preview + /// * [forceIcon] Force returning an icon + /// * [mode] How to crop the image + /// * [mimeFallback] Whether to fallback to the mime icon if no preview is available + /// + /// Status codes: + /// * 200: Preview returned + /// * 400: Getting preview is not possible + /// * 403: Getting preview is not allowed + /// * 404: Preview not found + /// * 303: Redirect to the mime icon url if mimeFallback is true + /// + /// See: + /// * [getPreviewRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getPreview({ final String file = '', final int x = 32, @@ -1603,7 +2387,32 @@ class CorePreviewClient { return rawResponse.future; } - /// Get a preview by file path + /// Get a preview by file path. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [file] Path of the file + /// * [x] Width of the preview + /// * [y] Height of the preview + /// * [a] Whether to not crop the preview + /// * [forceIcon] Force returning an icon + /// * [mode] How to crop the image + /// * [mimeFallback] Whether to fallback to the mime icon if no preview is available + /// + /// Status codes: + /// * 200: Preview returned + /// * 400: Getting preview is not possible + /// * 403: Getting preview is not allowed + /// * 404: Preview not found + /// * 303: Redirect to the mime icon url if mimeFallback is true + /// + /// See: + /// * [getPreview] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getPreviewRaw({ final String file = '', final int x = 32, @@ -1679,7 +2488,25 @@ class CoreProfileApiClient { final CoreClient _rootClient; - /// Update the visibility of a parameter + /// Update the visibility of a parameter. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [paramId] ID of the parameter + /// * [visibility] New visibility + /// * [targetUserId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Visibility updated successfully + /// * 400: Updating visibility is not possible + /// * 403: Not allowed to edit other users visibility + /// * 404: User not found + /// + /// See: + /// * [setVisibilityRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> setVisibility({ required final String paramId, required final String visibility, @@ -1696,7 +2523,28 @@ class CoreProfileApiClient { return rawResponse.future; } - /// Update the visibility of a parameter + /// Update the visibility of a parameter. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [paramId] ID of the parameter + /// * [visibility] New visibility + /// * [targetUserId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Visibility updated successfully + /// * 400: Updating visibility is not possible + /// * 403: Not allowed to edit other users visibility + /// * 404: User not found + /// + /// See: + /// * [setVisibility] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse setVisibilityRaw({ required final String paramId, required final String visibility, @@ -1752,7 +2600,20 @@ class CoreReferenceClient { final CoreClient _rootClient; - /// Get a preview for a reference + /// Get a preview for a reference. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [referenceId] the reference cache key + /// + /// Status codes: + /// * 200: Preview returned + /// * 404: Reference not found + /// + /// See: + /// * [previewRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> preview({required final String referenceId}) async { final rawResponse = previewRaw( referenceId: referenceId, @@ -1761,7 +2622,23 @@ class CoreReferenceClient { return rawResponse.future; } - /// Get a preview for a reference + /// Get a preview for a reference. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [referenceId] the reference cache key + /// + /// Status codes: + /// * 200: Preview returned + /// * 404: Reference not found + /// + /// See: + /// * [preview] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse previewRaw({required final String referenceId}) { var path = '/index.php/core/references/preview/{referenceId}'; final queryParameters = {}; @@ -1807,7 +2684,20 @@ class CoreReferenceApiClient { final CoreClient _rootClient; - /// Resolve a reference + /// Resolve a reference. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [reference] Reference to resolve + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Reference returned + /// + /// See: + /// * [resolveOneRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> resolveOne({ required final String reference, final bool oCSAPIRequest = true, @@ -1820,7 +2710,23 @@ class CoreReferenceApiClient { return rawResponse.future; } - /// Resolve a reference + /// Resolve a reference. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [reference] Reference to resolve + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Reference returned + /// + /// See: + /// * [resolveOne] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse resolveOneRaw({ required final String reference, final bool oCSAPIRequest = true, @@ -1866,7 +2772,21 @@ class CoreReferenceApiClient { ); } - /// Resolve multiple references + /// Resolve multiple references. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [references] References to resolve + /// * [limit] Maximum amount of references to resolve + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: References returned + /// + /// See: + /// * [resolveRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> resolve({ required final List references, final int limit = 1, @@ -1881,7 +2801,24 @@ class CoreReferenceApiClient { return rawResponse.future; } - /// Resolve multiple references + /// Resolve multiple references. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [references] References to resolve + /// * [limit] Maximum amount of references to resolve + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: References returned + /// + /// See: + /// * [resolve] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse resolveRaw({ required final List references, final int limit = 1, @@ -1931,7 +2868,22 @@ class CoreReferenceApiClient { ); } - /// Extract references from a text + /// Extract references from a text. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [text] Text to extract from + /// * [resolve] Resolve the references + /// * [limit] Maximum amount of references to extract + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: References returned + /// + /// See: + /// * [extractRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> extract({ required final String text, final int resolve = 0, @@ -1948,7 +2900,25 @@ class CoreReferenceApiClient { return rawResponse.future; } - /// Extract references from a text + /// Extract references from a text. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [text] Text to extract from + /// * [resolve] Resolve the references + /// * [limit] Maximum amount of references to extract + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: References returned + /// + /// See: + /// * [extract] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse extractRaw({ required final String text, final int resolve = 0, @@ -2002,7 +2972,19 @@ class CoreReferenceApiClient { ); } - /// Get the providers + /// Get the providers. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Providers returned + /// + /// See: + /// * [getProvidersInfoRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getProvidersInfo({ final bool oCSAPIRequest = true, }) async { @@ -2013,7 +2995,22 @@ class CoreReferenceApiClient { return rawResponse.future; } - /// Get the providers + /// Get the providers. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Providers returned + /// + /// See: + /// * [getProvidersInfo] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getProvidersInfoRaw({ final bool oCSAPIRequest = true, }) { @@ -2057,7 +3054,21 @@ class CoreReferenceApiClient { ); } - /// Touch a provider + /// Touch a provider. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [timestamp] Timestamp of the last usage + /// * [providerId] ID of the provider + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Provider touched + /// + /// See: + /// * [touchProviderRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> touchProvider({ required final String providerId, final int? timestamp, @@ -2072,7 +3083,24 @@ class CoreReferenceApiClient { return rawResponse.future; } - /// Touch a provider + /// Touch a provider. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [timestamp] Timestamp of the last usage + /// * [providerId] ID of the provider + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Provider touched + /// + /// See: + /// * [touchProvider] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse touchProviderRaw({ required final String providerId, final int? timestamp, @@ -2128,7 +3156,19 @@ class CoreTextProcessingApiClient { final CoreClient _rootClient; - /// This endpoint returns all available LanguageModel task types + /// This endpoint returns all available LanguageModel task types. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Task types returned + /// + /// See: + /// * [taskTypesRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> taskTypes({ final bool oCSAPIRequest = true, }) async { @@ -2139,7 +3179,22 @@ class CoreTextProcessingApiClient { return rawResponse.future; } - /// This endpoint returns all available LanguageModel task types + /// This endpoint returns all available LanguageModel task types. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Task types returned + /// + /// See: + /// * [taskTypes] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse taskTypesRaw({ final bool oCSAPIRequest = true, }) { @@ -2181,7 +3236,25 @@ class CoreTextProcessingApiClient { ); } - /// This endpoint allows scheduling a language model task + /// This endpoint allows scheduling a language model task. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [input] Input text + /// * [type] Type of the task + /// * [appId] ID of the app that will execute the task + /// * [identifier] An arbitrary identifier for the task + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Task scheduled successfully + /// * 400: Scheduling task is not possible + /// * 412: Scheduling task is not possible + /// + /// See: + /// * [scheduleRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> schedule({ required final String input, required final String type, @@ -2200,7 +3273,28 @@ class CoreTextProcessingApiClient { return rawResponse.future; } - /// This endpoint allows scheduling a language model task + /// This endpoint allows scheduling a language model task. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [input] Input text + /// * [type] Type of the task + /// * [appId] ID of the app that will execute the task + /// * [identifier] An arbitrary identifier for the task + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Task scheduled successfully + /// * 400: Scheduling task is not possible + /// * 412: Scheduling task is not possible + /// + /// See: + /// * [schedule] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse scheduleRaw({ required final String input, required final String type, @@ -2253,6 +3347,21 @@ class CoreTextProcessingApiClient { } /// This endpoint allows checking the status and results of a task. Tasks are removed 1 week after receiving their last update. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] The id of the task + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Task returned + /// * 404: Task not found + /// * 500 + /// + /// See: + /// * [getTaskRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getTask({ required final int id, final bool oCSAPIRequest = true, @@ -2266,6 +3375,24 @@ class CoreTextProcessingApiClient { } /// This endpoint allows checking the status and results of a task. Tasks are removed 1 week after receiving their last update. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] The id of the task + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Task returned + /// * 404: Task not found + /// * 500 + /// + /// See: + /// * [getTask] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getTaskRaw({ required final int id, final bool oCSAPIRequest = true, @@ -2309,7 +3436,22 @@ class CoreTextProcessingApiClient { ); } - /// This endpoint allows to delete a scheduled task for a user + /// This endpoint allows to delete a scheduled task for a user. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] The id of the task + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Task returned + /// * 404: Task not found + /// * 500 + /// + /// See: + /// * [deleteTaskRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> deleteTask({ required final int id, final bool oCSAPIRequest = true, @@ -2322,7 +3464,25 @@ class CoreTextProcessingApiClient { return rawResponse.future; } - /// This endpoint allows to delete a scheduled task for a user + /// This endpoint allows to delete a scheduled task for a user. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] The id of the task + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Task returned + /// * 404: Task not found + /// * 500 + /// + /// See: + /// * [deleteTask] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse deleteTaskRaw({ required final int id, final bool oCSAPIRequest = true, @@ -2368,7 +3528,22 @@ class CoreTextProcessingApiClient { ); } - /// This endpoint returns a list of tasks of a user that are related with a specific appId and optionally with an identifier + /// This endpoint returns a list of tasks of a user that are related with a specific appId and optionally with an identifier. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [identifier] An arbitrary identifier for the task + /// * [appId] ID of the app + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Task list returned + /// * 500 + /// + /// See: + /// * [listTasksByAppRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> listTasksByApp({ required final String appId, final String? identifier, @@ -2383,7 +3558,25 @@ class CoreTextProcessingApiClient { return rawResponse.future; } - /// This endpoint returns a list of tasks of a user that are related with a specific appId and optionally with an identifier + /// This endpoint returns a list of tasks of a user that are related with a specific appId and optionally with an identifier. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [identifier] An arbitrary identifier for the task + /// * [appId] ID of the app + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Task list returned + /// * 500 + /// + /// See: + /// * [listTasksByApp] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse listTasksByAppRaw({ required final String appId, final String? identifier, @@ -2439,7 +3632,19 @@ class CoreTranslationApiClient { final CoreClient _rootClient; - /// Get the list of supported languages + /// Get the list of supported languages. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Supported languages returned + /// + /// See: + /// * [languagesRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> languages({ final bool oCSAPIRequest = true, }) async { @@ -2450,7 +3655,22 @@ class CoreTranslationApiClient { return rawResponse.future; } - /// Get the list of supported languages + /// Get the list of supported languages. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Supported languages returned + /// + /// See: + /// * [languages] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse languagesRaw({ final bool oCSAPIRequest = true, }) { @@ -2492,7 +3712,25 @@ class CoreTranslationApiClient { ); } - /// Translate a text + /// Translate a text. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [text] Text to be translated + /// * [fromLanguage] Language to translate from + /// * [toLanguage] Language to translate to + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Translated text returned + /// * 400: Language not detected or unable to translate + /// * 412: Translating is not possible + /// * 500 + /// + /// See: + /// * [translateRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> translate({ required final String text, required final String toLanguage, @@ -2509,7 +3747,28 @@ class CoreTranslationApiClient { return rawResponse.future; } - /// Translate a text + /// Translate a text. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [text] Text to be translated + /// * [fromLanguage] Language to translate from + /// * [toLanguage] Language to translate to + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Translated text returned + /// * 400: Language not detected or unable to translate + /// * 412: Translating is not possible + /// * 500 + /// + /// See: + /// * [translate] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse translateRaw({ required final String text, required final String toLanguage, @@ -2565,7 +3824,20 @@ class CoreUnifiedSearchClient { final CoreClient _rootClient; - /// Get the providers for unified search + /// Get the providers for unified search. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [from] the url the user is currently at + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Providers returned + /// + /// See: + /// * [getProvidersRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getProviders({ final String from = '', final bool oCSAPIRequest = true, @@ -2578,7 +3850,23 @@ class CoreUnifiedSearchClient { return rawResponse.future; } - /// Get the providers for unified search + /// Get the providers for unified search. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [from] the url the user is currently at + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Providers returned + /// + /// See: + /// * [getProviders] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getProvidersRaw({ final String from = '', final bool oCSAPIRequest = true, @@ -2626,7 +3914,26 @@ class CoreUnifiedSearchClient { ); } - /// Search + /// Search. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [term] Term to search + /// * [sortOrder] Order of entries + /// * [limit] Maximum amount of entries + /// * [cursor] Offset for searching + /// * [from] The current user URL + /// * [providerId] ID of the provider + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Search entries returned + /// * 400: Searching is not possible + /// + /// See: + /// * [searchRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> search({ required final String providerId, final String term = '', @@ -2649,7 +3956,29 @@ class CoreUnifiedSearchClient { return rawResponse.future; } - /// Search + /// Search. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [term] Term to search + /// * [sortOrder] Order of entries + /// * [limit] Maximum amount of entries + /// * [cursor] Offset for searching + /// * [from] The current user URL + /// * [providerId] ID of the provider + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Search entries returned + /// * 400: Searching is not possible + /// + /// See: + /// * [search] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse searchRaw({ required final String providerId, final String term = '', @@ -2724,7 +4053,20 @@ class CoreWhatsNewClient { final CoreClient _rootClient; - /// Get the changes + /// Get the changes. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Changes returned + /// * 204: No changes + /// + /// See: + /// * [$getRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> $get({final bool oCSAPIRequest = true}) async { final rawResponse = $getRaw( oCSAPIRequest: oCSAPIRequest, @@ -2733,7 +4075,23 @@ class CoreWhatsNewClient { return rawResponse.future; } - /// Get the changes + /// Get the changes. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Changes returned + /// * 204: No changes + /// + /// See: + /// * [$get] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse $getRaw({final bool oCSAPIRequest = true}) { const path = '/ocs/v2.php/core/whatsnew'; final queryParameters = {}; @@ -2775,7 +4133,21 @@ class CoreWhatsNewClient { ); } - /// Dismiss the changes + /// Dismiss the changes. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [version] Version to dismiss the changes for + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Changes dismissed + /// * 500 + /// + /// See: + /// * [dismissRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> dismiss({ required final String version, final bool oCSAPIRequest = true, @@ -2788,7 +4160,24 @@ class CoreWhatsNewClient { return rawResponse.future; } - /// Dismiss the changes + /// Dismiss the changes. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [version] Version to dismiss the changes for + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Changes dismissed + /// * 500 + /// + /// See: + /// * [dismiss] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse dismissRaw({ required final String version, final bool oCSAPIRequest = true, @@ -2840,7 +4229,20 @@ class CoreWipeClient { final CoreClient _rootClient; - /// Check if the device should be wiped + /// Check if the device should be wiped. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [token] App password + /// + /// Status codes: + /// * 200: Device should be wiped + /// * 404: Device should not be wiped + /// + /// See: + /// * [checkWipeRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> checkWipe({ required final String token, }) async { @@ -2851,7 +4253,23 @@ class CoreWipeClient { return rawResponse.future; } - /// Check if the device should be wiped + /// Check if the device should be wiped. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [token] App password + /// + /// Status codes: + /// * 200: Device should be wiped + /// * 404: Device should not be wiped + /// + /// See: + /// * [checkWipe] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse checkWipeRaw({required final String token}) { const path = '/index.php/core/wipe/check'; final queryParameters = {}; @@ -2891,7 +4309,20 @@ class CoreWipeClient { ); } - /// Finish the wipe + /// Finish the wipe. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [token] App password + /// + /// Status codes: + /// * 200: Wipe finished successfully + /// * 404: Device should not be wiped + /// + /// See: + /// * [wipeDoneRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> wipeDone({required final String token}) async { final rawResponse = wipeDoneRaw( token: token, @@ -2900,7 +4331,23 @@ class CoreWipeClient { return rawResponse.future; } - /// Finish the wipe + /// Finish the wipe. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [token] App password + /// + /// Status codes: + /// * 200: Wipe finished successfully + /// * 404: Device should not be wiped + /// + /// See: + /// * [wipeDone] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse wipeDoneRaw({required final String token}) { const path = '/index.php/core/wipe/success'; final queryParameters = {}; diff --git a/packages/nextcloud/lib/src/api/dashboard.openapi.dart b/packages/nextcloud/lib/src/api/dashboard.openapi.dart index a551ffe8..0c5b2abd 100644 --- a/packages/nextcloud/lib/src/api/dashboard.openapi.dart +++ b/packages/nextcloud/lib/src/api/dashboard.openapi.dart @@ -11,6 +11,8 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -43,7 +45,19 @@ class DashboardDashboardApiClient { final DashboardClient _rootClient; - /// Get the widgets + /// Get the widgets. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Widgets returned + /// + /// See: + /// * [getWidgetsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getWidgets({ final bool oCSAPIRequest = true, }) async { @@ -54,7 +68,22 @@ class DashboardDashboardApiClient { return rawResponse.future; } - /// Get the widgets + /// Get the widgets. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Widgets returned + /// + /// See: + /// * [getWidgets] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getWidgetsRaw({ final bool oCSAPIRequest = true, }) { @@ -98,7 +127,22 @@ class DashboardDashboardApiClient { ); } - /// Get the items for the widgets + /// Get the items for the widgets. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [sinceIds] Array indexed by widget Ids, contains date/id from which we want the new items + /// * [limit] Limit number of result items per widget + /// * [widgets] Limit results to specific widgets + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Widget items returned + /// + /// See: + /// * [getWidgetItemsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getWidgetItems({ final ContentString>? sinceIds, final int limit = 7, @@ -115,7 +159,25 @@ class DashboardDashboardApiClient { return rawResponse.future; } - /// Get the items for the widgets + /// Get the items for the widgets. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [sinceIds] Array indexed by widget Ids, contains date/id from which we want the new items + /// * [limit] Limit number of result items per widget + /// * [widgets] Limit results to specific widgets + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Widget items returned + /// + /// See: + /// * [getWidgetItems] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getWidgetItemsRaw({ final ContentString>? sinceIds, final int limit = 7, @@ -176,7 +238,22 @@ class DashboardDashboardApiClient { ); } - /// Get the items for the widgets + /// Get the items for the widgets. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [sinceIds] Array indexed by widget Ids, contains date/id from which we want the new items + /// * [limit] Limit number of result items per widget + /// * [widgets] Limit results to specific widgets + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Widget items returned + /// + /// See: + /// * [getWidgetItemsV2Raw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getWidgetItemsV2({ final ContentString>? sinceIds, final int limit = 7, @@ -193,7 +270,25 @@ class DashboardDashboardApiClient { return rawResponse.future; } - /// Get the items for the widgets + /// Get the items for the widgets. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [sinceIds] Array indexed by widget Ids, contains date/id from which we want the new items + /// * [limit] Limit number of result items per widget + /// * [widgets] Limit results to specific widgets + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Widget items returned + /// + /// See: + /// * [getWidgetItemsV2] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getWidgetItemsV2Raw({ final ContentString>? sinceIds, final int limit = 7, diff --git a/packages/nextcloud/lib/src/api/dav.openapi.dart b/packages/nextcloud/lib/src/api/dav.openapi.dart index 5b3505fb..e8b25221 100644 --- a/packages/nextcloud/lib/src/api/dav.openapi.dart +++ b/packages/nextcloud/lib/src/api/dav.openapi.dart @@ -10,6 +10,8 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -42,7 +44,24 @@ class DavDirectClient { final DavClient _rootClient; - /// Get a direct link to a file + /// Get a direct link to a file. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [fileId] ID of the file + /// * [expirationTime] Duration until the link expires + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Direct link returned + /// * 404: File not found + /// * 400: Getting direct link is not possible + /// * 403: Missing permissions to get direct link + /// + /// See: + /// * [getUrlRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getUrl({ required final int fileId, final int? expirationTime, @@ -57,7 +76,27 @@ class DavDirectClient { return rawResponse.future; } - /// Get a direct link to a file + /// Get a direct link to a file. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [fileId] ID of the file + /// * [expirationTime] Duration until the link expires + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Direct link returned + /// * 404: File not found + /// * 400: Getting direct link is not possible + /// * 403: Missing permissions to get direct link + /// + /// See: + /// * [getUrl] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getUrlRaw({ required final int fileId, final int? expirationTime, diff --git a/packages/nextcloud/lib/src/api/files.openapi.dart b/packages/nextcloud/lib/src/api/files.openapi.dart index 615b9c6e..5950e6e4 100644 --- a/packages/nextcloud/lib/src/api/files.openapi.dart +++ b/packages/nextcloud/lib/src/api/files.openapi.dart @@ -13,6 +13,8 @@ import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:dynamite_runtime/utils.dart'; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -53,7 +55,23 @@ class FilesApiClient { final FilesClient _rootClient; - /// Gets a thumbnail of the specified file + /// Gets a thumbnail of the specified file. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [x] Width of the thumbnail + /// * [y] Height of the thumbnail + /// * [file] URL-encoded filename + /// + /// Status codes: + /// * 200: Thumbnail returned + /// * 400: Getting thumbnail is not possible + /// * 404: File not found + /// + /// See: + /// * [getThumbnailRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getThumbnail({ required final int x, required final int y, @@ -68,7 +86,26 @@ class FilesApiClient { return rawResponse.future; } - /// Gets a thumbnail of the specified file + /// Gets a thumbnail of the specified file. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [x] Width of the thumbnail + /// * [y] Height of the thumbnail + /// * [file] URL-encoded filename + /// + /// Status codes: + /// * 200: Thumbnail returned + /// * 400: Getting thumbnail is not possible + /// * 404: File not found + /// + /// See: + /// * [getThumbnail] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getThumbnailRaw({ required final int x, required final int y, @@ -123,7 +160,19 @@ class FilesDirectEditingClient { final FilesClient _rootClient; - /// Get the direct editing capabilities + /// Get the direct editing capabilities. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Direct editing capabilities returned + /// + /// See: + /// * [infoRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> info({ final bool oCSAPIRequest = true, }) async { @@ -134,7 +183,22 @@ class FilesDirectEditingClient { return rawResponse.future; } - /// Get the direct editing capabilities + /// Get the direct editing capabilities. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Direct editing capabilities returned + /// + /// See: + /// * [info] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse infoRaw({final bool oCSAPIRequest = true}) { const path = '/ocs/v2.php/apps/files/api/v1/directEditing'; final queryParameters = {}; @@ -176,7 +240,22 @@ class FilesDirectEditingClient { ); } - /// Get the templates for direct editing + /// Get the templates for direct editing. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [editorId] ID of the editor + /// * [creatorId] ID of the creator + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Templates returned + /// * 500 + /// + /// See: + /// * [templatesRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> templates({ required final String editorId, required final String creatorId, @@ -191,7 +270,25 @@ class FilesDirectEditingClient { return rawResponse.future; } - /// Get the templates for direct editing + /// Get the templates for direct editing. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [editorId] ID of the editor + /// * [creatorId] ID of the creator + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Templates returned + /// * 500 + /// + /// See: + /// * [templates] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse templatesRaw({ required final String editorId, required final String creatorId, @@ -239,7 +336,24 @@ class FilesDirectEditingClient { ); } - /// Open a file for direct editing + /// Open a file for direct editing. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [path] Path of the file + /// * [editorId] ID of the editor + /// * [fileId] ID of the file + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: URL for direct editing returned + /// * 403: Opening file is not allowed + /// * 500 + /// + /// See: + /// * [openRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> open({ required final String path, final String? editorId, @@ -256,7 +370,27 @@ class FilesDirectEditingClient { return rawResponse.future; } - /// Open a file for direct editing + /// Open a file for direct editing. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [path] Path of the file + /// * [editorId] ID of the editor + /// * [fileId] ID of the file + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: URL for direct editing returned + /// * 403: Opening file is not allowed + /// * 500 + /// + /// See: + /// * [open] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse openRaw({ required final String path, final String? editorId, @@ -310,7 +444,25 @@ class FilesDirectEditingClient { ); } - /// Create a file for direct editing + /// Create a file for direct editing. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [path] Path of the file + /// * [editorId] ID of the editor + /// * [creatorId] ID of the creator + /// * [templateId] ID of the template + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: URL for direct editing returned + /// * 403: Opening file is not allowed + /// * 500 + /// + /// See: + /// * [createRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> create({ required final String path, required final String editorId, @@ -329,7 +481,28 @@ class FilesDirectEditingClient { return rawResponse.future; } - /// Create a file for direct editing + /// Create a file for direct editing. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [path] Path of the file + /// * [editorId] ID of the editor + /// * [creatorId] ID of the creator + /// * [templateId] ID of the template + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: URL for direct editing returned + /// * 403: Opening file is not allowed + /// * 500 + /// + /// See: + /// * [create] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse createRaw({ required final String path, required final String editorId, @@ -389,7 +562,21 @@ class FilesOpenLocalEditorClient { final FilesClient _rootClient; - /// Create a local editor + /// Create a local editor. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [path] Path of the file + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Local editor returned + /// * 500 + /// + /// See: + /// * [createRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> create({ required final String path, final bool oCSAPIRequest = true, @@ -402,7 +589,24 @@ class FilesOpenLocalEditorClient { return rawResponse.future; } - /// Create a local editor + /// Create a local editor. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [path] Path of the file + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Local editor returned + /// * 500 + /// + /// See: + /// * [create] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse createRaw({ required final String path, final bool oCSAPIRequest = true, @@ -448,7 +652,22 @@ class FilesOpenLocalEditorClient { ); } - /// Validate a local editor + /// Validate a local editor. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [path] Path of the file + /// * [token] Token of the local editor + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Local editor validated successfully + /// * 404: Local editor not found + /// + /// See: + /// * [validateRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> validate({ required final String path, required final String token, @@ -463,7 +682,25 @@ class FilesOpenLocalEditorClient { return rawResponse.future; } - /// Validate a local editor + /// Validate a local editor. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [path] Path of the file + /// * [token] Token of the local editor + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Local editor validated successfully + /// * 404: Local editor not found + /// + /// See: + /// * [validate] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse validateRaw({ required final String path, required final String token, @@ -517,7 +754,19 @@ class FilesTemplateClient { final FilesClient _rootClient; - /// List the available templates + /// List the available templates. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Available templates returned + /// + /// See: + /// * [listRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> list({ final bool oCSAPIRequest = true, }) async { @@ -528,7 +777,22 @@ class FilesTemplateClient { return rawResponse.future; } - /// List the available templates + /// List the available templates. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Available templates returned + /// + /// See: + /// * [list] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse listRaw({final bool oCSAPIRequest = true}) { const path = '/ocs/v2.php/apps/files/api/v1/templates'; final queryParameters = {}; @@ -570,7 +834,23 @@ class FilesTemplateClient { ); } - /// Create a template + /// Create a template. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [filePath] Path of the file + /// * [templatePath] Name of the template + /// * [templateType] Type of the template + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Template created successfully + /// * 403: Creating template is not allowed + /// + /// See: + /// * [createRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> create({ required final String filePath, final String templatePath = '', @@ -587,7 +867,26 @@ class FilesTemplateClient { return rawResponse.future; } - /// Create a template + /// Create a template. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [filePath] Path of the file + /// * [templatePath] Name of the template + /// * [templateType] Type of the template + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Template created successfully + /// * 403: Creating template is not allowed + /// + /// See: + /// * [create] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse createRaw({ required final String filePath, final String templatePath = '', @@ -641,7 +940,22 @@ class FilesTemplateClient { ); } - /// Initialize the template directory + /// Initialize the template directory. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [templatePath] Path of the template directory + /// * [copySystemTemplates] Whether to copy the system templates to the template directory + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Template directory initialized successfully + /// * 403: Initializing the template directory is not allowed + /// + /// See: + /// * [pathRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> path({ final String templatePath = '', final int copySystemTemplates = 0, @@ -656,7 +970,25 @@ class FilesTemplateClient { return rawResponse.future; } - /// Initialize the template directory + /// Initialize the template directory. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [templatePath] Path of the template directory + /// * [copySystemTemplates] Whether to copy the system templates to the template directory + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Template directory initialized successfully + /// * 403: Initializing the template directory is not allowed + /// + /// See: + /// * [path] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse pathRaw({ final String templatePath = '', final int copySystemTemplates = 0, @@ -714,7 +1046,23 @@ class FilesTransferOwnershipClient { final FilesClient _rootClient; - /// Transfer the ownership to another user + /// Transfer the ownership to another user. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [recipient] Username of the recipient + /// * [path] Path of the file + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Ownership transferred successfully + /// * 400: Transferring ownership is not possible + /// * 403: Transferring ownership is not allowed + /// + /// See: + /// * [transferRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> transfer({ required final String recipient, required final String path, @@ -729,7 +1077,26 @@ class FilesTransferOwnershipClient { return rawResponse.future; } - /// Transfer the ownership to another user + /// Transfer the ownership to another user. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [recipient] Username of the recipient + /// * [path] Path of the file + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Ownership transferred successfully + /// * 400: Transferring ownership is not possible + /// * 403: Transferring ownership is not allowed + /// + /// See: + /// * [transfer] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse transferRaw({ required final String recipient, required final String path, @@ -777,7 +1144,22 @@ class FilesTransferOwnershipClient { ); } - /// Accept an ownership transfer + /// Accept an ownership transfer. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] ID of the ownership transfer + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Ownership transfer accepted successfully + /// * 403: Accepting ownership transfer is not allowed + /// * 404: Ownership transfer not found + /// + /// See: + /// * [acceptRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> accept({ required final int id, final bool oCSAPIRequest = true, @@ -790,7 +1172,25 @@ class FilesTransferOwnershipClient { return rawResponse.future; } - /// Accept an ownership transfer + /// Accept an ownership transfer. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] ID of the ownership transfer + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Ownership transfer accepted successfully + /// * 403: Accepting ownership transfer is not allowed + /// * 404: Ownership transfer not found + /// + /// See: + /// * [accept] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse acceptRaw({ required final int id, final bool oCSAPIRequest = true, @@ -836,7 +1236,22 @@ class FilesTransferOwnershipClient { ); } - /// Reject an ownership transfer + /// Reject an ownership transfer. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] ID of the ownership transfer + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Ownership transfer rejected successfully + /// * 403: Rejecting ownership transfer is not allowed + /// * 404: Ownership transfer not found + /// + /// See: + /// * [rejectRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> reject({ required final int id, final bool oCSAPIRequest = true, @@ -849,7 +1264,25 @@ class FilesTransferOwnershipClient { return rawResponse.future; } - /// Reject an ownership transfer + /// Reject an ownership transfer. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] ID of the ownership transfer + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Ownership transfer rejected successfully + /// * 403: Rejecting ownership transfer is not allowed + /// * 404: Ownership transfer not found + /// + /// See: + /// * [reject] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse rejectRaw({ required final int id, final bool oCSAPIRequest = true, diff --git a/packages/nextcloud/lib/src/api/files_external.openapi.dart b/packages/nextcloud/lib/src/api/files_external.openapi.dart index abf4ce85..a77908ce 100644 --- a/packages/nextcloud/lib/src/api/files_external.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_external.openapi.dart @@ -12,6 +12,8 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -44,7 +46,19 @@ class FilesExternalApiClient { final FilesExternalClient _rootClient; - /// Get the mount points visible for this user + /// Get the mount points visible for this user. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User mounts returned + /// + /// See: + /// * [getUserMountsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getUserMounts({ final bool oCSAPIRequest = true, }) async { @@ -55,7 +69,22 @@ class FilesExternalApiClient { return rawResponse.future; } - /// Get the mount points visible for this user + /// Get the mount points visible for this user. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User mounts returned + /// + /// See: + /// * [getUserMounts] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getUserMountsRaw({ final bool oCSAPIRequest = true, }) { diff --git a/packages/nextcloud/lib/src/api/files_reminders.openapi.dart b/packages/nextcloud/lib/src/api/files_reminders.openapi.dart index b6267f9c..0ea53a93 100644 --- a/packages/nextcloud/lib/src/api/files_reminders.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_reminders.openapi.dart @@ -12,6 +12,8 @@ import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:dynamite_runtime/utils.dart'; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -44,7 +46,22 @@ class FilesRemindersApiClient { final FilesRemindersClient _rootClient; - /// Get a reminder + /// Get a reminder. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [version] + /// * [fileId] ID of the file + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Reminder returned + /// * 401: User not found + /// + /// See: + /// * [$getRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> $get({ required final String version, required final int fileId, @@ -59,7 +76,25 @@ class FilesRemindersApiClient { return rawResponse.future; } - /// Get a reminder + /// Get a reminder. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [version] + /// * [fileId] ID of the file + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Reminder returned + /// * 401: User not found + /// + /// See: + /// * [$get] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse $getRaw({ required final String version, required final int fileId, @@ -108,7 +143,26 @@ class FilesRemindersApiClient { ); } - /// Set a reminder + /// Set a reminder. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [dueDate] ISO 8601 formatted date time string + /// * [version] + /// * [fileId] ID of the file + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Reminder updated + /// * 201: Reminder created successfully + /// * 400: Creating reminder is not possible + /// * 401: User not found + /// * 404: File not found + /// + /// See: + /// * [$setRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> $set({ required final String dueDate, required final String version, @@ -125,7 +179,29 @@ class FilesRemindersApiClient { return rawResponse.future; } - /// Set a reminder + /// Set a reminder. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [dueDate] ISO 8601 formatted date time string + /// * [version] + /// * [fileId] ID of the file + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Reminder updated + /// * 201: Reminder created successfully + /// * 400: Creating reminder is not possible + /// * 401: User not found + /// * 404: File not found + /// + /// See: + /// * [$set] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse $setRaw({ required final String dueDate, required final String version, @@ -176,7 +252,23 @@ class FilesRemindersApiClient { ); } - /// Remove a reminder + /// Remove a reminder. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [version] + /// * [fileId] ID of the file + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Reminder deleted successfully + /// * 401: User not found + /// * 404: Reminder not found + /// + /// See: + /// * [removeRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> remove({ required final String version, required final int fileId, @@ -191,7 +283,26 @@ class FilesRemindersApiClient { return rawResponse.future; } - /// Remove a reminder + /// Remove a reminder. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [version] + /// * [fileId] ID of the file + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Reminder deleted successfully + /// * 401: User not found + /// * 404: Reminder not found + /// + /// See: + /// * [remove] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse removeRaw({ required final String version, required final int fileId, diff --git a/packages/nextcloud/lib/src/api/files_sharing.openapi.dart b/packages/nextcloud/lib/src/api/files_sharing.openapi.dart index b984d898..7c723bdb 100644 --- a/packages/nextcloud/lib/src/api/files_sharing.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_sharing.openapi.dart @@ -12,6 +12,8 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -54,7 +56,19 @@ class FilesSharingDeletedShareapiClient { final FilesSharingClient _rootClient; - /// Get a list of all deleted shares + /// Get a list of all deleted shares. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Deleted shares returned + /// + /// See: + /// * [listRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> list({ final bool oCSAPIRequest = true, }) async { @@ -65,7 +79,22 @@ class FilesSharingDeletedShareapiClient { return rawResponse.future; } - /// Get a list of all deleted shares + /// Get a list of all deleted shares. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Deleted shares returned + /// + /// See: + /// * [list] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse listRaw({ final bool oCSAPIRequest = true, }) { @@ -109,7 +138,21 @@ class FilesSharingDeletedShareapiClient { ); } - /// Undelete a deleted share + /// Undelete a deleted share. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] ID of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Share undeleted successfully + /// * 404: Share not found + /// + /// See: + /// * [undeleteRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> undelete({ required final String id, final bool oCSAPIRequest = true, @@ -122,7 +165,24 @@ class FilesSharingDeletedShareapiClient { return rawResponse.future; } - /// Undelete a deleted share + /// Undelete a deleted share. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] ID of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Share undeleted successfully + /// * 404: Share not found + /// + /// See: + /// * [undelete] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse undeleteRaw({ required final String id, final bool oCSAPIRequest = true, @@ -174,7 +234,23 @@ class FilesSharingPublicPreviewClient { final FilesSharingClient _rootClient; - /// Get a direct link preview for a shared file + /// Get a direct link preview for a shared file. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [token] Token of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Preview returned + /// * 400: Getting preview is not possible + /// * 403: Getting preview is not allowed + /// * 404: Share or preview not found + /// + /// See: + /// * [directLinkRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> directLink({ required final String token, final bool oCSAPIRequest = true, @@ -187,7 +263,26 @@ class FilesSharingPublicPreviewClient { return rawResponse.future; } - /// Get a direct link preview for a shared file + /// Get a direct link preview for a shared file. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [token] Token of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Preview returned + /// * 400: Getting preview is not possible + /// * 403: Getting preview is not allowed + /// * 404: Share or preview not found + /// + /// See: + /// * [directLink] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse directLinkRaw({ required final String token, final bool oCSAPIRequest = true, @@ -231,7 +326,27 @@ class FilesSharingPublicPreviewClient { ); } - /// Get a preview for a shared file + /// Get a preview for a shared file. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [file] File in the share + /// * [x] Width of the preview + /// * [y] Height of the preview + /// * [a] Whether to not crop the preview + /// * [token] Token of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Preview returned + /// * 400: Getting preview is not possible + /// * 403: Getting preview is not allowed + /// * 404: Share or preview not found + /// + /// See: + /// * [getPreviewRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getPreview({ required final String token, final String file = '', @@ -252,7 +367,30 @@ class FilesSharingPublicPreviewClient { return rawResponse.future; } - /// Get a preview for a shared file + /// Get a preview for a shared file. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [file] File in the share + /// * [x] Width of the preview + /// * [y] Height of the preview + /// * [a] Whether to not crop the preview + /// * [token] Token of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Preview returned + /// * 400: Getting preview is not possible + /// * 403: Getting preview is not allowed + /// * 404: Share or preview not found + /// + /// See: + /// * [getPreview] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getPreviewRaw({ required final String token, final String file = '', @@ -318,7 +456,19 @@ class FilesSharingRemoteClient { final FilesSharingClient _rootClient; - /// Get a list of accepted remote shares + /// Get a list of accepted remote shares. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Accepted remote shares returned + /// + /// See: + /// * [getSharesRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getShares({ final bool oCSAPIRequest = true, }) async { @@ -329,7 +479,22 @@ class FilesSharingRemoteClient { return rawResponse.future; } - /// Get a list of accepted remote shares + /// Get a list of accepted remote shares. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Accepted remote shares returned + /// + /// See: + /// * [getShares] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getSharesRaw({ final bool oCSAPIRequest = true, }) { @@ -373,7 +538,19 @@ class FilesSharingRemoteClient { ); } - /// Get list of pending remote shares + /// Get list of pending remote shares. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Pending remote shares returned + /// + /// See: + /// * [getOpenSharesRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getOpenShares({ final bool oCSAPIRequest = true, }) async { @@ -384,7 +561,22 @@ class FilesSharingRemoteClient { return rawResponse.future; } - /// Get list of pending remote shares + /// Get list of pending remote shares. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Pending remote shares returned + /// + /// See: + /// * [getOpenShares] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getOpenSharesRaw({ final bool oCSAPIRequest = true, }) { @@ -428,7 +620,21 @@ class FilesSharingRemoteClient { ); } - /// Accept a remote share + /// Accept a remote share. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] ID of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Share accepted successfully + /// * 404: Share not found + /// + /// See: + /// * [acceptShareRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> acceptShare({ required final int id, final bool oCSAPIRequest = true, @@ -441,7 +647,24 @@ class FilesSharingRemoteClient { return rawResponse.future; } - /// Accept a remote share + /// Accept a remote share. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] ID of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Share accepted successfully + /// * 404: Share not found + /// + /// See: + /// * [acceptShare] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse acceptShareRaw({ required final int id, final bool oCSAPIRequest = true, @@ -487,7 +710,21 @@ class FilesSharingRemoteClient { ); } - /// Decline a remote share + /// Decline a remote share. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] ID of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Share declined successfully + /// * 404: Share not found + /// + /// See: + /// * [declineShareRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> declineShare({ required final int id, final bool oCSAPIRequest = true, @@ -500,7 +737,24 @@ class FilesSharingRemoteClient { return rawResponse.future; } - /// Decline a remote share + /// Decline a remote share. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] ID of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Share declined successfully + /// * 404: Share not found + /// + /// See: + /// * [declineShare] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse declineShareRaw({ required final int id, final bool oCSAPIRequest = true, @@ -546,7 +800,21 @@ class FilesSharingRemoteClient { ); } - /// Get info of a remote share + /// Get info of a remote share. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] ID of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Share returned + /// * 404: Share not found + /// + /// See: + /// * [getShareRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getShare({ required final int id, final bool oCSAPIRequest = true, @@ -559,7 +827,24 @@ class FilesSharingRemoteClient { return rawResponse.future; } - /// Get info of a remote share + /// Get info of a remote share. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] ID of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Share returned + /// * 404: Share not found + /// + /// See: + /// * [getShare] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getShareRaw({ required final int id, final bool oCSAPIRequest = true, @@ -605,7 +890,22 @@ class FilesSharingRemoteClient { ); } - /// Unshare a remote share + /// Unshare a remote share. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] ID of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Share unshared successfully + /// * 404: Share not found + /// * 403: Unsharing is not possible + /// + /// See: + /// * [unshareRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> unshare({ required final int id, final bool oCSAPIRequest = true, @@ -618,7 +918,25 @@ class FilesSharingRemoteClient { return rawResponse.future; } - /// Unshare a remote share + /// Unshare a remote share. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] ID of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Share unshared successfully + /// * 404: Share not found + /// * 403: Unsharing is not possible + /// + /// See: + /// * [unshare] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse unshareRaw({ required final int id, final bool oCSAPIRequest = true, @@ -670,7 +988,24 @@ class FilesSharingShareInfoClient { final FilesSharingClient _rootClient; - /// Get the info about a share + /// Get the info about a share. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [t] Token of the share + /// * [password] Password of the share + /// * [dir] Subdirectory to get info about + /// * [depth] Maximum depth to get info about + /// + /// Status codes: + /// * 200: Share info returned + /// * 403: Getting share info is not allowed + /// * 404: Share not found + /// + /// See: + /// * [infoRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> info({ required final String t, final String? password, @@ -687,7 +1022,27 @@ class FilesSharingShareInfoClient { return rawResponse.future; } - /// Get the info about a share + /// Get the info about a share. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [t] Token of the share + /// * [password] Password of the share + /// * [dir] Subdirectory to get info about + /// * [depth] Maximum depth to get info about + /// + /// Status codes: + /// * 200: Share info returned + /// * 403: Getting share info is not allowed + /// * 404: Share not found + /// + /// See: + /// * [info] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse infoRaw({ required final String t, final String? password, @@ -747,7 +1102,25 @@ class FilesSharingShareapiClient { final FilesSharingClient _rootClient; - /// Get shares of the current user + /// Get shares of the current user. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [sharedWithMe] Only get shares with the current user + /// * [reshares] Only get shares by the current user and reshares + /// * [subfiles] Only get all shares in a folder + /// * [path] Get shares for a specific path + /// * [includeTags] Include tags in the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Shares returned + /// * 404: The folder was not found or is inaccessible + /// + /// See: + /// * [getSharesRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getShares({ final String sharedWithMe = 'false', final String reshares = 'false', @@ -768,7 +1141,28 @@ class FilesSharingShareapiClient { return rawResponse.future; } - /// Get shares of the current user + /// Get shares of the current user. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [sharedWithMe] Only get shares with the current user + /// * [reshares] Only get shares by the current user and reshares + /// * [subfiles] Only get all shares in a folder + /// * [path] Get shares for a specific path + /// * [includeTags] Include tags in the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Shares returned + /// * 404: The folder was not found or is inaccessible + /// + /// See: + /// * [getShares] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getSharesRaw({ final String sharedWithMe = 'false', final String reshares = 'false', @@ -832,7 +1226,33 @@ class FilesSharingShareapiClient { ); } - /// Create a share + /// Create a share. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [path] Path of the share + /// * [permissions] Permissions for the share + /// * [shareType] Type of the share + /// * [shareWith] The entity this should be shared with + /// * [publicUpload] If public uploading is allowed + /// * [password] Password for the share + /// * [sendPasswordByTalk] Send the password for the share over Talk + /// * [expireDate] Expiry date of the share + /// * [note] Note for the share + /// * [label] Label for the share (only used in link and email) + /// * [attributes] Additional attributes for the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Share created + /// * 400: Unknown share type + /// * 403: Creating the share is not allowed + /// * 404: Creating the share failed + /// + /// See: + /// * [createShareRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> createShare({ final String? path, final int? permissions, @@ -865,7 +1285,36 @@ class FilesSharingShareapiClient { return rawResponse.future; } - /// Create a share + /// Create a share. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [path] Path of the share + /// * [permissions] Permissions for the share + /// * [shareType] Type of the share + /// * [shareWith] The entity this should be shared with + /// * [publicUpload] If public uploading is allowed + /// * [password] Password for the share + /// * [sendPasswordByTalk] Send the password for the share over Talk + /// * [expireDate] Expiry date of the share + /// * [note] Note for the share + /// * [label] Label for the share (only used in link and email) + /// * [attributes] Additional attributes for the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Share created + /// * 400: Unknown share type + /// * 403: Creating the share is not allowed + /// * 404: Creating the share failed + /// + /// See: + /// * [createShare] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse createShareRaw({ final String? path, final int? permissions, @@ -953,7 +1402,22 @@ class FilesSharingShareapiClient { ); } - /// Get all shares relative to a file, including parent folders shares rights + /// Get all shares relative to a file, including parent folders shares rights. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [path] Path all shares will be relative to + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Shares returned + /// * 500 + /// * 404: The given path is invalid + /// + /// See: + /// * [getInheritedSharesRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getInheritedShares({ required final String path, final bool oCSAPIRequest = true, @@ -966,7 +1430,25 @@ class FilesSharingShareapiClient { return rawResponse.future; } - /// Get all shares relative to a file, including parent folders shares rights + /// Get all shares relative to a file, including parent folders shares rights. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [path] Path all shares will be relative to + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Shares returned + /// * 500 + /// * 404: The given path is invalid + /// + /// See: + /// * [getInheritedShares] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getInheritedSharesRaw({ required final String path, final bool oCSAPIRequest = true, @@ -1012,7 +1494,19 @@ class FilesSharingShareapiClient { ); } - /// Get all shares that are still pending + /// Get all shares that are still pending. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Pending shares returned + /// + /// See: + /// * [pendingSharesRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> pendingShares({ final bool oCSAPIRequest = true, }) async { @@ -1023,7 +1517,22 @@ class FilesSharingShareapiClient { return rawResponse.future; } - /// Get all shares that are still pending + /// Get all shares that are still pending. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Pending shares returned + /// + /// See: + /// * [pendingShares] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse pendingSharesRaw({ final bool oCSAPIRequest = true, }) { @@ -1067,7 +1576,22 @@ class FilesSharingShareapiClient { ); } - /// Get a specific share by id + /// Get a specific share by id. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [includeTags] Include tags in the share + /// * [id] ID of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Share returned + /// * 404: Share not found + /// + /// See: + /// * [getShareRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getShare({ required final String id, final int includeTags = 0, @@ -1082,7 +1606,25 @@ class FilesSharingShareapiClient { return rawResponse.future; } - /// Get a specific share by id + /// Get a specific share by id. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [includeTags] Include tags in the share + /// * [id] ID of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Share returned + /// * 404: Share not found + /// + /// See: + /// * [getShare] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getShareRaw({ required final String id, final int includeTags = 0, @@ -1132,7 +1674,32 @@ class FilesSharingShareapiClient { ); } - /// Update a share + /// Update a share. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [permissions] New permissions + /// * [password] New password + /// * [sendPasswordByTalk] New condition if the password should be send over Talk + /// * [publicUpload] New condition if public uploading is allowed + /// * [expireDate] New expiry date + /// * [note] New note + /// * [label] New label + /// * [hideDownload] New condition if the download should be hidden + /// * [attributes] New additional attributes + /// * [id] ID of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Share updated successfully + /// * 400: Share could not be updated because the requested changes are invalid + /// * 403: Missing permissions to update the share + /// * 404: Share not found + /// + /// See: + /// * [updateShareRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> updateShare({ required final String id, final int? permissions, @@ -1163,7 +1730,35 @@ class FilesSharingShareapiClient { return rawResponse.future; } - /// Update a share + /// Update a share. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [permissions] New permissions + /// * [password] New password + /// * [sendPasswordByTalk] New condition if the password should be send over Talk + /// * [publicUpload] New condition if public uploading is allowed + /// * [expireDate] New expiry date + /// * [note] New note + /// * [label] New label + /// * [hideDownload] New condition if the download should be hidden + /// * [attributes] New additional attributes + /// * [id] ID of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Share updated successfully + /// * 400: Share could not be updated because the requested changes are invalid + /// * 403: Missing permissions to update the share + /// * 404: Share not found + /// + /// See: + /// * [updateShare] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse updateShareRaw({ required final String id, final int? permissions, @@ -1245,7 +1840,22 @@ class FilesSharingShareapiClient { ); } - /// Delete a share + /// Delete a share. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] ID of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Share deleted successfully + /// * 404: Share not found + /// * 403: Missing permissions to delete the share + /// + /// See: + /// * [deleteShareRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> deleteShare({ required final String id, final bool oCSAPIRequest = true, @@ -1258,7 +1868,25 @@ class FilesSharingShareapiClient { return rawResponse.future; } - /// Delete a share + /// Delete a share. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] ID of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Share deleted successfully + /// * 404: Share not found + /// * 403: Missing permissions to delete the share + /// + /// See: + /// * [deleteShare] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse deleteShareRaw({ required final String id, final bool oCSAPIRequest = true, @@ -1304,7 +1932,22 @@ class FilesSharingShareapiClient { ); } - /// Accept a share + /// Accept a share. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] ID of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Share accepted successfully + /// * 404: Share not found + /// * 400: Share could not be accepted + /// + /// See: + /// * [acceptShareRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> acceptShare({ required final String id, final bool oCSAPIRequest = true, @@ -1317,7 +1960,25 @@ class FilesSharingShareapiClient { return rawResponse.future; } - /// Accept a share + /// Accept a share. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [id] ID of the share + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Share accepted successfully + /// * 404: Share not found + /// * 400: Share could not be accepted + /// + /// See: + /// * [acceptShare] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse acceptShareRaw({ required final String id, final bool oCSAPIRequest = true, @@ -1369,7 +2030,26 @@ class FilesSharingShareesapiClient { final FilesSharingClient _rootClient; - /// Search for sharees + /// Search for sharees. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [search] Text to search for + /// * [itemType] Limit to specific item types + /// * [page] Page offset for searching + /// * [perPage] Limit amount of search results per page + /// * [shareType] Limit to specific share types + /// * [lookup] If a global lookup should be performed too + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Sharees search result returned + /// * 400: Invalid search parameters + /// + /// See: + /// * [searchRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future< DynamiteResponse> search({ @@ -1394,7 +2074,29 @@ class FilesSharingShareesapiClient { return rawResponse.future; } - /// Search for sharees + /// Search for sharees. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [search] Text to search for + /// * [itemType] Limit to specific item types + /// * [page] Page offset for searching + /// * [perPage] Limit amount of search results per page + /// * [shareType] Limit to specific share types + /// * [lookup] If a global lookup should be performed too + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Sharees search result returned + /// * 400: Invalid search parameters + /// + /// See: + /// * [search] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse searchRaw({ final String search = '', @@ -1467,7 +2169,21 @@ class FilesSharingShareesapiClient { ); } - /// Find recommended sharees + /// Find recommended sharees. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [itemType] Limit to specific item types + /// * [shareType] Limit to specific share types + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Recommended sharees returned + /// + /// See: + /// * [findRecommendedRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> findRecommended({ required final String itemType, final ContentString? shareType, @@ -1482,7 +2198,24 @@ class FilesSharingShareesapiClient { return rawResponse.future; } - /// Find recommended sharees + /// Find recommended sharees. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [itemType] Limit to specific item types + /// * [shareType] Limit to specific share types + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Recommended sharees returned + /// + /// See: + /// * [findRecommended] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse findRecommendedRaw({ required final String itemType, final ContentString? shareType, diff --git a/packages/nextcloud/lib/src/api/files_trashbin.openapi.dart b/packages/nextcloud/lib/src/api/files_trashbin.openapi.dart index 6aa8aa3f..b3b54e2d 100644 --- a/packages/nextcloud/lib/src/api/files_trashbin.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_trashbin.openapi.dart @@ -10,6 +10,8 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -42,7 +44,24 @@ class FilesTrashbinPreviewClient { final FilesTrashbinClient _rootClient; - /// Get the preview for a file + /// Get the preview for a file. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [fileId] ID of the file + /// * [x] Width of the preview + /// * [y] Height of the preview + /// * [a] Whether to not crop the preview + /// + /// Status codes: + /// * 200: Preview returned + /// * 400: Getting preview is not possible + /// * 404: Preview not found + /// + /// See: + /// * [getPreviewRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getPreview({ final int fileId = -1, final int x = 32, @@ -59,7 +78,27 @@ class FilesTrashbinPreviewClient { return rawResponse.future; } - /// Get the preview for a file + /// Get the preview for a file. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [fileId] ID of the file + /// * [x] Width of the preview + /// * [y] Height of the preview + /// * [a] Whether to not crop the preview + /// + /// Status codes: + /// * 200: Preview returned + /// * 400: Getting preview is not possible + /// * 404: Preview not found + /// + /// See: + /// * [getPreview] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getPreviewRaw({ final int fileId = -1, final int x = 32, diff --git a/packages/nextcloud/lib/src/api/files_versions.openapi.dart b/packages/nextcloud/lib/src/api/files_versions.openapi.dart index 54750077..2a57fa96 100644 --- a/packages/nextcloud/lib/src/api/files_versions.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_versions.openapi.dart @@ -10,6 +10,8 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -42,7 +44,24 @@ class FilesVersionsPreviewClient { final FilesVersionsClient _rootClient; - /// Get the preview for a file version + /// Get the preview for a file version. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [file] Path of the file + /// * [x] Width of the preview + /// * [y] Height of the preview + /// * [version] Version of the file to get the preview for + /// + /// Status codes: + /// * 200: Preview returned + /// * 400: Getting preview is not possible + /// * 404: Preview not found + /// + /// See: + /// * [getPreviewRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getPreview({ final String file = '', final int x = 44, @@ -59,7 +78,27 @@ class FilesVersionsPreviewClient { return rawResponse.future; } - /// Get the preview for a file version + /// Get the preview for a file version. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [file] Path of the file + /// * [x] Width of the preview + /// * [y] Height of the preview + /// * [version] Version of the file to get the preview for + /// + /// Status codes: + /// * 200: Preview returned + /// * 400: Getting preview is not possible + /// * 404: Preview not found + /// + /// See: + /// * [getPreview] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getPreviewRaw({ final String file = '', final int x = 44, diff --git a/packages/nextcloud/lib/src/api/news.openapi.dart b/packages/nextcloud/lib/src/api/news.openapi.dart index 6a7581e9..7abfaa7a 100644 --- a/packages/nextcloud/lib/src/api/news.openapi.dart +++ b/packages/nextcloud/lib/src/api/news.openapi.dart @@ -12,6 +12,8 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -36,12 +38,31 @@ class NewsClient extends DynamiteClient { authentications: client.authentications, ); + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [getSupportedApiVersionsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getSupportedApiVersions() async { final rawResponse = getSupportedApiVersionsRaw(); return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [getSupportedApiVersions] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getSupportedApiVersionsRaw() { const path = '/index.php/apps/news/api'; final queryParameters = {}; @@ -82,12 +103,31 @@ class NewsClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [listFoldersRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> listFolders() async { final rawResponse = listFoldersRaw(); return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [listFolders] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse listFoldersRaw() { const path = '/index.php/apps/news/api/v1-3/folders'; final queryParameters = {}; @@ -128,6 +168,17 @@ class NewsClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [name] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [createFolderRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> createFolder({required final String name}) async { final rawResponse = createFolderRaw( name: name, @@ -136,6 +187,20 @@ class NewsClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [name] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [createFolder] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse createFolderRaw({required final String name}) { const path = '/index.php/apps/news/api/v1-3/folders'; final queryParameters = {}; @@ -177,6 +242,17 @@ class NewsClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [name] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [renameFolderRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> renameFolder({ required final int folderId, required final String name, @@ -189,6 +265,20 @@ class NewsClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [name] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [renameFolder] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse renameFolderRaw({ required final int folderId, required final String name, @@ -232,6 +322,14 @@ class NewsClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [deleteFolderRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> deleteFolder({required final int folderId}) async { final rawResponse = deleteFolderRaw( folderId: folderId, @@ -240,6 +338,17 @@ class NewsClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [deleteFolder] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse deleteFolderRaw({required final int folderId}) { var path = '/index.php/apps/news/api/v1-3/folders/{folderId}'; final queryParameters = {}; @@ -279,6 +388,17 @@ class NewsClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [newestItemId] The newest read item + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [markFolderAsReadRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> markFolderAsRead({ required final int folderId, required final int newestItemId, @@ -291,6 +411,20 @@ class NewsClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [newestItemId] The newest read item + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [markFolderAsRead] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse markFolderAsReadRaw({ required final int folderId, required final int newestItemId, @@ -334,12 +468,31 @@ class NewsClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [listFeedsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> listFeeds() async { final rawResponse = listFeedsRaw(); return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [listFeeds] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse listFeedsRaw() { const path = '/index.php/apps/news/api/v1-3/feeds'; final queryParameters = {}; @@ -380,6 +533,18 @@ class NewsClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [url] + /// * [folderId] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [addFeedRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> addFeed({ required final String url, final int? folderId, @@ -392,6 +557,21 @@ class NewsClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [url] + /// * [folderId] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [addFeed] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse addFeedRaw({ required final String url, final int? folderId, @@ -439,6 +619,14 @@ class NewsClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [deleteFeedRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> deleteFeed({required final int feedId}) async { final rawResponse = deleteFeedRaw( feedId: feedId, @@ -447,6 +635,17 @@ class NewsClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [deleteFeed] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse deleteFeedRaw({required final int feedId}) { var path = '/index.php/apps/news/api/v1-3/feeds/{feedId}'; final queryParameters = {}; @@ -486,6 +685,17 @@ class NewsClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [folderId] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [moveFeedRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> moveFeed({ required final int feedId, final int? folderId, @@ -498,6 +708,20 @@ class NewsClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [folderId] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [moveFeed] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse moveFeedRaw({ required final int feedId, final int? folderId, @@ -543,6 +767,17 @@ class NewsClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [feedTitle] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [renameFeedRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> renameFeed({ required final int feedId, required final String feedTitle, @@ -555,6 +790,20 @@ class NewsClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [feedTitle] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [renameFeed] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse renameFeedRaw({ required final int feedId, required final String feedTitle, @@ -598,6 +847,17 @@ class NewsClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [newestItemId] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [markFeedAsReadRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> markFeedAsRead({ required final int feedId, required final int newestItemId, @@ -610,6 +870,20 @@ class NewsClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [newestItemId] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [markFeedAsRead] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse markFeedAsReadRaw({ required final int feedId, required final int newestItemId, @@ -653,6 +927,22 @@ class NewsClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [type] + /// * [id] + /// * [getRead] + /// * [batchSize] + /// * [offset] + /// * [oldestFirst] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [listArticlesRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> listArticles({ final int type = 3, final int id = 0, @@ -673,6 +963,25 @@ class NewsClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [type] + /// * [id] + /// * [getRead] + /// * [batchSize] + /// * [offset] + /// * [oldestFirst] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [listArticles] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse listArticlesRaw({ final int type = 3, final int id = 0, @@ -738,6 +1047,19 @@ class NewsClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [type] + /// * [id] + /// * [lastModified] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [listUpdatedArticlesRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> listUpdatedArticles({ final int type = 3, final int id = 0, @@ -752,6 +1074,22 @@ class NewsClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [type] + /// * [id] + /// * [lastModified] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [listUpdatedArticles] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse listUpdatedArticlesRaw({ final int type = 3, final int id = 0, @@ -805,6 +1143,14 @@ class NewsClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [markArticleAsReadRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> markArticleAsRead({required final int itemId}) async { final rawResponse = markArticleAsReadRaw( itemId: itemId, @@ -813,6 +1159,17 @@ class NewsClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [markArticleAsRead] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse markArticleAsReadRaw({required final int itemId}) { var path = '/index.php/apps/news/api/v1-3/items/{itemId}/read'; final queryParameters = {}; @@ -852,6 +1209,14 @@ class NewsClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [markArticleAsUnreadRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> markArticleAsUnread({required final int itemId}) async { final rawResponse = markArticleAsUnreadRaw( itemId: itemId, @@ -860,6 +1225,17 @@ class NewsClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [markArticleAsUnread] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse markArticleAsUnreadRaw({required final int itemId}) { var path = '/index.php/apps/news/api/v1-3/items/{itemId}/unread'; final queryParameters = {}; @@ -899,6 +1275,14 @@ class NewsClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [starArticleRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> starArticle({required final int itemId}) async { final rawResponse = starArticleRaw( itemId: itemId, @@ -907,6 +1291,17 @@ class NewsClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [starArticle] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse starArticleRaw({required final int itemId}) { var path = '/index.php/apps/news/api/v1-3/items/{itemId}/star'; final queryParameters = {}; @@ -946,6 +1341,14 @@ class NewsClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [unstarArticleRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> unstarArticle({required final int itemId}) async { final rawResponse = unstarArticleRaw( itemId: itemId, @@ -954,6 +1357,17 @@ class NewsClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [unstarArticle] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse unstarArticleRaw({required final int itemId}) { var path = '/index.php/apps/news/api/v1-3/items/{itemId}/unstar'; final queryParameters = {}; @@ -1109,7 +1523,7 @@ abstract interface class NewsFolderInterface { String get name; bool get opened; - /// This seems to be broken. In testing it is always empty + /// This seems to be broken. In testing it is always empty. BuiltList get feeds; NewsFolderInterface rebuild(final void Function(NewsFolderInterfaceBuilder) updates); NewsFolderInterfaceBuilder toBuilder(); diff --git a/packages/nextcloud/lib/src/api/notes.openapi.dart b/packages/nextcloud/lib/src/api/notes.openapi.dart index 0eeb21f4..44f71db2 100644 --- a/packages/nextcloud/lib/src/api/notes.openapi.dart +++ b/packages/nextcloud/lib/src/api/notes.openapi.dart @@ -13,6 +13,8 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -37,6 +39,22 @@ class NotesClient extends DynamiteClient { authentications: client.authentications, ); + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [category] + /// * [exclude] + /// * [pruneBefore] + /// * [chunkSize] + /// * [chunkCursor] + /// * [ifNoneMatch] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [getNotesRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future, void>> getNotes({ final String? category, final String exclude = '', @@ -57,6 +75,25 @@ class NotesClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [category] + /// * [exclude] + /// * [pruneBefore] + /// * [chunkSize] + /// * [chunkCursor] + /// * [ifNoneMatch] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [getNotes] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse, void> getNotesRaw({ final String? category, final String exclude = '', @@ -122,6 +159,21 @@ class NotesClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [category] + /// * [title] + /// * [content] + /// * [modified] + /// * [favorite] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [createNoteRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> createNote({ final String category = '', final String title = '', @@ -140,6 +192,24 @@ class NotesClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [category] + /// * [title] + /// * [content] + /// * [modified] + /// * [favorite] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [createNote] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse createNoteRaw({ final String category = '', final String title = '', @@ -201,6 +271,18 @@ class NotesClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [exclude] + /// * [ifNoneMatch] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [getNoteRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getNote({ required final int id, final String exclude = '', @@ -215,6 +297,21 @@ class NotesClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [exclude] + /// * [ifNoneMatch] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [getNote] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getNoteRaw({ required final int id, final String exclude = '', @@ -266,6 +363,22 @@ class NotesClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [content] + /// * [modified] + /// * [title] + /// * [category] + /// * [favorite] + /// * [ifMatch] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [updateNoteRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> updateNote({ required final int id, final String? content, @@ -288,6 +401,25 @@ class NotesClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [content] + /// * [modified] + /// * [title] + /// * [category] + /// * [favorite] + /// * [ifMatch] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [updateNote] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse updateNoteRaw({ required final int id, final String? content, @@ -355,6 +487,14 @@ class NotesClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [deleteNoteRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> deleteNote({required final int id}) async { final rawResponse = deleteNoteRaw( id: id, @@ -363,6 +503,17 @@ class NotesClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [deleteNote] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse deleteNoteRaw({required final int id}) { var path = '/index.php/apps/notes/api/v1/notes/{id}'; final queryParameters = {}; @@ -404,12 +555,31 @@ class NotesClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [getSettingsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getSettings() async { final rawResponse = getSettingsRaw(); return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [getSettings] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getSettingsRaw() { const path = '/index.php/apps/notes/api/v1/settings'; final queryParameters = {}; @@ -450,6 +620,14 @@ class NotesClient extends DynamiteClient { ); } + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [updateSettingsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> updateSettings({required final NotesSettings settings}) async { final rawResponse = updateSettingsRaw( settings: settings, @@ -458,6 +636,17 @@ class NotesClient extends DynamiteClient { return rawResponse.future; } + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [updateSettings] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse updateSettingsRaw({required final NotesSettings settings}) { const path = '/index.php/apps/notes/api/v1/settings'; final queryParameters = {}; diff --git a/packages/nextcloud/lib/src/api/notifications.openapi.dart b/packages/nextcloud/lib/src/api/notifications.openapi.dart index a2729e74..3cd31b00 100644 --- a/packages/nextcloud/lib/src/api/notifications.openapi.dart +++ b/packages/nextcloud/lib/src/api/notifications.openapi.dart @@ -12,6 +12,8 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -50,9 +52,28 @@ class NotificationsApiClient { final NotificationsClient _rootClient; - /// Generate a notification for a user + /// Generate a notification for a user. /// - /// This endpoint requires admin access + /// This endpoint requires admin access. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [shortMessage] Subject of the notification + /// * [longMessage] Message of the notification + /// * [apiVersion] + /// * [userId] ID of the user + /// * [oCSAPIRequest] + /// + /// Status codes: + /// * 200: Notification generated successfully + /// * 400: Generating notification is not possible + /// * 404: User not found + /// * 500 + /// + /// See: + /// * [generateNotificationRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> generateNotification({ required final String shortMessage, required final String userId, @@ -71,9 +92,31 @@ class NotificationsApiClient { return rawResponse.future; } - /// Generate a notification for a user + /// Generate a notification for a user. + /// + /// This endpoint requires admin access. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. /// - /// This endpoint requires admin access + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [shortMessage] Subject of the notification + /// * [longMessage] Message of the notification + /// * [apiVersion] + /// * [userId] ID of the user + /// * [oCSAPIRequest] + /// + /// Status codes: + /// * 200: Notification generated successfully + /// * 400: Generating notification is not possible + /// * 404: User not found + /// * 500 + /// + /// See: + /// * [generateNotification] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse generateNotificationRaw({ required final String shortMessage, required final String userId, @@ -133,7 +176,21 @@ class NotificationsEndpointClient { final NotificationsClient _rootClient; - /// Get all notifications + /// Get all notifications. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [apiVersion] Version of the API to use + /// * [oCSAPIRequest] + /// + /// Status codes: + /// * 200: Notifications returned + /// * 204: No app uses notifications + /// + /// See: + /// * [listNotificationsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future< DynamiteResponse> listNotifications({ @@ -149,7 +206,24 @@ class NotificationsEndpointClient { return rawResponse.future; } - /// Get all notifications + /// Get all notifications. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [apiVersion] Version of the API to use + /// * [oCSAPIRequest] + /// + /// Status codes: + /// * 200: Notifications returned + /// * 204: No app uses notifications + /// + /// See: + /// * [listNotifications] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse listNotificationsRaw({ final NotificationsEndpointListNotificationsApiVersion apiVersion = @@ -198,7 +272,21 @@ class NotificationsEndpointClient { ); } - /// Delete all notifications + /// Delete all notifications. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [apiVersion] + /// * [oCSAPIRequest] + /// + /// Status codes: + /// * 200: All notifications deleted successfully + /// * 403: Deleting notification for impersonated user is not allowed + /// + /// See: + /// * [deleteAllNotificationsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> deleteAllNotifications({ final NotificationsEndpointDeleteAllNotificationsApiVersion apiVersion = @@ -213,7 +301,24 @@ class NotificationsEndpointClient { return rawResponse.future; } - /// Delete all notifications + /// Delete all notifications. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [apiVersion] + /// * [oCSAPIRequest] + /// + /// Status codes: + /// * 200: All notifications deleted successfully + /// * 403: Deleting notification for impersonated user is not allowed + /// + /// See: + /// * [deleteAllNotifications] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse deleteAllNotificationsRaw({ final NotificationsEndpointDeleteAllNotificationsApiVersion apiVersion = @@ -261,7 +366,22 @@ class NotificationsEndpointClient { ); } - /// Get a notification + /// Get a notification. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [apiVersion] Version of the API to use + /// * [id] ID of the notification + /// * [oCSAPIRequest] + /// + /// Status codes: + /// * 200: Notification returned + /// * 404: Notification not found + /// + /// See: + /// * [getNotificationRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getNotification({ required final int id, final NotificationsEndpointGetNotificationApiVersion apiVersion = NotificationsEndpointGetNotificationApiVersion.v2, @@ -276,7 +396,25 @@ class NotificationsEndpointClient { return rawResponse.future; } - /// Get a notification + /// Get a notification. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [apiVersion] Version of the API to use + /// * [id] ID of the notification + /// * [oCSAPIRequest] + /// + /// Status codes: + /// * 200: Notification returned + /// * 404: Notification not found + /// + /// See: + /// * [getNotification] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getNotificationRaw({ required final int id, final NotificationsEndpointGetNotificationApiVersion apiVersion = NotificationsEndpointGetNotificationApiVersion.v2, @@ -324,7 +462,23 @@ class NotificationsEndpointClient { ); } - /// Delete a notification + /// Delete a notification. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [apiVersion] + /// * [id] ID of the notification + /// * [oCSAPIRequest] + /// + /// Status codes: + /// * 200: Notification deleted successfully + /// * 403: Deleting notification for impersonated user is not allowed + /// * 404: Notification not found + /// + /// See: + /// * [deleteNotificationRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> deleteNotification({ required final int id, final NotificationsEndpointDeleteNotificationApiVersion apiVersion = @@ -340,7 +494,26 @@ class NotificationsEndpointClient { return rawResponse.future; } - /// Delete a notification + /// Delete a notification. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [apiVersion] + /// * [id] ID of the notification + /// * [oCSAPIRequest] + /// + /// Status codes: + /// * 200: Notification deleted successfully + /// * 403: Deleting notification for impersonated user is not allowed + /// * 404: Notification not found + /// + /// See: + /// * [deleteNotification] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse deleteNotificationRaw({ required final int id, final NotificationsEndpointDeleteNotificationApiVersion apiVersion = @@ -389,7 +562,22 @@ class NotificationsEndpointClient { ); } - /// Check if notification IDs exist + /// Check if notification IDs exist. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [ids] IDs of the notifications to check + /// * [apiVersion] Version of the API to use + /// * [oCSAPIRequest] + /// + /// Status codes: + /// * 200: Existing notification IDs returned + /// * 400: Too many notification IDs requested + /// + /// See: + /// * [confirmIdsForUserRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> confirmIdsForUser({ required final List ids, final NotificationsEndpointConfirmIdsForUserApiVersion apiVersion = @@ -405,7 +593,25 @@ class NotificationsEndpointClient { return rawResponse.future; } - /// Check if notification IDs exist + /// Check if notification IDs exist. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [ids] IDs of the notifications to check + /// * [apiVersion] Version of the API to use + /// * [oCSAPIRequest] + /// + /// Status codes: + /// * 200: Existing notification IDs returned + /// * 400: Too many notification IDs requested + /// + /// See: + /// * [confirmIdsForUser] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse confirmIdsForUserRaw({ required final List ids, final NotificationsEndpointConfirmIdsForUserApiVersion apiVersion = @@ -460,7 +666,26 @@ class NotificationsPushClient { final NotificationsClient _rootClient; - /// Register device for push notifications + /// Register device for push notifications. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [pushTokenHash] Hash of the push token + /// * [devicePublicKey] Public key of the device + /// * [proxyServer] Proxy server to be used + /// * [apiVersion] + /// * [oCSAPIRequest] + /// + /// Status codes: + /// * 200: Device was already registered + /// * 201: Device registered successfully + /// * 400: Registering device is not possible + /// * 401: Missing permissions to register device + /// + /// See: + /// * [registerDeviceRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> registerDevice({ required final String pushTokenHash, required final String devicePublicKey, @@ -479,7 +704,29 @@ class NotificationsPushClient { return rawResponse.future; } - /// Register device for push notifications + /// Register device for push notifications. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [pushTokenHash] Hash of the push token + /// * [devicePublicKey] Public key of the device + /// * [proxyServer] Proxy server to be used + /// * [apiVersion] + /// * [oCSAPIRequest] + /// + /// Status codes: + /// * 200: Device was already registered + /// * 201: Device registered successfully + /// * 400: Registering device is not possible + /// * 401: Missing permissions to register device + /// + /// See: + /// * [registerDevice] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse registerDeviceRaw({ required final String pushTokenHash, required final String devicePublicKey, @@ -531,7 +778,23 @@ class NotificationsPushClient { ); } - /// Remove a device from push notifications + /// Remove a device from push notifications. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [apiVersion] + /// * [oCSAPIRequest] + /// + /// Status codes: + /// * 200: No device registered + /// * 202: Device removed successfully + /// * 401: Missing permissions to remove device + /// * 400: Removing device is not possible + /// + /// See: + /// * [removeDeviceRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> removeDevice({ final NotificationsPushRemoveDeviceApiVersion apiVersion = NotificationsPushRemoveDeviceApiVersion.v2, final String oCSAPIRequest = 'true', @@ -544,7 +807,26 @@ class NotificationsPushClient { return rawResponse.future; } - /// Remove a device from push notifications + /// Remove a device from push notifications. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [apiVersion] + /// * [oCSAPIRequest] + /// + /// Status codes: + /// * 200: No device registered + /// * 202: Device removed successfully + /// * 401: Missing permissions to remove device + /// * 400: Removing device is not possible + /// + /// See: + /// * [removeDevice] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse removeDeviceRaw({ final NotificationsPushRemoveDeviceApiVersion apiVersion = NotificationsPushRemoveDeviceApiVersion.v2, final String oCSAPIRequest = 'true', @@ -596,7 +878,23 @@ class NotificationsSettingsClient { final NotificationsClient _rootClient; - /// Update personal notification settings + /// Update personal notification settings. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [batchSetting] How often E-mails about missed notifications should be sent (hourly: 1; every three hours: 2; daily: 3; weekly: 4) + /// * [soundNotification] Enable sound for notifications ('yes' or 'no') + /// * [soundTalk] Enable sound for Talk notifications ('yes' or 'no') + /// * [apiVersion] + /// * [oCSAPIRequest] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [personalRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> personal({ required final int batchSetting, required final String soundNotification, @@ -615,7 +913,26 @@ class NotificationsSettingsClient { return rawResponse.future; } - /// Update personal notification settings + /// Update personal notification settings. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [batchSetting] How often E-mails about missed notifications should be sent (hourly: 1; every three hours: 2; daily: 3; weekly: 4) + /// * [soundNotification] Enable sound for notifications ('yes' or 'no') + /// * [soundTalk] Enable sound for Talk notifications ('yes' or 'no') + /// * [apiVersion] + /// * [oCSAPIRequest] + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [personal] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse personalRaw({ required final int batchSetting, required final String soundNotification, @@ -667,9 +984,25 @@ class NotificationsSettingsClient { ); } - /// Update default notification settings for new users + /// Update default notification settings for new users. + /// + /// This endpoint requires admin access. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [batchSetting] How often E-mails about missed notifications should be sent (hourly: 1; every three hours: 2; daily: 3; weekly: 4) + /// * [soundNotification] Enable sound for notifications ('yes' or 'no') + /// * [soundTalk] Enable sound for Talk notifications ('yes' or 'no') + /// * [apiVersion] + /// * [oCSAPIRequest] + /// + /// Status codes: + /// * 200 /// - /// This endpoint requires admin access + /// See: + /// * [adminRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> admin({ required final int batchSetting, required final String soundNotification, @@ -688,9 +1021,28 @@ class NotificationsSettingsClient { return rawResponse.future; } - /// Update default notification settings for new users + /// Update default notification settings for new users. + /// + /// This endpoint requires admin access. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [batchSetting] How often E-mails about missed notifications should be sent (hourly: 1; every three hours: 2; daily: 3; weekly: 4) + /// * [soundNotification] Enable sound for notifications ('yes' or 'no') + /// * [soundTalk] Enable sound for Talk notifications ('yes' or 'no') + /// * [apiVersion] + /// * [oCSAPIRequest] + /// + /// Status codes: + /// * 200 /// - /// This endpoint requires admin access + /// See: + /// * [admin] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse adminRaw({ required final int batchSetting, required final String soundNotification, diff --git a/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart b/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart index 01b37ff4..20172d85 100644 --- a/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart +++ b/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart @@ -13,6 +13,8 @@ import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:dynamite_runtime/utils.dart'; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -53,9 +55,21 @@ class ProvisioningApiAppConfigClient { final ProvisioningApiClient _rootClient; - /// Get a list of apps + /// Get a list of apps. /// - /// This endpoint requires admin access + /// This endpoint requires admin access. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Apps returned + /// + /// See: + /// * [getAppsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getApps({ final bool oCSAPIRequest = true, }) async { @@ -66,9 +80,24 @@ class ProvisioningApiAppConfigClient { return rawResponse.future; } - /// Get a list of apps + /// Get a list of apps. + /// + /// This endpoint requires admin access. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// - /// This endpoint requires admin access + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Apps returned + /// + /// See: + /// * [getApps] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getAppsRaw({ final bool oCSAPIRequest = true, }) { @@ -112,9 +141,23 @@ class ProvisioningApiAppConfigClient { ); } - /// Get the config keys of an app + /// Get the config keys of an app. + /// + /// This endpoint requires admin access. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [app] ID of the app + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Keys returned + /// * 403: App is not allowed /// - /// This endpoint requires admin access + /// See: + /// * [getKeysRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getKeys({ required final String app, final bool oCSAPIRequest = true, @@ -127,9 +170,26 @@ class ProvisioningApiAppConfigClient { return rawResponse.future; } - /// Get the config keys of an app + /// Get the config keys of an app. /// - /// This endpoint requires admin access + /// This endpoint requires admin access. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [app] ID of the app + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Keys returned + /// * 403: App is not allowed + /// + /// See: + /// * [getKeys] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getKeysRaw({ required final String app, final bool oCSAPIRequest = true, @@ -175,9 +235,25 @@ class ProvisioningApiAppConfigClient { ); } - /// Get a the config value of an app + /// Get a the config value of an app. + /// + /// This endpoint requires admin access. /// - /// This endpoint requires admin access + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [defaultValue] Default returned value if the value is empty + /// * [app] ID of the app + /// * [key] Key + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Value returned + /// * 403: App is not allowed + /// + /// See: + /// * [getValueRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getValue({ required final String app, required final String key, @@ -194,9 +270,28 @@ class ProvisioningApiAppConfigClient { return rawResponse.future; } - /// Get a the config value of an app + /// Get a the config value of an app. + /// + /// This endpoint requires admin access. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// - /// This endpoint requires admin access + /// Parameters: + /// * [defaultValue] Default returned value if the value is empty + /// * [app] ID of the app + /// * [key] Key + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Value returned + /// * 403: App is not allowed + /// + /// See: + /// * [getValue] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getValueRaw({ required final String app, required final String key, @@ -248,7 +343,23 @@ class ProvisioningApiAppConfigClient { ); } - /// Update the config value of an app + /// Update the config value of an app. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [value] New value for the key + /// * [app] ID of the app + /// * [key] Key to update + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Value updated successfully + /// * 403: App or key is not allowed + /// + /// See: + /// * [setValueRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> setValue({ required final String value, required final String app, @@ -265,7 +376,26 @@ class ProvisioningApiAppConfigClient { return rawResponse.future; } - /// Update the config value of an app + /// Update the config value of an app. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [value] New value for the key + /// * [app] ID of the app + /// * [key] Key to update + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Value updated successfully + /// * 403: App or key is not allowed + /// + /// See: + /// * [setValue] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse setValueRaw({ required final String value, required final String app, @@ -315,9 +445,24 @@ class ProvisioningApiAppConfigClient { ); } - /// Delete a config key of an app + /// Delete a config key of an app. + /// + /// This endpoint requires admin access. /// - /// This endpoint requires admin access + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [app] ID of the app + /// * [key] Key to delete + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Key deleted successfully + /// * 403: App or key is not allowed + /// + /// See: + /// * [deleteKeyRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> deleteKey({ required final String app, required final String key, @@ -332,9 +477,27 @@ class ProvisioningApiAppConfigClient { return rawResponse.future; } - /// Delete a config key of an app + /// Delete a config key of an app. + /// + /// This endpoint requires admin access. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// - /// This endpoint requires admin access + /// Parameters: + /// * [app] ID of the app + /// * [key] Key to delete + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Key deleted successfully + /// * 403: App or key is not allowed + /// + /// See: + /// * [deleteKey] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse deleteKeyRaw({ required final String app, required final String key, @@ -388,9 +551,22 @@ class ProvisioningApiAppsClient { final ProvisioningApiClient _rootClient; - /// Get a list of installed apps + /// Get a list of installed apps. + /// + /// This endpoint requires admin access. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [filter] Filter for enabled or disabled apps + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Installed apps returned /// - /// This endpoint requires admin access + /// See: + /// * [getAppsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getApps({ final String? filter, final bool oCSAPIRequest = true, @@ -403,9 +579,25 @@ class ProvisioningApiAppsClient { return rawResponse.future; } - /// Get a list of installed apps + /// Get a list of installed apps. /// - /// This endpoint requires admin access + /// This endpoint requires admin access. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [filter] Filter for enabled or disabled apps + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Installed apps returned + /// + /// See: + /// * [getApps] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getAppsRaw({ final String? filter, final bool oCSAPIRequest = true, @@ -453,9 +645,22 @@ class ProvisioningApiAppsClient { ); } - /// Get the app info for an app + /// Get the app info for an app. + /// + /// This endpoint requires admin access. /// - /// This endpoint requires admin access + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [app] ID of the app + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: App info returned + /// + /// See: + /// * [getAppInfoRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getAppInfo({ required final String app, final bool oCSAPIRequest = true, @@ -468,9 +673,25 @@ class ProvisioningApiAppsClient { return rawResponse.future; } - /// Get the app info for an app + /// Get the app info for an app. + /// + /// This endpoint requires admin access. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// - /// This endpoint requires admin access + /// Parameters: + /// * [app] ID of the app + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: App info returned + /// + /// See: + /// * [getAppInfo] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getAppInfoRaw({ required final String app, final bool oCSAPIRequest = true, @@ -516,9 +737,22 @@ class ProvisioningApiAppsClient { ); } - /// Enable an app + /// Enable an app. + /// + /// This endpoint requires admin access. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [app] ID of the app + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: App enabled successfully /// - /// This endpoint requires admin access + /// See: + /// * [enableRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> enable({ required final String app, final bool oCSAPIRequest = true, @@ -531,9 +765,25 @@ class ProvisioningApiAppsClient { return rawResponse.future; } - /// Enable an app + /// Enable an app. /// - /// This endpoint requires admin access + /// This endpoint requires admin access. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [app] ID of the app + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: App enabled successfully + /// + /// See: + /// * [enable] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse enableRaw({ required final String app, final bool oCSAPIRequest = true, @@ -579,9 +829,22 @@ class ProvisioningApiAppsClient { ); } - /// Disable an app + /// Disable an app. + /// + /// This endpoint requires admin access. /// - /// This endpoint requires admin access + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [app] ID of the app + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: App disabled successfully + /// + /// See: + /// * [disableRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> disable({ required final String app, final bool oCSAPIRequest = true, @@ -594,9 +857,25 @@ class ProvisioningApiAppsClient { return rawResponse.future; } - /// Disable an app + /// Disable an app. + /// + /// This endpoint requires admin access. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// - /// This endpoint requires admin access + /// Parameters: + /// * [app] ID of the app + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: App disabled successfully + /// + /// See: + /// * [disable] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse disableRaw({ required final String app, final bool oCSAPIRequest = true, @@ -648,7 +927,22 @@ class ProvisioningApiGroupsClient { final ProvisioningApiClient _rootClient; - /// Get a list of groups + /// Get a list of groups. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [search] Text to search for + /// * [limit] Limit the amount of groups returned + /// * [offset] Offset for searching for groups + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Groups returned + /// + /// See: + /// * [getGroupsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getGroups({ final String search = '', final int? limit, @@ -665,7 +959,25 @@ class ProvisioningApiGroupsClient { return rawResponse.future; } - /// Get a list of groups + /// Get a list of groups. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [search] Text to search for + /// * [limit] Limit the amount of groups returned + /// * [offset] Offset for searching for groups + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Groups returned + /// + /// See: + /// * [getGroups] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getGroupsRaw({ final String search = '', final int? limit, @@ -721,9 +1033,23 @@ class ProvisioningApiGroupsClient { ); } - /// Create a new group + /// Create a new group. + /// + /// This endpoint requires admin access. /// - /// This endpoint requires admin access + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [groupid] ID of the group + /// * [displayname] Display name of the group + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Group created successfully + /// + /// See: + /// * [addGroupRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> addGroup({ required final String groupid, final String displayname = '', @@ -738,9 +1064,26 @@ class ProvisioningApiGroupsClient { return rawResponse.future; } - /// Create a new group + /// Create a new group. + /// + /// This endpoint requires admin access. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// - /// This endpoint requires admin access + /// Parameters: + /// * [groupid] ID of the group + /// * [displayname] Display name of the group + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Group created successfully + /// + /// See: + /// * [addGroup] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse addGroupRaw({ required final String groupid, final String displayname = '', @@ -790,7 +1133,22 @@ class ProvisioningApiGroupsClient { ); } - /// Get a list of groups details + /// Get a list of groups details. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [search] Text to search for + /// * [limit] Limit the amount of groups returned + /// * [offset] Offset for searching for groups + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Groups details returned + /// + /// See: + /// * [getGroupsDetailsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getGroupsDetails({ final String search = '', final int? limit, @@ -807,7 +1165,25 @@ class ProvisioningApiGroupsClient { return rawResponse.future; } - /// Get a list of groups details + /// Get a list of groups details. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [search] Text to search for + /// * [limit] Limit the amount of groups returned + /// * [offset] Offset for searching for groups + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Groups details returned + /// + /// See: + /// * [getGroupsDetails] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getGroupsDetailsRaw({ final String search = '', final int? limit, @@ -863,7 +1239,22 @@ class ProvisioningApiGroupsClient { ); } - /// Get a list of users in the specified group + /// Get a list of users in the specified group. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [groupId] ID of the group + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User IDs returned + /// * 404: Group not found + /// * 403: Missing permissions to get users in the group + /// + /// See: + /// * [getGroupUsersRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getGroupUsers({ required final String groupId, final bool oCSAPIRequest = true, @@ -876,7 +1267,25 @@ class ProvisioningApiGroupsClient { return rawResponse.future; } - /// Get a list of users in the specified group + /// Get a list of users in the specified group. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [groupId] ID of the group + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User IDs returned + /// * 404: Group not found + /// * 403: Missing permissions to get users in the group + /// + /// See: + /// * [getGroupUsers] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getGroupUsersRaw({ required final String groupId, final bool oCSAPIRequest = true, @@ -923,7 +1332,23 @@ class ProvisioningApiGroupsClient { ); } - /// Get a list of users details in the specified group + /// Get a list of users details in the specified group. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [search] Text to search for + /// * [limit] Limit the amount of groups returned + /// * [offset] Offset for searching for groups + /// * [groupId] ID of the group + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Group users details returned + /// + /// See: + /// * [getGroupUsersDetailsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getGroupUsersDetails({ required final String groupId, @@ -943,7 +1368,26 @@ class ProvisioningApiGroupsClient { return rawResponse.future; } - /// Get a list of users details in the specified group + /// Get a list of users details in the specified group. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [search] Text to search for + /// * [limit] Limit the amount of groups returned + /// * [offset] Offset for searching for groups + /// * [groupId] ID of the group + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Group users details returned + /// + /// See: + /// * [getGroupUsersDetails] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getGroupUsersDetailsRaw({ required final String groupId, final String search = '', @@ -1002,9 +1446,22 @@ class ProvisioningApiGroupsClient { ); } - /// Get the list of user IDs that are a subadmin of the group + /// Get the list of user IDs that are a subadmin of the group. + /// + /// This endpoint requires admin access. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// - /// This endpoint requires admin access + /// Parameters: + /// * [groupId] ID of the group + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Sub admins returned + /// + /// See: + /// * [getSubAdminsOfGroupRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getSubAdminsOfGroup({ required final String groupId, final bool oCSAPIRequest = true, @@ -1017,9 +1474,25 @@ class ProvisioningApiGroupsClient { return rawResponse.future; } - /// Get the list of user IDs that are a subadmin of the group + /// Get the list of user IDs that are a subadmin of the group. + /// + /// This endpoint requires admin access. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [groupId] ID of the group + /// * [oCSAPIRequest] Required to be true for the API request to pass /// - /// This endpoint requires admin access + /// Status codes: + /// * 200: Sub admins returned + /// + /// See: + /// * [getSubAdminsOfGroup] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getSubAdminsOfGroupRaw({ required final String groupId, final bool oCSAPIRequest = true, @@ -1066,7 +1539,20 @@ class ProvisioningApiGroupsClient { ); } - /// Get a list of users in the specified group + /// Get a list of users in the specified group. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [groupId] ID of the group + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Group users returned + /// + /// See: + /// * [getGroupRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. @Deprecated('') Future> getGroup({ required final String groupId, @@ -1080,7 +1566,23 @@ class ProvisioningApiGroupsClient { return rawResponse.future; } - /// Get a list of users in the specified group + /// Get a list of users in the specified group. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [groupId] ID of the group + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Group users returned + /// + /// See: + /// * [getGroup] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental @Deprecated('') DynamiteRawResponse getGroupRaw({ required final String groupId, @@ -1128,9 +1630,24 @@ class ProvisioningApiGroupsClient { ); } - /// Update a group + /// Update a group. + /// + /// This endpoint requires admin access. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// - /// This endpoint requires admin access + /// Parameters: + /// * [key] Key to update, only 'displayname' + /// * [value] New value for the key + /// * [groupId] ID of the group + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Group updated successfully + /// + /// See: + /// * [updateGroupRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> updateGroup({ required final String key, required final String value, @@ -1147,9 +1664,27 @@ class ProvisioningApiGroupsClient { return rawResponse.future; } - /// Update a group + /// Update a group. + /// + /// This endpoint requires admin access. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [key] Key to update, only 'displayname' + /// * [value] New value for the key + /// * [groupId] ID of the group + /// * [oCSAPIRequest] Required to be true for the API request to pass /// - /// This endpoint requires admin access + /// Status codes: + /// * 200: Group updated successfully + /// + /// See: + /// * [updateGroup] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse updateGroupRaw({ required final String key, required final String value, @@ -1200,9 +1735,22 @@ class ProvisioningApiGroupsClient { ); } - /// Delete a group + /// Delete a group. + /// + /// This endpoint requires admin access. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// - /// This endpoint requires admin access + /// Parameters: + /// * [groupId] ID of the group + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Group deleted successfully + /// + /// See: + /// * [deleteGroupRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> deleteGroup({ required final String groupId, final bool oCSAPIRequest = true, @@ -1215,9 +1763,25 @@ class ProvisioningApiGroupsClient { return rawResponse.future; } - /// Delete a group + /// Delete a group. + /// + /// This endpoint requires admin access. /// - /// This endpoint requires admin access + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [groupId] ID of the group + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Group deleted successfully + /// + /// See: + /// * [deleteGroup] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse deleteGroupRaw({ required final String groupId, final bool oCSAPIRequest = true, @@ -1270,7 +1834,23 @@ class ProvisioningApiPreferencesClient { final ProvisioningApiClient _rootClient; - /// Update a preference value of an app + /// Update a preference value of an app. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [configValue] New value + /// * [appId] ID of the app + /// * [configKey] Key of the preference + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Preference updated successfully + /// * 400: Preference invalid + /// + /// See: + /// * [setPreferenceRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> setPreference({ required final String configValue, required final String appId, @@ -1287,7 +1867,26 @@ class ProvisioningApiPreferencesClient { return rawResponse.future; } - /// Update a preference value of an app + /// Update a preference value of an app. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [configValue] New value + /// * [appId] ID of the app + /// * [configKey] Key of the preference + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Preference updated successfully + /// * 400: Preference invalid + /// + /// See: + /// * [setPreference] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse setPreferenceRaw({ required final String configValue, required final String appId, @@ -1337,7 +1936,22 @@ class ProvisioningApiPreferencesClient { ); } - /// Delete a preference for an app + /// Delete a preference for an app. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [appId] ID of the app + /// * [configKey] Key to delete + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Preference deleted successfully + /// * 400: Preference invalid + /// + /// See: + /// * [deletePreferenceRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> deletePreference({ required final String appId, required final String configKey, @@ -1352,7 +1966,25 @@ class ProvisioningApiPreferencesClient { return rawResponse.future; } - /// Delete a preference for an app + /// Delete a preference for an app. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [appId] ID of the app + /// * [configKey] Key to delete + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Preference deleted successfully + /// * 400: Preference invalid + /// + /// See: + /// * [deletePreference] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse deletePreferenceRaw({ required final String appId, required final String configKey, @@ -1400,7 +2032,22 @@ class ProvisioningApiPreferencesClient { ); } - /// Update multiple preference values of an app + /// Update multiple preference values of an app. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [configs] Key-value pairs of the preferences + /// * [appId] ID of the app + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Preferences updated successfully + /// * 400: Preference invalid + /// + /// See: + /// * [setMultiplePreferencesRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> setMultiplePreferences({ required final ContentString> configs, @@ -1416,7 +2063,25 @@ class ProvisioningApiPreferencesClient { return rawResponse.future; } - /// Update multiple preference values of an app + /// Update multiple preference values of an app. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [configs] Key-value pairs of the preferences + /// * [appId] ID of the app + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Preferences updated successfully + /// * 400: Preference invalid + /// + /// See: + /// * [setMultiplePreferences] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse setMultiplePreferencesRaw({ required final ContentString> configs, @@ -1470,7 +2135,22 @@ class ProvisioningApiPreferencesClient { ); } - /// Delete multiple preferences for an app + /// Delete multiple preferences for an app. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [configKeys] Keys to delete + /// * [appId] ID of the app + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Preferences deleted successfully + /// * 400: Preference invalid + /// + /// See: + /// * [deleteMultiplePreferenceRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> deleteMultiplePreference({ required final List configKeys, @@ -1486,7 +2166,25 @@ class ProvisioningApiPreferencesClient { return rawResponse.future; } - /// Delete multiple preferences for an app + /// Delete multiple preferences for an app. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [configKeys] Keys to delete + /// * [appId] ID of the app + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Preferences deleted successfully + /// * 400: Preference invalid + /// + /// See: + /// * [deleteMultiplePreference] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse deleteMultiplePreferenceRaw({ required final List configKeys, @@ -1541,7 +2239,22 @@ class ProvisioningApiUsersClient { final ProvisioningApiClient _rootClient; - /// Get a list of users + /// Get a list of users. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [search] Text to search for + /// * [limit] Limit the amount of groups returned + /// * [offset] Offset for searching for groups + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Users returned + /// + /// See: + /// * [getUsersRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getUsers({ final String search = '', final int? limit, @@ -1558,7 +2271,25 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Get a list of users + /// Get a list of users. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [search] Text to search for + /// * [limit] Limit the amount of groups returned + /// * [offset] Offset for searching for groups + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Users returned + /// + /// See: + /// * [getUsers] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getUsersRaw({ final String search = '', final int? limit, @@ -1614,7 +2345,29 @@ class ProvisioningApiUsersClient { ); } - /// Create a new user + /// Create a new user. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userid] ID of the user + /// * [password] Password of the user + /// * [displayName] Display name of the user + /// * [email] Email of the user + /// * [groups] Groups of the user + /// * [subadmin] Groups where the user is subadmin + /// * [quota] Quota of the user + /// * [language] Language of the user + /// * [manager] Manager of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User added successfully + /// * 403: Missing permissions to make user subadmin + /// + /// See: + /// * [addUserRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> addUser({ required final String userid, final String password = '', @@ -1643,7 +2396,32 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Create a new user + /// Create a new user. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userid] ID of the user + /// * [password] Password of the user + /// * [displayName] Display name of the user + /// * [email] Email of the user + /// * [groups] Groups of the user + /// * [subadmin] Groups where the user is subadmin + /// * [quota] Quota of the user + /// * [language] Language of the user + /// * [manager] Manager of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User added successfully + /// * 403: Missing permissions to make user subadmin + /// + /// See: + /// * [addUser] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse addUserRaw({ required final String userid, final String password = '', @@ -1721,7 +2499,22 @@ class ProvisioningApiUsersClient { ); } - /// Get a list of users and their details + /// Get a list of users and their details. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [search] Text to search for + /// * [limit] Limit the amount of groups returned + /// * [offset] Offset for searching for groups + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Users details returned + /// + /// See: + /// * [getUsersDetailsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getUsersDetails({ final String search = '', final int? limit, @@ -1738,7 +2531,25 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Get a list of users and their details + /// Get a list of users and their details. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [search] Text to search for + /// * [limit] Limit the amount of groups returned + /// * [offset] Offset for searching for groups + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Users details returned + /// + /// See: + /// * [getUsersDetails] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getUsersDetailsRaw({ final String search = '', final int? limit, @@ -1794,7 +2605,22 @@ class ProvisioningApiUsersClient { ); } - /// Search users by their phone numbers + /// Search users by their phone numbers. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [location] Location of the phone number (for country code) + /// * [search] Phone numbers to search for + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Users returned + /// * 400: Invalid location + /// + /// See: + /// * [searchByPhoneNumbersRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> searchByPhoneNumbers({ required final String location, required final ContentString>> search, @@ -1809,7 +2635,25 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Search users by their phone numbers + /// Search users by their phone numbers. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [location] Location of the phone number (for country code) + /// * [search] Phone numbers to search for + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Users returned + /// * 400: Invalid location + /// + /// See: + /// * [searchByPhoneNumbers] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse searchByPhoneNumbersRaw({ required final String location, required final ContentString>> search, @@ -1865,7 +2709,20 @@ class ProvisioningApiUsersClient { ); } - /// Get the details of a user + /// Get the details of a user. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User returned + /// + /// See: + /// * [getUserRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getUser({ required final String userId, final bool oCSAPIRequest = true, @@ -1878,7 +2735,23 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Get the details of a user + /// Get the details of a user. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User returned + /// + /// See: + /// * [getUser] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getUserRaw({ required final String userId, final bool oCSAPIRequest = true, @@ -1924,7 +2797,22 @@ class ProvisioningApiUsersClient { ); } - /// Update a value of the user's details + /// Update a value of the user's details. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [key] Key that will be updated + /// * [value] New value for the key + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User value edited successfully + /// + /// See: + /// * [editUserRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> editUser({ required final String key, required final String value, @@ -1941,7 +2829,25 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Update a value of the user's details + /// Update a value of the user's details. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [key] Key that will be updated + /// * [value] New value for the key + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User value edited successfully + /// + /// See: + /// * [editUser] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse editUserRaw({ required final String key, required final String value, @@ -1991,7 +2897,20 @@ class ProvisioningApiUsersClient { ); } - /// Delete a user + /// Delete a user. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User deleted successfully + /// + /// See: + /// * [deleteUserRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> deleteUser({ required final String userId, final bool oCSAPIRequest = true, @@ -2004,7 +2923,23 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Delete a user + /// Delete a user. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User deleted successfully + /// + /// See: + /// * [deleteUser] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse deleteUserRaw({ required final String userId, final bool oCSAPIRequest = true, @@ -2050,7 +2985,19 @@ class ProvisioningApiUsersClient { ); } - /// Get the details of the current user + /// Get the details of the current user. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Current user returned + /// + /// See: + /// * [getCurrentUserRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getCurrentUser({ final bool oCSAPIRequest = true, }) async { @@ -2061,7 +3008,22 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Get the details of the current user + /// Get the details of the current user. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Current user returned + /// + /// See: + /// * [getCurrentUser] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getCurrentUserRaw({ final bool oCSAPIRequest = true, }) { @@ -2105,7 +3067,19 @@ class ProvisioningApiUsersClient { ); } - /// Get a list of fields that are editable for the current user + /// Get a list of fields that are editable for the current user. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Editable fields returned + /// + /// See: + /// * [getEditableFieldsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getEditableFields({ final bool oCSAPIRequest = true, }) async { @@ -2116,7 +3090,22 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Get a list of fields that are editable for the current user + /// Get a list of fields that are editable for the current user. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Editable fields returned + /// + /// See: + /// * [getEditableFields] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getEditableFieldsRaw({ final bool oCSAPIRequest = true, }) { @@ -2160,7 +3149,20 @@ class ProvisioningApiUsersClient { ); } - /// Get a list of fields that are editable for a user + /// Get a list of fields that are editable for a user. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Editable fields for user returned + /// + /// See: + /// * [getEditableFieldsForUserRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getEditableFieldsForUser({ required final String userId, @@ -2174,7 +3176,23 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Get a list of fields that are editable for a user + /// Get a list of fields that are editable for a user. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Editable fields for user returned + /// + /// See: + /// * [getEditableFieldsForUser] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getEditableFieldsForUserRaw({ required final String userId, @@ -2221,7 +3239,23 @@ class ProvisioningApiUsersClient { ); } - /// Update multiple values of the user's details + /// Update multiple values of the user's details. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [key] Key that will be updated + /// * [value] New value for the key + /// * [userId] ID of the user + /// * [collectionName] Collection to update + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User values edited successfully + /// + /// See: + /// * [editUserMultiValueRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> editUserMultiValue({ required final String key, required final String value, @@ -2240,7 +3274,26 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Update multiple values of the user's details + /// Update multiple values of the user's details. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [key] Key that will be updated + /// * [value] New value for the key + /// * [userId] ID of the user + /// * [collectionName] Collection to update + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User values edited successfully + /// + /// See: + /// * [editUserMultiValue] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse editUserMultiValueRaw({ required final String key, required final String value, @@ -2297,7 +3350,20 @@ class ProvisioningApiUsersClient { ); } - /// Wipe all devices of a user + /// Wipe all devices of a user. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Wiped all user devices successfully + /// + /// See: + /// * [wipeUserDevicesRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> wipeUserDevices({ required final String userId, final bool oCSAPIRequest = true, @@ -2310,7 +3376,23 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Wipe all devices of a user + /// Wipe all devices of a user. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Wiped all user devices successfully + /// + /// See: + /// * [wipeUserDevices] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse wipeUserDevicesRaw({ required final String userId, final bool oCSAPIRequest = true, @@ -2356,7 +3438,20 @@ class ProvisioningApiUsersClient { ); } - /// Enable a user + /// Enable a user. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User enabled successfully + /// + /// See: + /// * [enableUserRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> enableUser({ required final String userId, final bool oCSAPIRequest = true, @@ -2369,7 +3464,23 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Enable a user + /// Enable a user. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User enabled successfully + /// + /// See: + /// * [enableUser] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse enableUserRaw({ required final String userId, final bool oCSAPIRequest = true, @@ -2415,7 +3526,20 @@ class ProvisioningApiUsersClient { ); } - /// Disable a user + /// Disable a user. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User disabled successfully + /// + /// See: + /// * [disableUserRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> disableUser({ required final String userId, final bool oCSAPIRequest = true, @@ -2428,7 +3552,23 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Disable a user + /// Disable a user. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User disabled successfully + /// + /// See: + /// * [disableUser] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse disableUserRaw({ required final String userId, final bool oCSAPIRequest = true, @@ -2474,7 +3614,20 @@ class ProvisioningApiUsersClient { ); } - /// Get a list of groups the user belongs to + /// Get a list of groups the user belongs to. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Users groups returned + /// + /// See: + /// * [getUsersGroupsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getUsersGroups({ required final String userId, final bool oCSAPIRequest = true, @@ -2487,7 +3640,23 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Get a list of groups the user belongs to + /// Get a list of groups the user belongs to. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Users groups returned + /// + /// See: + /// * [getUsersGroups] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getUsersGroupsRaw({ required final String userId, final bool oCSAPIRequest = true, @@ -2533,7 +3702,21 @@ class ProvisioningApiUsersClient { ); } - /// Add a user to a group + /// Add a user to a group. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [groupid] ID of the group + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User added to group successfully + /// + /// See: + /// * [addToGroupRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> addToGroup({ required final String userId, final String groupid = '', @@ -2548,7 +3731,24 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Add a user to a group + /// Add a user to a group. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [groupid] ID of the group + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User added to group successfully + /// + /// See: + /// * [addToGroup] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse addToGroupRaw({ required final String userId, final String groupid = '', @@ -2598,7 +3798,21 @@ class ProvisioningApiUsersClient { ); } - /// Remove a user from a group + /// Remove a user from a group. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [groupid] ID of the group + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User removed from group successfully + /// + /// See: + /// * [removeFromGroupRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> removeFromGroup({ required final String groupid, required final String userId, @@ -2613,7 +3827,24 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Remove a user from a group + /// Remove a user from a group. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [groupid] ID of the group + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User removed from group successfully + /// + /// See: + /// * [removeFromGroup] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse removeFromGroupRaw({ required final String groupid, required final String userId, @@ -2661,9 +3892,22 @@ class ProvisioningApiUsersClient { ); } - /// Get the groups a user is a subadmin of + /// Get the groups a user is a subadmin of. /// - /// This endpoint requires admin access + /// This endpoint requires admin access. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID if the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User subadmin groups returned + /// + /// See: + /// * [getUserSubAdminGroupsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getUserSubAdminGroups({ required final String userId, @@ -2677,9 +3921,25 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Get the groups a user is a subadmin of + /// Get the groups a user is a subadmin of. + /// + /// This endpoint requires admin access. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. /// - /// This endpoint requires admin access + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID if the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User subadmin groups returned + /// + /// See: + /// * [getUserSubAdminGroups] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getUserSubAdminGroupsRaw({ required final String userId, final bool oCSAPIRequest = true, @@ -2725,9 +3985,23 @@ class ProvisioningApiUsersClient { ); } - /// Make a user a subadmin of a group + /// Make a user a subadmin of a group. + /// + /// This endpoint requires admin access. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [groupid] ID of the group + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass /// - /// This endpoint requires admin access + /// Status codes: + /// * 200: User added as group subadmin successfully + /// + /// See: + /// * [addSubAdminRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> addSubAdmin({ required final String groupid, required final String userId, @@ -2742,9 +4016,26 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Make a user a subadmin of a group + /// Make a user a subadmin of a group. + /// + /// This endpoint requires admin access. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [groupid] ID of the group + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User added as group subadmin successfully /// - /// This endpoint requires admin access + /// See: + /// * [addSubAdmin] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse addSubAdminRaw({ required final String groupid, required final String userId, @@ -2792,9 +4083,23 @@ class ProvisioningApiUsersClient { ); } - /// Remove a user from the subadmins of a group + /// Remove a user from the subadmins of a group. /// - /// This endpoint requires admin access + /// This endpoint requires admin access. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [groupid] ID of the group + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User removed as group subadmin successfully + /// + /// See: + /// * [removeSubAdminRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> removeSubAdmin({ required final String groupid, required final String userId, @@ -2809,9 +4114,26 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Remove a user from the subadmins of a group + /// Remove a user from the subadmins of a group. + /// + /// This endpoint requires admin access. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. /// - /// This endpoint requires admin access + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [groupid] ID of the group + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: User removed as group subadmin successfully + /// + /// See: + /// * [removeSubAdmin] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse removeSubAdminRaw({ required final String groupid, required final String userId, @@ -2859,7 +4181,20 @@ class ProvisioningApiUsersClient { ); } - /// Resend the welcome message + /// Resend the welcome message. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID if the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Resent welcome message successfully + /// + /// See: + /// * [resendWelcomeMessageRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> resendWelcomeMessage({ required final String userId, final bool oCSAPIRequest = true, @@ -2872,7 +4207,23 @@ class ProvisioningApiUsersClient { return rawResponse.future; } - /// Resend the welcome message + /// Resend the welcome message. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID if the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Resent welcome message successfully + /// + /// See: + /// * [resendWelcomeMessage] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse resendWelcomeMessageRaw({ required final String userId, final bool oCSAPIRequest = true, diff --git a/packages/nextcloud/lib/src/api/settings.openapi.dart b/packages/nextcloud/lib/src/api/settings.openapi.dart index 00389a9d..848a2571 100644 --- a/packages/nextcloud/lib/src/api/settings.openapi.dart +++ b/packages/nextcloud/lib/src/api/settings.openapi.dart @@ -10,6 +10,8 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -42,18 +44,39 @@ class SettingsLogSettingsClient { final SettingsClient _rootClient; - /// download logfile + /// download logfile. /// - /// This endpoint requires admin access + /// This endpoint requires admin access. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200: Logfile returned + /// + /// See: + /// * [downloadRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> download() async { final rawResponse = downloadRaw(); return rawResponse.future; } - /// download logfile + /// download logfile. + /// + /// This endpoint requires admin access. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200: Logfile returned /// - /// This endpoint requires admin access + /// See: + /// * [download] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse downloadRaw() { const path = '/index.php/settings/admin/log/download'; final queryParameters = {}; diff --git a/packages/nextcloud/lib/src/api/theming.openapi.dart b/packages/nextcloud/lib/src/api/theming.openapi.dart index 2ce57726..4f47de33 100644 --- a/packages/nextcloud/lib/src/api/theming.openapi.dart +++ b/packages/nextcloud/lib/src/api/theming.openapi.dart @@ -13,6 +13,8 @@ import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:dynamite_runtime/utils.dart'; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -49,7 +51,21 @@ class ThemingIconClient { final ThemingClient _rootClient; - /// Return a 32x32 favicon as png + /// Return a 32x32 favicon as png. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [app] ID of the app + /// + /// Status codes: + /// * 200: Favicon returned + /// * 404: Favicon not found + /// * 500 + /// + /// See: + /// * [getFaviconRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getFavicon({final String app = 'core'}) async { final rawResponse = getFaviconRaw( app: app, @@ -58,7 +74,24 @@ class ThemingIconClient { return rawResponse.future; } - /// Return a 32x32 favicon as png + /// Return a 32x32 favicon as png. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [app] ID of the app + /// + /// Status codes: + /// * 200: Favicon returned + /// * 404: Favicon not found + /// * 500 + /// + /// See: + /// * [getFavicon] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getFaviconRaw({final String app = 'core'}) { var path = '/index.php/apps/theming/favicon/{app}'; final queryParameters = {}; @@ -98,7 +131,21 @@ class ThemingIconClient { ); } - /// Return a 512x512 icon for touch devices + /// Return a 512x512 icon for touch devices. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [app] ID of the app + /// + /// Status codes: + /// * 200: Touch icon returned + /// * 404: Touch icon not found + /// * 500 + /// + /// See: + /// * [getTouchIconRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getTouchIcon({final String app = 'core'}) async { final rawResponse = getTouchIconRaw( app: app, @@ -107,7 +154,24 @@ class ThemingIconClient { return rawResponse.future; } - /// Return a 512x512 icon for touch devices + /// Return a 512x512 icon for touch devices. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [app] ID of the app + /// + /// Status codes: + /// * 200: Touch icon returned + /// * 404: Touch icon not found + /// * 500 + /// + /// See: + /// * [getTouchIcon] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getTouchIconRaw({final String app = 'core'}) { var path = '/index.php/apps/theming/icon/{app}'; final queryParameters = {}; @@ -147,7 +211,22 @@ class ThemingIconClient { ); } - /// Get a themed icon + /// Get a themed icon. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [app] ID of the app + /// * [image] image file name (svg required) + /// + /// Status codes: + /// * 200: Themed icon returned + /// * 404: Themed icon not found + /// * 500 + /// + /// See: + /// * [getThemedIconRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getThemedIcon({ required final String app, required final String image, @@ -160,7 +239,25 @@ class ThemingIconClient { return rawResponse.future; } - /// Get a themed icon + /// Get a themed icon. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [app] ID of the app + /// * [image] image file name (svg required) + /// + /// Status codes: + /// * 200: Themed icon returned + /// * 404: Themed icon not found + /// * 500 + /// + /// See: + /// * [getThemedIcon] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getThemedIconRaw({ required final String app, required final String image, @@ -206,14 +303,29 @@ class ThemingIconClient { } } -/// Class ThemingController -/// handle ajax requests to update the theme +/// Class ThemingController. +/// handle ajax requests to update the theme. class ThemingThemingClient { ThemingThemingClient(this._rootClient); final ThemingClient _rootClient; - /// Get the CSS stylesheet for a theme + /// Get the CSS stylesheet for a theme. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [plain] Let the browser decide the CSS priority + /// * [withCustomCss] Include custom CSS + /// * [themeId] ID of the theme + /// + /// Status codes: + /// * 200: Stylesheet returned + /// * 404: Theme not found + /// + /// See: + /// * [getThemeStylesheetRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getThemeStylesheet({ required final String themeId, final int plain = 0, @@ -228,7 +340,25 @@ class ThemingThemingClient { return rawResponse.future; } - /// Get the CSS stylesheet for a theme + /// Get the CSS stylesheet for a theme. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [plain] Let the browser decide the CSS priority + /// * [withCustomCss] Include custom CSS + /// * [themeId] ID of the theme + /// + /// Status codes: + /// * 200: Stylesheet returned + /// * 404: Theme not found + /// + /// See: + /// * [getThemeStylesheet] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getThemeStylesheetRaw({ required final String themeId, final int plain = 0, @@ -278,7 +408,22 @@ class ThemingThemingClient { ); } - /// Get an image + /// Get an image. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [useSvg] Return image as SVG + /// * [key] Key of the image + /// + /// Status codes: + /// * 200: Image returned + /// * 404: Image not found + /// * 500 + /// + /// See: + /// * [getImageRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getImage({ required final String key, final int useSvg = 1, @@ -291,7 +436,25 @@ class ThemingThemingClient { return rawResponse.future; } - /// Get an image + /// Get an image. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [useSvg] Return image as SVG + /// * [key] Key of the image + /// + /// Status codes: + /// * 200: Image returned + /// * 404: Image not found + /// * 500 + /// + /// See: + /// * [getImage] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getImageRaw({ required final String key, final int useSvg = 1, @@ -337,7 +500,19 @@ class ThemingThemingClient { ); } - /// Get the manifest for an app + /// Get the manifest for an app. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [app] ID of the app + /// + /// Status codes: + /// * 200: Manifest returned + /// + /// See: + /// * [getManifestRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getManifest({ required final String app, }) async { @@ -348,7 +523,22 @@ class ThemingThemingClient { return rawResponse.future; } - /// Get the manifest for an app + /// Get the manifest for an app. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [app] ID of the app + /// + /// Status codes: + /// * 200: Manifest returned + /// + /// See: + /// * [getManifest] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getManifestRaw({ required final String app, }) { @@ -396,7 +586,20 @@ class ThemingUserThemeClient { final ThemingClient _rootClient; - /// Get the background image + /// Get the background image. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Background image returned + /// * 404: Background image not found + /// + /// See: + /// * [getBackgroundRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getBackground({final bool oCSAPIRequest = true}) async { final rawResponse = getBackgroundRaw( oCSAPIRequest: oCSAPIRequest, @@ -405,7 +608,23 @@ class ThemingUserThemeClient { return rawResponse.future; } - /// Get the background image + /// Get the background image. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Background image returned + /// * 404: Background image not found + /// + /// See: + /// * [getBackground] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getBackgroundRaw({final bool oCSAPIRequest = true}) { const path = '/index.php/apps/theming/background'; final queryParameters = {}; @@ -447,7 +666,24 @@ class ThemingUserThemeClient { ); } - /// Set the background + /// Set the background. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [value] Path of the background image + /// * [color] Color for the background + /// * [type] Type of background + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Background set successfully + /// * 400: Setting background is not possible + /// * 500 + /// + /// See: + /// * [setBackgroundRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> setBackground({ required final String type, final String value = '', @@ -464,7 +700,27 @@ class ThemingUserThemeClient { return rawResponse.future; } - /// Set the background + /// Set the background. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [value] Path of the background image + /// * [color] Color for the background + /// * [type] Type of background + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Background set successfully + /// * 400: Setting background is not possible + /// * 500 + /// + /// See: + /// * [setBackground] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse setBackgroundRaw({ required final String type, final String value = '', @@ -518,7 +774,19 @@ class ThemingUserThemeClient { ); } - /// Delete the background + /// Delete the background. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Background deleted successfully + /// + /// See: + /// * [deleteBackgroundRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> deleteBackground({final bool oCSAPIRequest = true}) async { final rawResponse = deleteBackgroundRaw( oCSAPIRequest: oCSAPIRequest, @@ -527,7 +795,22 @@ class ThemingUserThemeClient { return rawResponse.future; } - /// Delete the background + /// Delete the background. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Background deleted successfully + /// + /// See: + /// * [deleteBackground] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse deleteBackgroundRaw({final bool oCSAPIRequest = true}) { const path = '/index.php/apps/theming/background/custom'; final queryParameters = {}; @@ -569,7 +852,22 @@ class ThemingUserThemeClient { ); } - /// Enable theme + /// Enable theme. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [themeId] the theme ID + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Theme enabled successfully + /// * 400: Enabling theme is not possible + /// * 500 + /// + /// See: + /// * [enableThemeRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> enableTheme({ required final String themeId, final bool oCSAPIRequest = true, @@ -582,7 +880,25 @@ class ThemingUserThemeClient { return rawResponse.future; } - /// Enable theme + /// Enable theme. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [themeId] the theme ID + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Theme enabled successfully + /// * 400: Enabling theme is not possible + /// * 500 + /// + /// See: + /// * [enableTheme] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse enableThemeRaw({ required final String themeId, final bool oCSAPIRequest = true, @@ -628,7 +944,22 @@ class ThemingUserThemeClient { ); } - /// Disable theme + /// Disable theme. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [themeId] the theme ID + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Theme disabled successfully + /// * 400: Disabling theme is not possible + /// * 500 + /// + /// See: + /// * [disableThemeRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> disableTheme({ required final String themeId, final bool oCSAPIRequest = true, @@ -641,7 +972,25 @@ class ThemingUserThemeClient { return rawResponse.future; } - /// Disable theme + /// Disable theme. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [themeId] the theme ID + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Theme disabled successfully + /// * 400: Disabling theme is not possible + /// * 500 + /// + /// See: + /// * [disableTheme] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse disableThemeRaw({ required final String themeId, final bool oCSAPIRequest = true, diff --git a/packages/nextcloud/lib/src/api/updatenotification.openapi.dart b/packages/nextcloud/lib/src/api/updatenotification.openapi.dart index 52e28318..7c641d6d 100644 --- a/packages/nextcloud/lib/src/api/updatenotification.openapi.dart +++ b/packages/nextcloud/lib/src/api/updatenotification.openapi.dart @@ -11,6 +11,8 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -43,9 +45,24 @@ class UpdatenotificationApiClient { final UpdatenotificationClient _rootClient; - /// List available updates for apps + /// List available updates for apps. /// - /// This endpoint requires admin access + /// This endpoint requires admin access. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [apiVersion] + /// * [newVersion] Server version to check updates for + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Apps returned + /// * 404: New versions not found + /// + /// See: + /// * [getAppListRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getAppList({ required final String newVersion, final UpdatenotificationApiGetAppListApiVersion apiVersion = UpdatenotificationApiGetAppListApiVersion.v1, @@ -60,9 +77,27 @@ class UpdatenotificationApiClient { return rawResponse.future; } - /// List available updates for apps + /// List available updates for apps. + /// + /// This endpoint requires admin access. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [apiVersion] + /// * [newVersion] Server version to check updates for + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Apps returned + /// * 404: New versions not found /// - /// This endpoint requires admin access + /// See: + /// * [getAppList] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getAppListRaw({ required final String newVersion, final UpdatenotificationApiGetAppListApiVersion apiVersion = UpdatenotificationApiGetAppListApiVersion.v1, diff --git a/packages/nextcloud/lib/src/api/uppush.openapi.dart b/packages/nextcloud/lib/src/api/uppush.openapi.dart index 55976672..43468095 100644 --- a/packages/nextcloud/lib/src/api/uppush.openapi.dart +++ b/packages/nextcloud/lib/src/api/uppush.openapi.dart @@ -11,6 +11,8 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -35,14 +37,35 @@ class UppushClient extends DynamiteClient { authentications: client.authentications, ); - /// Check if the UnifiedPush provider is present + /// Check if the UnifiedPush provider is present. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [checkRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> check() async { final rawResponse = checkRaw(); return rawResponse.future; } - /// Check if the UnifiedPush provider is present + /// Check if the UnifiedPush provider is present. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [check] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse checkRaw() { const path = '/index.php/apps/uppush'; final queryParameters = {}; @@ -83,9 +106,21 @@ class UppushClient extends DynamiteClient { ); } - /// Set keepalive interval + /// Set keepalive interval. + /// + /// This endpoint requires admin access. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [keepalive] Keep alive value in seconds + /// + /// Status codes: + /// * 200 /// - /// This endpoint requires admin access + /// See: + /// * [setKeepaliveRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> setKeepalive({ required final int keepalive, }) async { @@ -96,9 +131,24 @@ class UppushClient extends DynamiteClient { return rawResponse.future; } - /// Set keepalive interval + /// Set keepalive interval. /// - /// This endpoint requires admin access + /// This endpoint requires admin access. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [keepalive] Keep alive value in seconds + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [setKeepalive] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse setKeepaliveRaw({required final int keepalive}) { const path = '/index.php/apps/uppush/keepalive'; final queryParameters = {}; @@ -140,7 +190,19 @@ class UppushClient extends DynamiteClient { ); } - /// Request to create a new deviceId + /// Request to create a new deviceId. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [deviceName] Name of the device + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [createDeviceRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> createDevice({ required final String deviceName, }) async { @@ -151,7 +213,22 @@ class UppushClient extends DynamiteClient { return rawResponse.future; } - /// Request to create a new deviceId + /// Request to create a new deviceId. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [deviceName] Name of the device + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [createDevice] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse createDeviceRaw({ required final String deviceName, }) { @@ -195,9 +272,18 @@ class UppushClient extends DynamiteClient { ); } - /// Request to get push messages + /// Request to get push messages. + /// + /// This is a public page since it has to be handle by the non-connected app (NextPush app and not Nextcloud-app). + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// - /// This is a public page since it has to be handle by the non-connected app (NextPush app and not Nextcloud-app) + /// Status codes: + /// * 401: Missing permissions to sync device + /// + /// See: + /// * [syncDeviceRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> syncDevice({ required final String deviceId, }) async { @@ -208,9 +294,21 @@ class UppushClient extends DynamiteClient { return rawResponse.future; } - /// Request to get push messages + /// Request to get push messages. + /// + /// This is a public page since it has to be handle by the non-connected app (NextPush app and not Nextcloud-app). + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 401: Missing permissions to sync device /// - /// This is a public page since it has to be handle by the non-connected app (NextPush app and not Nextcloud-app) + /// See: + /// * [syncDevice] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse syncDeviceRaw({required final String deviceId}) { var path = '/index.php/apps/uppush/device/{deviceId}'; final queryParameters = {}; @@ -252,7 +350,16 @@ class UppushClient extends DynamiteClient { ); } - /// Delete a device + /// Delete a device. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200: Device deleted successfully + /// + /// See: + /// * [deleteDeviceRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> deleteDevice({ required final String deviceId, }) async { @@ -263,7 +370,19 @@ class UppushClient extends DynamiteClient { return rawResponse.future; } - /// Delete a device + /// Delete a device. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200: Device deleted successfully + /// + /// See: + /// * [deleteDevice] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse deleteDeviceRaw({ required final String deviceId, }) { @@ -307,7 +426,20 @@ class UppushClient extends DynamiteClient { ); } - /// Create an authorization token for a new 3rd party service + /// Create an authorization token for a new 3rd party service. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [deviceId] ID of the device + /// * [appName] Name of the app + /// + /// Status codes: + /// * 200: App created successfully + /// + /// See: + /// * [createAppRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> createApp({ required final String deviceId, required final String appName, @@ -320,7 +452,23 @@ class UppushClient extends DynamiteClient { return rawResponse.future; } - /// Create an authorization token for a new 3rd party service + /// Create an authorization token for a new 3rd party service. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [deviceId] ID of the device + /// * [appName] Name of the app + /// + /// Status codes: + /// * 200: App created successfully + /// + /// See: + /// * [createApp] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse createAppRaw({ required final String deviceId, required final String appName, @@ -366,7 +514,16 @@ class UppushClient extends DynamiteClient { ); } - /// Delete an authorization token + /// Delete an authorization token. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200: App deleted successfully + /// + /// See: + /// * [deleteAppRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> deleteApp({ required final String token, }) async { @@ -377,7 +534,19 @@ class UppushClient extends DynamiteClient { return rawResponse.future; } - /// Delete an authorization token + /// Delete an authorization token. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200: App deleted successfully + /// + /// See: + /// * [deleteApp] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse deleteAppRaw({required final String token}) { var path = '/index.php/apps/uppush/app/{token}'; final queryParameters = {}; @@ -419,7 +588,16 @@ class UppushClient extends DynamiteClient { ); } - /// Unifiedpush discovery Following specifications + /// Unifiedpush discovery Following specifications. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [unifiedpushDiscoveryRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> unifiedpushDiscovery({ required final String token, }) async { @@ -430,7 +608,19 @@ class UppushClient extends DynamiteClient { return rawResponse.future; } - /// Unifiedpush discovery Following specifications + /// Unifiedpush discovery Following specifications. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [unifiedpushDiscovery] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse unifiedpushDiscoveryRaw({ required final String token, }) { @@ -474,7 +664,16 @@ class UppushClient extends DynamiteClient { ); } - /// Receive notifications from 3rd parties + /// Receive notifications from 3rd parties. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 201: Notification pushed successfully + /// + /// See: + /// * [pushRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> push({required final String token}) async { final rawResponse = pushRaw( token: token, @@ -483,7 +682,19 @@ class UppushClient extends DynamiteClient { return rawResponse.future; } - /// Receive notifications from 3rd parties + /// Receive notifications from 3rd parties. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 201: Notification pushed successfully + /// + /// See: + /// * [push] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse pushRaw({required final String token}) { var path = '/index.php/apps/uppush/push/{token}'; final queryParameters = {}; @@ -525,14 +736,35 @@ class UppushClient extends DynamiteClient { ); } - /// Matrix Gateway discovery + /// Matrix Gateway discovery. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [gatewayMatrixDiscoveryRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> gatewayMatrixDiscovery() async { final rawResponse = gatewayMatrixDiscoveryRaw(); return rawResponse.future; } - /// Matrix Gateway discovery + /// Matrix Gateway discovery. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [gatewayMatrixDiscovery] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse gatewayMatrixDiscoveryRaw() { const path = '/index.php/apps/uppush/gateway/matrix'; final queryParameters = {}; @@ -573,14 +805,35 @@ class UppushClient extends DynamiteClient { ); } - /// Matrix Gateway + /// Matrix Gateway. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [gatewayMatrixRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> gatewayMatrix() async { final rawResponse = gatewayMatrixRaw(); return rawResponse.future; } - /// Matrix Gateway + /// Matrix Gateway. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Status codes: + /// * 200 + /// + /// See: + /// * [gatewayMatrix] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse gatewayMatrixRaw() { const path = '/index.php/apps/uppush/gateway/matrix'; final queryParameters = {}; diff --git a/packages/nextcloud/lib/src/api/user_status.openapi.dart b/packages/nextcloud/lib/src/api/user_status.openapi.dart index 2c56063c..1a54c0f2 100644 --- a/packages/nextcloud/lib/src/api/user_status.openapi.dart +++ b/packages/nextcloud/lib/src/api/user_status.openapi.dart @@ -12,6 +12,8 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -50,7 +52,23 @@ class UserStatusHeartbeatClient { final UserStatusClient _rootClient; - /// Keep the status alive + /// Keep the status alive. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [status] Only online, away + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Status successfully updated + /// * 400: Invalid status to update + /// * 500 + /// * 204: User has no status to keep alive + /// + /// See: + /// * [heartbeatRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> heartbeat({ required final String status, final bool oCSAPIRequest = true, @@ -63,7 +81,26 @@ class UserStatusHeartbeatClient { return rawResponse.future; } - /// Keep the status alive + /// Keep the status alive. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [status] Only online, away + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Status successfully updated + /// * 400: Invalid status to update + /// * 500 + /// * 204: User has no status to keep alive + /// + /// See: + /// * [heartbeat] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse heartbeatRaw({ required final String status, final bool oCSAPIRequest = true, @@ -115,7 +152,19 @@ class UserStatusPredefinedStatusClient { final UserStatusClient _rootClient; - /// Get all predefined messages + /// Get all predefined messages. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Predefined statuses returned + /// + /// See: + /// * [findAllRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> findAll({ final bool oCSAPIRequest = true, }) async { @@ -126,7 +175,22 @@ class UserStatusPredefinedStatusClient { return rawResponse.future; } - /// Get all predefined messages + /// Get all predefined messages. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Predefined statuses returned + /// + /// See: + /// * [findAll] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse findAllRaw({ final bool oCSAPIRequest = true, }) { @@ -176,7 +240,21 @@ class UserStatusStatusesClient { final UserStatusClient _rootClient; - /// Find statuses of users + /// Find statuses of users. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [limit] Maximum number of statuses to find + /// * [offset] Offset for finding statuses + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Statuses returned + /// + /// See: + /// * [findAllRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> findAll({ final int? limit, final int? offset, @@ -191,7 +269,24 @@ class UserStatusStatusesClient { return rawResponse.future; } - /// Find statuses of users + /// Find statuses of users. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [limit] Maximum number of statuses to find + /// * [offset] Offset for finding statuses + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Statuses returned + /// + /// See: + /// * [findAll] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse findAllRaw({ final int? limit, final int? offset, @@ -243,7 +338,21 @@ class UserStatusStatusesClient { ); } - /// Find the status of a user + /// Find the status of a user. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Status returned + /// * 404: The user was not found + /// + /// See: + /// * [findRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> find({ required final String userId, final bool oCSAPIRequest = true, @@ -256,7 +365,24 @@ class UserStatusStatusesClient { return rawResponse.future; } - /// Find the status of a user + /// Find the status of a user. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [userId] ID of the user + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Status returned + /// * 404: The user was not found + /// + /// See: + /// * [find] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse findRaw({ required final String userId, final bool oCSAPIRequest = true, @@ -308,7 +434,20 @@ class UserStatusUserStatusClient { final UserStatusClient _rootClient; - /// Get the status of the current user + /// Get the status of the current user. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: The status was found successfully + /// * 404: The user was not found + /// + /// See: + /// * [getStatusRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getStatus({ final bool oCSAPIRequest = true, }) async { @@ -319,7 +458,23 @@ class UserStatusUserStatusClient { return rawResponse.future; } - /// Get the status of the current user + /// Get the status of the current user. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: The status was found successfully + /// * 404: The user was not found + /// + /// See: + /// * [getStatus] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getStatusRaw({ final bool oCSAPIRequest = true, }) { @@ -363,7 +518,21 @@ class UserStatusUserStatusClient { ); } - /// Update the status type of the current user + /// Update the status type of the current user. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [statusType] The new status type + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: The status was updated successfully + /// * 400: The status type is invalid + /// + /// See: + /// * [setStatusRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> setStatus({ required final String statusType, final bool oCSAPIRequest = true, @@ -376,7 +545,24 @@ class UserStatusUserStatusClient { return rawResponse.future; } - /// Update the status type of the current user + /// Update the status type of the current user. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [statusType] The new status type + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: The status was updated successfully + /// * 400: The status type is invalid + /// + /// See: + /// * [setStatus] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse setStatusRaw({ required final String statusType, final bool oCSAPIRequest = true, @@ -422,7 +608,22 @@ class UserStatusUserStatusClient { ); } - /// Set the message to a predefined message for the current user + /// Set the message to a predefined message for the current user. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [messageId] ID of the predefined message + /// * [clearAt] When the message should be cleared + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: The message was updated successfully + /// * 400: The clearAt or message-id is invalid + /// + /// See: + /// * [setPredefinedMessageRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> setPredefinedMessage({ required final String messageId, final int? clearAt, @@ -437,7 +638,25 @@ class UserStatusUserStatusClient { return rawResponse.future; } - /// Set the message to a predefined message for the current user + /// Set the message to a predefined message for the current user. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [messageId] ID of the predefined message + /// * [clearAt] When the message should be cleared + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: The message was updated successfully + /// * 400: The clearAt or message-id is invalid + /// + /// See: + /// * [setPredefinedMessage] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse setPredefinedMessageRaw({ required final String messageId, final int? clearAt, @@ -487,7 +706,23 @@ class UserStatusUserStatusClient { ); } - /// Set the message to a custom message for the current user + /// Set the message to a custom message for the current user. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [statusIcon] Icon of the status + /// * [message] Message of the status + /// * [clearAt] When the message should be cleared + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: The message was updated successfully + /// * 400: The clearAt or icon is invalid or the message is too long + /// + /// See: + /// * [setCustomMessageRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> setCustomMessage({ final String? statusIcon, final String? message, @@ -504,7 +739,26 @@ class UserStatusUserStatusClient { return rawResponse.future; } - /// Set the message to a custom message for the current user + /// Set the message to a custom message for the current user. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [statusIcon] Icon of the status + /// * [message] Message of the status + /// * [clearAt] When the message should be cleared + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: The message was updated successfully + /// * 400: The clearAt or icon is invalid or the message is too long + /// + /// See: + /// * [setCustomMessage] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse setCustomMessageRaw({ final String? statusIcon, final String? message, @@ -560,7 +814,19 @@ class UserStatusUserStatusClient { ); } - /// Clear the message of the current user + /// Clear the message of the current user. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Message cleared successfully + /// + /// See: + /// * [clearMessageRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> clearMessage({ final bool oCSAPIRequest = true, }) async { @@ -571,7 +837,22 @@ class UserStatusUserStatusClient { return rawResponse.future; } - /// Clear the message of the current user + /// Clear the message of the current user. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Message cleared successfully + /// + /// See: + /// * [clearMessage] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse clearMessageRaw({ final bool oCSAPIRequest = true, }) { @@ -615,7 +896,20 @@ class UserStatusUserStatusClient { ); } - /// Revert the status to the previous status + /// Revert the status to the previous status. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [messageId] ID of the message to delete + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Status reverted + /// + /// See: + /// * [revertStatusRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> revertStatus({ required final String messageId, final bool oCSAPIRequest = true, @@ -628,7 +922,23 @@ class UserStatusUserStatusClient { return rawResponse.future; } - /// Revert the status to the previous status + /// Revert the status to the previous status. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [messageId] ID of the message to delete + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Status reverted + /// + /// See: + /// * [revertStatus] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse revertStatusRaw({ required final String messageId, final bool oCSAPIRequest = true, diff --git a/packages/nextcloud/lib/src/api/weather_status.openapi.dart b/packages/nextcloud/lib/src/api/weather_status.openapi.dart index a01f6a5b..f884a2b0 100644 --- a/packages/nextcloud/lib/src/api/weather_status.openapi.dart +++ b/packages/nextcloud/lib/src/api/weather_status.openapi.dart @@ -11,6 +11,8 @@ import 'package:built_value/standard_json_plugin.dart'; import 'package:collection/collection.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; +import 'package:meta/meta.dart'; +import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; @@ -43,7 +45,20 @@ class WeatherStatusWeatherStatusClient { final WeatherStatusClient _rootClient; - /// Change the weather status mode. There are currently 2 modes: - ask the browser - use the user defined address + /// Change the weather status mode. There are currently 2 modes: - ask the browser - use the user defined address. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [mode] New mode + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Weather status mode updated + /// + /// See: + /// * [setModeRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> setMode({ required final int mode, final bool oCSAPIRequest = true, @@ -56,7 +71,23 @@ class WeatherStatusWeatherStatusClient { return rawResponse.future; } - /// Change the weather status mode. There are currently 2 modes: - ask the browser - use the user defined address + /// Change the weather status mode. There are currently 2 modes: - ask the browser - use the user defined address. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [mode] New mode + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Weather status mode updated + /// + /// See: + /// * [setMode] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse setModeRaw({ required final int mode, final bool oCSAPIRequest = true, @@ -102,7 +133,19 @@ class WeatherStatusWeatherStatusClient { ); } - /// Try to use the address set in user personal settings as weather location + /// Try to use the address set in user personal settings as weather location. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Address updated + /// + /// See: + /// * [usePersonalAddressRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> usePersonalAddress({final bool oCSAPIRequest = true}) async { final rawResponse = usePersonalAddressRaw( @@ -112,7 +155,22 @@ class WeatherStatusWeatherStatusClient { return rawResponse.future; } - /// Try to use the address set in user personal settings as weather location + /// Try to use the address set in user personal settings as weather location. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Address updated + /// + /// See: + /// * [usePersonalAddress] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse usePersonalAddressRaw({ final bool oCSAPIRequest = true, }) { @@ -156,7 +214,19 @@ class WeatherStatusWeatherStatusClient { ); } - /// Get stored user location + /// Get stored user location. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Location returned + /// + /// See: + /// * [getLocationRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getLocation({ final bool oCSAPIRequest = true, }) async { @@ -167,7 +237,22 @@ class WeatherStatusWeatherStatusClient { return rawResponse.future; } - /// Get stored user location + /// Get stored user location. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Location returned + /// + /// See: + /// * [getLocation] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getLocationRaw({ final bool oCSAPIRequest = true, }) { @@ -211,7 +296,22 @@ class WeatherStatusWeatherStatusClient { ); } - /// Set address and resolve it to get coordinates or directly set coordinates and get address with reverse geocoding + /// Set address and resolve it to get coordinates or directly set coordinates and get address with reverse geocoding. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [address] Any approximative or exact address + /// * [lat] Latitude in decimal degree format + /// * [lon] Longitude in decimal degree format + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Location updated + /// + /// See: + /// * [setLocationRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> setLocation({ final String? address, final num? lat, @@ -228,7 +328,25 @@ class WeatherStatusWeatherStatusClient { return rawResponse.future; } - /// Set address and resolve it to get coordinates or directly set coordinates and get address with reverse geocoding + /// Set address and resolve it to get coordinates or directly set coordinates and get address with reverse geocoding. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [address] Any approximative or exact address + /// * [lat] Latitude in decimal degree format + /// * [lon] Longitude in decimal degree format + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Location updated + /// + /// See: + /// * [setLocation] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse setLocationRaw({ final String? address, final num? lat, @@ -284,7 +402,20 @@ class WeatherStatusWeatherStatusClient { ); } - /// Get forecast for current location + /// Get forecast for current location. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Forecast returned + /// * 404: Forecast not found + /// + /// See: + /// * [getForecastRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getForecast({ final bool oCSAPIRequest = true, }) async { @@ -295,7 +426,23 @@ class WeatherStatusWeatherStatusClient { return rawResponse.future; } - /// Get forecast for current location + /// Get forecast for current location. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Forecast returned + /// * 404: Forecast not found + /// + /// See: + /// * [getForecast] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getForecastRaw({ final bool oCSAPIRequest = true, }) { @@ -339,7 +486,19 @@ class WeatherStatusWeatherStatusClient { ); } - /// Get favorites list + /// Get favorites list. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Favorites returned + /// + /// See: + /// * [getFavoritesRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getFavorites({ final bool oCSAPIRequest = true, }) async { @@ -350,7 +509,22 @@ class WeatherStatusWeatherStatusClient { return rawResponse.future; } - /// Get favorites list + /// Get favorites list. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Favorites returned + /// + /// See: + /// * [getFavorites] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse getFavoritesRaw({ final bool oCSAPIRequest = true, }) { @@ -394,7 +568,20 @@ class WeatherStatusWeatherStatusClient { ); } - /// Set favorites list + /// Set favorites list. + /// + /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [favorites] Favorite addresses + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Favorites updated + /// + /// See: + /// * [setFavoritesRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> setFavorites({ required final List favorites, final bool oCSAPIRequest = true, @@ -407,7 +594,23 @@ class WeatherStatusWeatherStatusClient { return rawResponse.future; } - /// Set favorites list + /// Set favorites list. + /// + /// This method and the response it returns is experimental. The API might change without a major version bump. + /// + /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. + /// Throws a [DynamiteApiException] if the API call does not return an expected status code. + /// + /// Parameters: + /// * [favorites] Favorite addresses + /// * [oCSAPIRequest] Required to be true for the API request to pass + /// + /// Status codes: + /// * 200: Favorites updated + /// + /// See: + /// * [setFavorites] for an operation that returns a [DynamiteResponse] with a stable API. + @experimental DynamiteRawResponse setFavoritesRaw({ required final List favorites, final bool oCSAPIRequest = true, From 7ed9d1b66fbb6d5850e1fecbc409655fb0d09322 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Tue, 26 Sep 2023 22:55:56 +0200 Subject: [PATCH 8/9] refactor(neon): make RequestManager more reliable and performant Signed-off-by: Nikolas Rimikis --- packages/neon/neon/lib/src/bloc/result.dart | 18 +- .../neon/lib/src/utils/request_manager.dart | 172 ++++++++++-------- 2 files changed, 114 insertions(+), 76 deletions(-) diff --git a/packages/neon/neon/lib/src/bloc/result.dart b/packages/neon/neon/lib/src/bloc/result.dart index d652fbbf..66240ccd 100644 --- a/packages/neon/neon/lib/src/bloc/result.dart +++ b/packages/neon/neon/lib/src/bloc/result.dart @@ -42,11 +42,19 @@ class Result { isCached: isCached, ); - Result asLoading() => Result( - data, - error, - isLoading: true, - isCached: isCached, + Result asLoading() => copyWith(isLoading: true); + + Result copyWith({ + final T? data, + final Object? error, + final bool? isLoading, + final bool? isCached, + }) => + Result( + data ?? this.data, + error ?? this.error, + isLoading: isLoading ?? this.isLoading, + isCached: isCached ?? this.isCached, ); bool get hasError => error != null; diff --git a/packages/neon/neon/lib/src/utils/request_manager.dart b/packages/neon/neon/lib/src/utils/request_manager.dart index ec1b96ed..bfe5ee4e 100644 --- a/packages/neon/neon/lib/src/utils/request_manager.dart +++ b/packages/neon/neon/lib/src/utils/request_manager.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:convert'; import 'package:flutter/foundation.dart'; @@ -13,7 +14,10 @@ import 'package:xml/xml.dart' as xml; typedef UnwrapCallback = T Function(R); typedef SerializeCallback = String Function(T); typedef DeserializeCallback = T Function(String); -typedef NextcloudApiCallback = Future Function(); +typedef NextcloudApiCallback = AsyncValueGetter; + +const maxRetries = 3; +const defaultTimeout = Duration(seconds: 30); class RequestManager { RequestManager(); @@ -34,26 +38,32 @@ class RequestManager { Cache? _cache; - Future wrapNextcloud( + Future wrapNextcloud( final String clientID, final String k, final BehaviorSubject> subject, - final NextcloudApiCallback call, - final UnwrapCallback unwrap, { + final DynamiteRawResponse rawResponse, + final UnwrapCallback> unwrap, { final bool disableTimeout = false, - final bool emitEmptyCache = false, }) async => - _wrap( + _wrap>( clientID, k, subject, - call, - unwrap, - (final data) => json.encode(serializeNextcloud(data)), - (final data) => deserializeNextcloud(json.decode(data) as Object), + () async { + await rawResponse.future; + + return rawResponse; + }, + (final rawResponse) => unwrap(rawResponse.response), + (final data) => json.encode(data), + (final data) => DynamiteRawResponse.fromJson( + json.decode(data) as Map, + serializers: rawResponse.serializers, + bodyType: rawResponse.bodyType, + headersType: rawResponse.headersType, + ), disableTimeout, - emitEmptyCache, - 0, ); Future wrapWebDav( @@ -75,7 +85,6 @@ class RequestManager { (final data) => WebDavMultistatus.fromXmlElement(xml.XmlDocument.parse(data).rootElement), disableTimeout, emitEmptyCache, - 0, ); Future _wrap( @@ -85,44 +94,44 @@ class RequestManager { final NextcloudApiCallback call, final UnwrapCallback unwrap, final SerializeCallback serialize, - final DeserializeCallback deserialize, - final bool disableTimeout, - final bool emitEmptyCache, - final int retries, - ) async { - if (subject.valueOrNull?.hasData ?? false) { - subject.add( - Result( - subject.value.data, - null, - isLoading: true, - isCached: true, - ), - ); - } else { - subject.add(Result.loading()); - } + final DeserializeCallback deserialize, [ + final bool disableTimeout = false, + final bool emitEmptyCache = false, + final int retries = 0, + ]) async { + // emit loading state with the current value if present + final value = subject.valueOrNull?.copyWith(isLoading: true) ?? Result.loading(); + subject.add(value); final key = '$clientID-$k'; - await _emitCached( - key, - subject, - unwrap, - deserialize, - emitEmptyCache, - true, - null, + unawaited( + _emitCached( + key, + subject, + unwrap, + deserialize, + emitEmptyCache, + ), ); try { - final response = await (disableTimeout ? call() : timeout(call)); - await _cache?.set(key, await compute(serialize, response)); + final response = await timeout(call, disableTimeout: disableTimeout); subject.add(Result.success(unwrap(response))); + + final serialized = serialize(response); + await _cache?.set(key, serialized); + } on TimeoutException catch (e, s) { + debugPrint('Request timed out ...'); + debugPrint(e.toString()); + debugPrintStack(stackTrace: s, maxFrames: 5); + + _emitError(e, subject); } catch (e, s) { debugPrint(e.toString()); - debugPrint(s.toString()); - if (e is DynamiteApiException && e.statusCode >= 500 && retries < 3) { + debugPrintStack(stackTrace: s, maxFrames: 5); + + if (e is DynamiteApiException && e.statusCode >= 500 && retries < maxRetries) { debugPrint('Retrying...'); await _wrap( clientID, @@ -136,58 +145,79 @@ class RequestManager { emitEmptyCache, retries + 1, ); - return; - } - if (!(await _emitCached( - key, - subject, - unwrap, - deserialize, - emitEmptyCache, - false, - e, - ))) { - subject.add(Result.error(e)); + } else { + _emitError(e, subject); } } } + /// Re emits the current result with the given [error]. + /// + /// Defaults to a [Result.error] if none has been emitted yet. + void _emitError( + final Object error, + final BehaviorSubject> subject, + ) { + final value = subject.valueOrNull?.copyWith(error: error, isLoading: false) ?? Result.error(error); + subject.add(value); + } + Future _emitCached( final String key, final BehaviorSubject> subject, final UnwrapCallback unwrap, final DeserializeCallback deserialize, final bool emitEmptyCache, - final bool loading, - final Object? error, ) async { - T? cached; - try { - if (_cache != null && await _cache!.has(key)) { - cached = unwrap(await compute(deserialize, (await _cache!.get(key))!)); + if (_cache != null && await _cache!.has(key)) { + try { + final cacheValue = await _cache!.get(key); + final cached = unwrap(deserialize(cacheValue!)); + + // If the network fetch is faster than fetching the cached value the + // subject can be closed before emitting. + if (subject.value.hasUncachedData) { + return true; + } + + subject.add( + subject.value.copyWith( + data: cached, + isCached: true, + ), + ); + + return true; + } catch (e, s) { + debugPrint(e.toString()); + debugPrintStack(stackTrace: s, maxFrames: 5); } - } catch (e, s) { - debugPrint(e.toString()); - debugPrint(s.toString()); } - if (cached != null || emitEmptyCache) { + + if (emitEmptyCache && !subject.value.hasUncachedData) { subject.add( - Result( - cached, - error, - isLoading: loading, + subject.value.copyWith( isCached: true, ), ); + return true; } + return false; } Future timeout( - final NextcloudApiCallback call, - ) => - call().timeout(const Duration(seconds: 30)); + final NextcloudApiCallback call, { + final bool disableTimeout = false, + final Duration timeout = const Duration(seconds: 30), + }) { + if (disableTimeout) { + return call(); + } + + return call().timeout(timeout); + } } @internal From f8765fb2fb5d18e8ed609bff1efbc0bb583a5818 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Tue, 26 Sep 2023 22:56:46 +0200 Subject: [PATCH 9/9] refactor(app,neon_files,neon_news,neon_notes,neon_notifications): adapt to new request manager Signed-off-by: Nikolas Rimikis --- .../app/integration_test/screenshot_test.dart | 3 ++- packages/neon/neon/lib/src/blocs/apps.dart | 6 ++--- .../neon/neon/lib/src/blocs/capabilities.dart | 6 ++--- .../lib/src/blocs/login_check_account.dart | 2 +- .../src/blocs/login_check_server_status.dart | 2 +- .../neon/neon/lib/src/blocs/login_flow.dart | 6 ++--- .../neon/neon/lib/src/blocs/next_push.dart | 3 ++- .../lib/src/blocs/push_notifications.dart | 2 +- .../neon/lib/src/blocs/unified_search.dart | 5 ++-- .../neon/neon/lib/src/blocs/user_details.dart | 6 ++--- .../neon/lib/src/blocs/user_statuses.dart | 4 ++-- packages/neon/neon/lib/src/pages/home.dart | 2 +- .../neon/neon/lib/src/utils/push_utils.dart | 7 +++--- .../neon/lib/src/widgets/cached_image.dart | 7 ++++-- .../neon/lib/src/widgets/user_avatar.dart | 24 +++++++++---------- .../neon/neon_files/lib/blocs/browser.dart | 2 +- .../neon/neon_news/lib/blocs/articles.dart | 6 ++--- packages/neon/neon_news/lib/blocs/news.dart | 16 ++++++------- packages/neon/neon_notes/lib/blocs/note.dart | 6 ++--- packages/neon/neon_notes/lib/blocs/notes.dart | 6 ++--- .../lib/blocs/notifications.dart | 11 ++++----- 21 files changed, 66 insertions(+), 66 deletions(-) diff --git a/packages/app/integration_test/screenshot_test.dart b/packages/app/integration_test/screenshot_test.dart index 50973fea..86f83251 100644 --- a/packages/app/integration_test/screenshot_test.dart +++ b/packages/app/integration_test/screenshot_test.dart @@ -53,6 +53,7 @@ Future getAccount(final String username) async { loginName: username, password: username, ).core.appPassword.getAppPassword()) + .body .ocs .data .apppassword; @@ -149,7 +150,7 @@ Future main() async { final folder = await account.client.news.createFolder(name: 'test'); await account.client.news.addFeed( url: nasaFeedURL, - folderId: folder.folders.single.id, + folderId: folder.body.folders.single.id, ); await runTestApp( diff --git a/packages/neon/neon/lib/src/blocs/apps.dart b/packages/neon/neon/lib/src/blocs/apps.dart index 54fd9fa7..9733e0f6 100644 --- a/packages/neon/neon/lib/src/blocs/apps.dart +++ b/packages/neon/neon/lib/src/blocs/apps.dart @@ -199,12 +199,12 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates @override Future refresh() async { await RequestManager.instance - .wrapNextcloud, CoreNavigationGetAppsNavigationResponseApplicationJson>( + .wrapNextcloud, CoreNavigationGetAppsNavigationResponseApplicationJson, void>( _account.id, 'apps-apps', apps, - () async => _account.client.core.navigation.getAppsNavigation(), - (final response) => response.ocs.data.toList(), + _account.client.core.navigation.getAppsNavigationRaw(), + (final response) => response.body.ocs.data.toList(), ); } diff --git a/packages/neon/neon/lib/src/blocs/capabilities.dart b/packages/neon/neon/lib/src/blocs/capabilities.dart index a2f91e95..f67a1d43 100644 --- a/packages/neon/neon/lib/src/blocs/capabilities.dart +++ b/packages/neon/neon/lib/src/blocs/capabilities.dart @@ -39,12 +39,12 @@ class CapabilitiesBloc extends InteractiveBloc implements CapabilitiesBlocEvents @override Future refresh() async { await RequestManager.instance.wrapNextcloud( + CoreOcsGetCapabilitiesResponseApplicationJson, void>( _account.id, 'capabilities', capabilities, - () async => _account.client.core.ocs.getCapabilities(), - (final response) => response.ocs.data, + _account.client.core.ocs.getCapabilitiesRaw(), + (final response) => response.body.ocs.data, ); } } diff --git a/packages/neon/neon/lib/src/blocs/login_check_account.dart b/packages/neon/neon/lib/src/blocs/login_check_account.dart index 337b3e56..1d1b7bf0 100644 --- a/packages/neon/neon/lib/src/blocs/login_check_account.dart +++ b/packages/neon/neon/lib/src/blocs/login_check_account.dart @@ -59,7 +59,7 @@ class LoginCheckAccountBloc extends InteractiveBloc final account = Account( serverURL: serverURL, - username: response.ocs.data.id, + username: response.body.ocs.data.id, password: password, userAgent: neonUserAgent, ); diff --git a/packages/neon/neon/lib/src/blocs/login_check_server_status.dart b/packages/neon/neon/lib/src/blocs/login_check_server_status.dart index 1f7eeb4d..73a42f57 100644 --- a/packages/neon/neon/lib/src/blocs/login_check_server_status.dart +++ b/packages/neon/neon/lib/src/blocs/login_check_server_status.dart @@ -47,7 +47,7 @@ class LoginCheckServerStatusBloc extends InteractiveBloc ); final status = await client.core.getStatus(); - state.add(Result.success(status)); + state.add(Result.success(status.body)); } catch (e, s) { debugPrint(e.toString()); debugPrint(s.toString()); diff --git a/packages/neon/neon/lib/src/blocs/login_flow.dart b/packages/neon/neon/lib/src/blocs/login_flow.dart index a0d3e892..2f640bdd 100644 --- a/packages/neon/neon/lib/src/blocs/login_flow.dart +++ b/packages/neon/neon/lib/src/blocs/login_flow.dart @@ -54,14 +54,14 @@ class LoginFlowBloc extends InteractiveBloc implements LoginFlowBlocEvents, Logi init.add(Result.loading()); final initResponse = await _client.core.clientFlowLoginV2.init(); - init.add(Result.success(initResponse)); + init.add(Result.success(initResponse.body)); _cancelPollTimer(); _pollTimer = Timer.periodic(const Duration(seconds: 1), (final _) async { try { - final resultResponse = await _client.core.clientFlowLoginV2.poll(token: initResponse.poll.token); + final resultResponse = await _client.core.clientFlowLoginV2.poll(token: initResponse.body.poll.token); _cancelPollTimer(); - _resultController.add(resultResponse); + _resultController.add(resultResponse.body); } catch (e, s) { debugPrint(e.toString()); debugPrint(s.toString()); diff --git a/packages/neon/neon/lib/src/blocs/next_push.dart b/packages/neon/neon/lib/src/blocs/next_push.dart index 0e9184f1..79ad6e62 100644 --- a/packages/neon/neon/lib/src/blocs/next_push.dart +++ b/packages/neon/neon/lib/src/blocs/next_push.dart @@ -46,7 +46,8 @@ class NextPushBloc extends Bloc implements NextPushBlocEvents, NextPushBlocState for (final account in _accountsBloc.accounts.value) { if (!_supported.containsKey(account)) { try { - _supported[account] = (await account.client.uppush.check()).success; + final response = await account.client.uppush.check(); + _supported[account] = response.body.success; } catch (e, s) { debugPrint(e.toString()); debugPrint(s.toString()); diff --git a/packages/neon/neon/lib/src/blocs/push_notifications.dart b/packages/neon/neon/lib/src/blocs/push_notifications.dart index bc5c7051..9571bb53 100644 --- a/packages/neon/neon/lib/src/blocs/push_notifications.dart +++ b/packages/neon/neon/lib/src/blocs/push_notifications.dart @@ -96,7 +96,7 @@ class PushNotificationsBloc extends Bloc implements PushNotificationsBlocEvents, await _storage.setString(_keyLastEndpoint(account), endpoint); debugPrint( - 'Account $instance registered for push notifications ${json.encode(subscription.ocs.data.toJson())}', + 'Account $instance registered for push notifications ${json.encode(subscription.body.ocs.data.toJson())}', ); }, onMessage: PushUtils.onMessage, diff --git a/packages/neon/neon/lib/src/blocs/unified_search.dart b/packages/neon/neon/lib/src/blocs/unified_search.dart index a20e59ad..e99933ab 100644 --- a/packages/neon/neon/lib/src/blocs/unified_search.dart +++ b/packages/neon/neon/lib/src/blocs/unified_search.dart @@ -88,7 +88,8 @@ class UnifiedSearchBloc extends InteractiveBloc implements UnifiedSearchBlocEven try { results.add(results.value.asLoading()); - final providers = (await _account.client.core.unifiedSearch.getProviders()).ocs.data; + final response = await _account.client.core.unifiedSearch.getProviders(); + final providers = response.body.ocs.data; results.add( Result.success(Map.fromEntries(_getLoadingProviders(providers))), ); @@ -117,7 +118,7 @@ class UnifiedSearchBloc extends InteractiveBloc implements UnifiedSearchBlocEven providerId: provider.id, term: _term, ); - _updateResults(provider, Result.success(response.ocs.data)); + _updateResults(provider, Result.success(response.body.ocs.data)); } catch (e, s) { debugPrint(e.toString()); debugPrint(s.toString()); diff --git a/packages/neon/neon/lib/src/blocs/user_details.dart b/packages/neon/neon/lib/src/blocs/user_details.dart index d109406b..2336ab9c 100644 --- a/packages/neon/neon/lib/src/blocs/user_details.dart +++ b/packages/neon/neon/lib/src/blocs/user_details.dart @@ -39,12 +39,12 @@ class UserDetailsBloc extends InteractiveBloc implements UserDetailsBlocEvents, @override Future refresh() async { await RequestManager.instance - .wrapNextcloud( + .wrapNextcloud( _account.id, 'user-details', userDetails, - () async => _account.client.provisioningApi.users.getCurrentUser(), - (final response) => response.ocs.data, + _account.client.provisioningApi.users.getCurrentUserRaw(), + (final response) => response.body.ocs.data, ); } } diff --git a/packages/neon/neon/lib/src/blocs/user_statuses.dart b/packages/neon/neon/lib/src/blocs/user_statuses.dart index 5cf0dd3b..eee802de 100644 --- a/packages/neon/neon/lib/src/blocs/user_statuses.dart +++ b/packages/neon/neon/lib/src/blocs/user_statuses.dart @@ -73,7 +73,7 @@ class UserStatusesBloc extends InteractiveBloc implements UserStatusesBlocEvents final response = await _account.client.userStatus.heartbeat.heartbeat( status: isAway ? 'away' : 'online', ); - data = response.ocs.data; + data = response.body.ocs.data; } catch (e) { // 204 is returned if the heartbeat failed because the current status is different. Ignore this and fetch the normal status if (e is! DynamiteApiException || e.statusCode != 204) { @@ -84,7 +84,7 @@ class UserStatusesBloc extends InteractiveBloc implements UserStatusesBlocEvents if (data == null) { final response = await _account.client.userStatus.statuses.find(userId: username); - data = response.ocs.data; + data = response.body.ocs.data; } _updateStatus(username, Result.success(data)); diff --git a/packages/neon/neon/lib/src/pages/home.dart b/packages/neon/neon/lib/src/pages/home.dart index 2ff64712..a66a881a 100644 --- a/packages/neon/neon/lib/src/pages/home.dart +++ b/packages/neon/neon/lib/src/pages/home.dart @@ -82,7 +82,7 @@ class _HomePageState extends State { Future _checkMaintenanceMode() async { try { final status = await _account.client.core.getStatus(); - if (status.maintenance && mounted) { + if (status.body.maintenance && mounted) { await _showProblem( AppLocalizations.of(context).errorServerInMaintenanceMode, ); diff --git a/packages/neon/neon/lib/src/utils/push_utils.dart b/packages/neon/neon/lib/src/utils/push_utils.dart index 0880f97c..49a99188 100644 --- a/packages/neon/neon/lib/src/utils/push_utils.dart +++ b/packages/neon/neon/lib/src/utils/push_utils.dart @@ -102,10 +102,9 @@ class PushUtils { try { account = accounts.tryFind(instance); if (account != null) { - notification = - (await account.client.notifications.endpoint.getNotification(id: pushNotification.subject.nid!)) - .ocs - .data; + final response = + await account.client.notifications.endpoint.getNotification(id: pushNotification.subject.nid!); + notification = response.body.ocs.data; if (notification.icon?.endsWith('.svg') ?? false) { // Only SVG icons are supported right now (should be most of them) diff --git a/packages/neon/neon/lib/src/widgets/cached_image.dart b/packages/neon/neon/lib/src/widgets/cached_image.dart index 4f393d73..08a58bb6 100644 --- a/packages/neon/neon/lib/src/widgets/cached_image.dart +++ b/packages/neon/neon/lib/src/widgets/cached_image.dart @@ -17,7 +17,7 @@ typedef ImageDownloader = FutureOr Function(); typedef CacheWriter = Future Function(CacheManager cacheManager, Uint8List image); typedef ErrorWidgetBuilder = Widget? Function(BuildContext, dynamic); -typedef ApiImageDownloader = FutureOr Function(NextcloudClient client); +typedef ApiImageDownloader = FutureOr> Function(NextcloudClient client); class NeonCachedImage extends StatefulWidget { const NeonCachedImage({ @@ -223,7 +223,10 @@ class NeonApiImage extends StatelessWidget { final account = NeonProvider.of(context).activeAccount.value!; return NeonCachedImage.custom( - getImage: () async => getImage(account.client), + getImage: () async { + final response = await getImage(account.client); + return response.body; + }, cacheKey: '${account.id}-$cacheKey', ); } diff --git a/packages/neon/neon/lib/src/widgets/user_avatar.dart b/packages/neon/neon/lib/src/widgets/user_avatar.dart index f4277785..76c7c391 100644 --- a/packages/neon/neon/lib/src/widgets/user_avatar.dart +++ b/packages/neon/neon/lib/src/widgets/user_avatar.dart @@ -64,19 +64,17 @@ class _UserAvatarState extends State { child: NeonCachedImage.custom( cacheKey: '${widget.account.id}-avatar-${widget.username}-$brightness$pixelSize', getImage: () async { - if (brightness == Brightness.dark) { - return (await widget.account.client.core.avatar.getAvatarDark( - userId: widget.username, - size: pixelSize, - )) - .data; - } else { - return (await widget.account.client.core.avatar.getAvatar( - userId: widget.username, - size: pixelSize, - )) - .data; - } + final response = switch (brightness) { + Brightness.dark => await widget.account.client.core.avatar.getAvatarDark( + userId: widget.username, + size: pixelSize, + ), + Brightness.light => await widget.account.client.core.avatar.getAvatar( + userId: widget.username, + size: pixelSize, + ), + }; + return response.body; }, ), ), diff --git a/packages/neon/neon_files/lib/blocs/browser.dart b/packages/neon/neon_files/lib/blocs/browser.dart index b644e9a7..80c97062 100644 --- a/packages/neon/neon_files/lib/blocs/browser.dart +++ b/packages/neon/neon_files/lib/blocs/browser.dart @@ -47,7 +47,7 @@ class FilesBrowserBloc extends InteractiveBloc implements FilesBrowserBlocEvents account.id, 'files-${path.value.join('/')}', files, - () async => account.client.webdav.propfind( + () => account.client.webdav.propfind( Uri(pathSegments: path.value), prop: WebDavPropWithoutValues.fromBools( davgetcontenttype: true, diff --git a/packages/neon/neon_news/lib/blocs/articles.dart b/packages/neon/neon_news/lib/blocs/articles.dart index c8ae115f..45b2c287 100644 --- a/packages/neon/neon_news/lib/blocs/articles.dart +++ b/packages/neon/neon_news/lib/blocs/articles.dart @@ -115,16 +115,16 @@ class NewsArticlesBloc extends InteractiveBloc implements NewsArticlesBlocEvents } } - await RequestManager.instance.wrapNextcloud, NewsListArticles>( + await RequestManager.instance.wrapNextcloud, NewsListArticles, void>( account.id, 'news-articles-${type.index}-$id-$getRead', articles, - () async => account.client.news.listArticles( + account.client.news.listArticlesRaw( type: type.index, id: id ?? 0, getRead: getRead ?? true ? 1 : 0, ), - (final response) => response.items.toList(), + (final response) => response.body.items.toList(), ); } diff --git a/packages/neon/neon_news/lib/blocs/news.dart b/packages/neon/neon_news/lib/blocs/news.dart index 224fec85..1f7033de 100644 --- a/packages/neon/neon_news/lib/blocs/news.dart +++ b/packages/neon/neon_news/lib/blocs/news.dart @@ -92,23 +92,23 @@ class NewsBloc extends InteractiveBloc implements NewsBlocEvents, NewsBlocStates @override Future refresh() async { await Future.wait([ - RequestManager.instance.wrapNextcloud, NewsListFolders>( + RequestManager.instance.wrapNextcloud, NewsListFolders, void>( account.id, 'news-folders', folders, - () async => account.client.news.listFolders(), - (final response) => response.folders.toList(), + account.client.news.listFoldersRaw(), + (final response) => response.body.folders.toList(), ), - RequestManager.instance.wrapNextcloud, NewsListFeeds>( + RequestManager.instance.wrapNextcloud, NewsListFeeds, void>( account.id, 'news-feeds', feeds, - () async => account.client.news.listFeeds(), + account.client.news.listFeedsRaw(), (final response) { - if (response.newestItemId != null) { - _newestItemId = response.newestItemId!; + if (response.body.newestItemId != null) { + _newestItemId = response.body.newestItemId!; } - return response.feeds.toList(); + return response.body.feeds.toList(); }, ), mainArticlesBloc.reload(), diff --git a/packages/neon/neon_notes/lib/blocs/note.dart b/packages/neon/neon_notes/lib/blocs/note.dart index de552b54..02e8b9aa 100644 --- a/packages/neon/neon_notes/lib/blocs/note.dart +++ b/packages/neon/neon_notes/lib/blocs/note.dart @@ -29,11 +29,11 @@ class NotesNoteBloc extends InteractiveBloc implements NotesNoteBlocEvents, Note } // ignore: avoid_void_async - void _wrapAction(final Future Function(String etag) call) async { + void _wrapAction(final Future> Function(String etag) call) async { await _updateQueue.add(() async { try { - final data = await call(_etag); - _emitNote(data); + final response = await call(_etag); + _emitNote(response.body); await _notesBloc.refresh(); } catch (e, s) { debugPrint(e.toString()); diff --git a/packages/neon/neon_notes/lib/blocs/notes.dart b/packages/neon/neon_notes/lib/blocs/notes.dart index 2f24714b..64e3a38f 100644 --- a/packages/neon/neon_notes/lib/blocs/notes.dart +++ b/packages/neon/neon_notes/lib/blocs/notes.dart @@ -44,12 +44,12 @@ class NotesBloc extends InteractiveBloc implements NotesBlocEvents, NotesBlocSta @override Future refresh() async { - await RequestManager.instance.wrapNextcloud, BuiltList>( + await RequestManager.instance.wrapNextcloud, BuiltList, void>( account.id, 'notes-notes', notes, - () async => account.client.notes.getNotes(), - List.from, + account.client.notes.getNotesRaw(), + (final response) => List.from(response.body), ); } diff --git a/packages/neon/neon_notifications/lib/blocs/notifications.dart b/packages/neon/neon_notifications/lib/blocs/notifications.dart index e0da4a9f..6ea611e0 100644 --- a/packages/neon/neon_notifications/lib/blocs/notifications.dart +++ b/packages/neon/neon_notifications/lib/blocs/notifications.dart @@ -50,16 +50,13 @@ class NotificationsBloc extends InteractiveBloc @override Future refresh() async { - await RequestManager.instance - .wrapNextcloud, NotificationsEndpointListNotificationsResponseApplicationJson>( + await RequestManager.instance.wrapNextcloud, + NotificationsEndpointListNotificationsResponseApplicationJson, void>( _account.id, 'notifications-notifications', notifications, - () async { - final response = await _account.client.notifications.endpoint.listNotifications(); - return response.data; - }, - (final response) => response.ocs.data.toList(), + _account.client.notifications.endpoint.listNotificationsRaw(), + (final response) => response.body.ocs.data.toList(), ); }