Browse Source

feat(dynamite,dynamite_runtime): generate DynamiteRawResponses for all endpoints

Signed-off-by: Nikolas Rimikis <leptopoda@users.noreply.github.com>
pull/846/head
Nikolas Rimikis 2 years ago
parent
commit
dd185cdd06
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 496
      packages/dynamite/dynamite/lib/src/builder/client.dart
  2. 1
      packages/dynamite/dynamite/lib/src/builder/imports.dart
  3. 129
      packages/dynamite/dynamite/lib/src/builder/resolve_mime_type.dart
  4. 10
      packages/dynamite/dynamite/lib/src/builder/serializer.dart
  5. 4
      packages/dynamite/dynamite_runtime/analysis_options.yaml
  6. 4
      packages/dynamite/dynamite_runtime/lib/http_client.dart
  7. 445
      packages/dynamite/dynamite_runtime/lib/src/dynamite_client.dart
  8. 249
      packages/dynamite/dynamite_runtime/lib/src/http_client.dart
  9. 43
      packages/dynamite/dynamite_runtime/lib/src/http_extensions.dart
  10. 7
      packages/nextcloud/lib/src/api/comments.openapi.dart
  11. 1880
      packages/nextcloud/lib/src/api/core.openapi.dart
  12. 132
      packages/nextcloud/lib/src/api/dashboard.openapi.dart
  13. 48
      packages/nextcloud/lib/src/api/dav.openapi.dart
  14. 531
      packages/nextcloud/lib/src/api/files.openapi.dart
  15. 46
      packages/nextcloud/lib/src/api/files_external.openapi.dart
  16. 136
      packages/nextcloud/lib/src/api/files_reminders.openapi.dart
  17. 895
      packages/nextcloud/lib/src/api/files_sharing.openapi.dart
  18. 47
      packages/nextcloud/lib/src/api/files_trashbin.openapi.dart
  19. 47
      packages/nextcloud/lib/src/api/files_versions.openapi.dart
  20. 610
      packages/nextcloud/lib/src/api/news.openapi.dart
  21. 272
      packages/nextcloud/lib/src/api/notes.openapi.dart
  22. 444
      packages/nextcloud/lib/src/api/notifications.openapi.dart
  23. 1889
      packages/nextcloud/lib/src/api/provisioning_api.openapi.dart
  24. 43
      packages/nextcloud/lib/src/api/settings.openapi.dart
  25. 7
      packages/nextcloud/lib/src/api/sharebymail.openapi.dart
  26. 426
      packages/nextcloud/lib/src/api/theming.openapi.dart
  27. 51
      packages/nextcloud/lib/src/api/updatenotification.openapi.dart
  28. 412
      packages/nextcloud/lib/src/api/uppush.openapi.dart
  29. 403
      packages/nextcloud/lib/src/api/user_status.openapi.dart
  30. 277
      packages/nextcloud/lib/src/api/weather_status.openapi.dart
  31. 44
      packages/nextcloud/lib/src/client.dart
  32. 4
      packages/nextcloud/lib/src/version_supported.dart
  33. 6
      packages/nextcloud/lib/src/webdav/client.dart
  34. 179
      packages/nextcloud/test/core_test.dart
  35. 10
      packages/nextcloud/test/dashboard_test.dart
  36. 259
      packages/nextcloud/test/news_test.dart
  37. 117
      packages/nextcloud/test/notes_test.dart
  38. 40
      packages/nextcloud/test/notifications_test.dart
  39. 36
      packages/nextcloud/test/provisioning_api_test.dart
  40. 5
      packages/nextcloud/test/settings_test.dart
  41. 43
      packages/nextcloud/test/uppush_test.dart
  42. 165
      packages/nextcloud/test/user_status_test.dart

496
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<Method> 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 = <openapi.Response, List<int>>{};
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 = <openapi.Response, List<int>>{};
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 = <String, dynamic>{};
final _headers = <String, String>{${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<Parameter>();
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<DynamiteResponse<$dataType, $headersType>>');
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<void>');
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<DynamiteResponse<$returnDataType, $returnHeadersType>>')
..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());
},
);
}

1
packages/dynamite/dynamite/lib/src/builder/imports.dart

@ -4,6 +4,7 @@ import 'package:path/path.dart' as p;
List<Spec> 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'),

129
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<String> resolveMimeTypeEncode(
final openapi.Operation operation,
final openapi.OpenAPI spec,
final State state,
final String identifier,
final ListBuilder<Parameter> 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"');
}
}
}
}

10
packages/dynamite/dynamite/lib/src/builder/serializer.dart

@ -13,19 +13,9 @@ List<Spec> 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}<T>(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;',
),
const Code(''),
Code(
'Object? serialize${state.classPrefix}<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));',
),
const Code('// coverage:ignore-end'),
];
}

4
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'

4
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';

445
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<B, H> {
/// 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<B, H> {
/// 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<HttpClientResponse> response,
required this.bodyType,
required this.headersType,
required this.serializers,
}) {
final completer = Completer<DynamiteResponse<B, H>>();
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<B>(_rawBody, serializers, bodyType);
final headers = deserializeHeaders<H>(_rawHeaders, serializers, headersType);
_response = DynamiteResponse<B, H>(
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<String, Object?> json, {
required final Serializers serializers,
final FullType? bodyType,
final FullType? headersType,
}) {
final statusCode = json['statusCode']! as int;
final body = deserializeBody<B>(json['body'], serializers, bodyType);
final headers = deserializeHeaders<H>(json['headers'], serializers, headersType);
final response = DynamiteResponse<B, H>(
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<DynamiteResponse<B, H>> 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<String, String>? _rawHeaders;
DynamiteResponse<B, H>? _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<B, H> 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<B>(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<H>(
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<String, Object?> 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<DynamiteApiException> 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<String, String> 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<String, String> 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<String, String> 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<String, String> 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<String, String>? 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<DynamiteAuthentication> authentications;
/// Makes a request against a given [path].
Future<HttpClientResponse> doRequest(
final String method,
final Uri path,
final Map<String, String> headers,
final Uint8List? body,
final Set<int>? 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);
}
}
}

249
packages/dynamite/dynamite_runtime/lib/src/http_client.dart

@ -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<Uint8List> get bodyBytes async {
final buffer = BytesBuilder();
await forEach(buffer.add);
return buffer.toBytes();
}
Future<String> get body => transform(utf8.decoder).join();
Future<dynamic> get jsonBody => transform(utf8.decoder).transform(json.decoder).first;
Map<String, String> get responseHeaders {
final responseHeaders = <String, String>{};
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<B, H> {
/// 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<DynamiteApiException> 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<String, String> 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<String, String> 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<String, String> 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<String, String> 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<String, String>? 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<DynamiteAuthentication> authentications;
/// Makes a request against a given [path].
Future<HttpClientResponse> doRequest(
final String method,
final Uri path,
final Map<String, String> 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;
}
}

43
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<Uint8List>`.
typedef BytesStream = Stream<List<int>>;
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<Uint8List> get bytes async {
final buffer = BytesBuilder();
await forEach(buffer.add);
return buffer.toBytes();
}
/// Converts the stream into a `String` using the [utf8] encoding.
Future<String> get string => transform(utf8.decoder).join();
/// Converts the stream into a JSON using the [utf8] encoding.
Future<Object?> get json => transform(_utf8JsonDecoder).first;
}
/// Extension on a http responses.
extension HttpClientResponseExtension on HttpClientResponse {
/// Returns a map of headers.
Map<String, String> get responseHeaders {
final responseHeaders = <String, String>{};
headers.forEach((final name, final values) {
responseHeaders[name] = values.last;
});
return responseHeaders;
}
}

7
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<T>(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;
Object? serializeComments<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

1880
packages/nextcloud/lib/src/api/core.openapi.dart

File diff suppressed because it is too large Load Diff

132
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<DashboardDashboardApiGetWidgetsResponseApplicationJson> getWidgets({final bool oCSAPIRequest = true}) async {
Future<DynamiteResponse<DashboardDashboardApiGetWidgetsResponseApplicationJson, void>> getWidgets({
final bool oCSAPIRequest = true,
}) async {
final rawResponse = getWidgetsRaw(
oCSAPIRequest: oCSAPIRequest,
);
return rawResponse.future;
}
/// Get the widgets
DynamiteRawResponse<DashboardDashboardApiGetWidgetsResponseApplicationJson, void> getWidgetsRaw({
final bool oCSAPIRequest = true,
}) {
const path = '/ocs/v2.php/apps/dashboard/api/v1/widgets';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<DashboardDashboardApiGetWidgetsResponseApplicationJson, void>(
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<DashboardDashboardApiGetWidgetItemsResponseApplicationJson> getWidgetItems({
Future<DynamiteResponse<DashboardDashboardApiGetWidgetItemsResponseApplicationJson, void>> getWidgetItems({
final ContentString<BuiltMap<String, String>>? sinceIds,
final int limit = 7,
final List<String> widgets = const <String>[],
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<DashboardDashboardApiGetWidgetItemsResponseApplicationJson, void> getWidgetItemsRaw({
final ContentString<BuiltMap<String, String>>? sinceIds,
final int limit = 7,
final List<String> widgets = const <String>[],
final bool oCSAPIRequest = true,
}) {
const path = '/ocs/v2.php/apps/dashboard/api/v1/widget-items';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<DashboardDashboardApiGetWidgetItemsResponseApplicationJson, void>(
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<DashboardDashboardApiGetWidgetItemsV2ResponseApplicationJson> getWidgetItemsV2({
Future<DynamiteResponse<DashboardDashboardApiGetWidgetItemsV2ResponseApplicationJson, void>> getWidgetItemsV2({
final ContentString<BuiltMap<String, String>>? sinceIds,
final int limit = 7,
final List<String> widgets = const <String>[],
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<DashboardDashboardApiGetWidgetItemsV2ResponseApplicationJson, void> getWidgetItemsV2Raw({
final ContentString<BuiltMap<String, String>>? sinceIds,
final int limit = 7,
final List<String> widgets = const <String>[],
final bool oCSAPIRequest = true,
}) {
const path = '/ocs/v2.php/apps/dashboard/api/v2/widget-items';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<DashboardDashboardApiGetWidgetItemsV2ResponseApplicationJson, void>(
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<T>(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;
Object? serializeDashboard<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

48
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<DavDirectGetUrlResponseApplicationJson> getUrl({
Future<DynamiteResponse<DavDirectGetUrlResponseApplicationJson, void>> 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<DavDirectGetUrlResponseApplicationJson, void> getUrlRaw({
required final int fileId,
final int? expirationTime,
final bool oCSAPIRequest = true,
}) {
const path = '/ocs/v2.php/apps/dav/api/v1/direct';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<DavDirectGetUrlResponseApplicationJson, void>(
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<T>(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;
Object? serializeDav<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

531
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<Uint8List> getThumbnail({
Future<DynamiteResponse<Uint8List, void>> 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<Uint8List, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<Uint8List, void>(
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<FilesDirectEditingInfoResponseApplicationJson> info({final bool oCSAPIRequest = true}) async {
Future<DynamiteResponse<FilesDirectEditingInfoResponseApplicationJson, void>> info({
final bool oCSAPIRequest = true,
}) async {
final rawResponse = infoRaw(
oCSAPIRequest: oCSAPIRequest,
);
return rawResponse.future;
}
/// Get the direct editing capabilities
DynamiteRawResponse<FilesDirectEditingInfoResponseApplicationJson, void> infoRaw({final bool oCSAPIRequest = true}) {
const path = '/ocs/v2.php/apps/files/api/v1/directEditing';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<FilesDirectEditingInfoResponseApplicationJson, void>(
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<FilesDirectEditingTemplatesResponseApplicationJson> templates({
Future<DynamiteResponse<FilesDirectEditingTemplatesResponseApplicationJson, void>> 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<FilesDirectEditingTemplatesResponseApplicationJson, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<FilesDirectEditingTemplatesResponseApplicationJson, void>(
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<FilesDirectEditingOpenResponseApplicationJson> open({
Future<DynamiteResponse<FilesDirectEditingOpenResponseApplicationJson, void>> 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<FilesDirectEditingOpenResponseApplicationJson, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<FilesDirectEditingOpenResponseApplicationJson, void>(
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<FilesDirectEditingCreateResponseApplicationJson> create({
Future<DynamiteResponse<FilesDirectEditingCreateResponseApplicationJson, void>> 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<FilesDirectEditingCreateResponseApplicationJson, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<FilesDirectEditingCreateResponseApplicationJson, void>(
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<FilesOpenLocalEditorCreateResponseApplicationJson> create({
Future<DynamiteResponse<FilesOpenLocalEditorCreateResponseApplicationJson, void>> 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<FilesOpenLocalEditorCreateResponseApplicationJson, void> createRaw({
required final String path,
final bool oCSAPIRequest = true,
}) {
const path0 = '/ocs/v2.php/apps/files/api/v1/openlocaleditor';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<FilesOpenLocalEditorCreateResponseApplicationJson, void>(
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<FilesOpenLocalEditorValidateResponseApplicationJson> validate({
Future<DynamiteResponse<FilesOpenLocalEditorValidateResponseApplicationJson, void>> 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<FilesOpenLocalEditorValidateResponseApplicationJson, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<FilesOpenLocalEditorValidateResponseApplicationJson, void>(
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<FilesTemplateListResponseApplicationJson> list({final bool oCSAPIRequest = true}) async {
Future<DynamiteResponse<FilesTemplateListResponseApplicationJson, void>> list({
final bool oCSAPIRequest = true,
}) async {
final rawResponse = listRaw(
oCSAPIRequest: oCSAPIRequest,
);
return rawResponse.future;
}
/// List the available templates
DynamiteRawResponse<FilesTemplateListResponseApplicationJson, void> listRaw({final bool oCSAPIRequest = true}) {
const path = '/ocs/v2.php/apps/files/api/v1/templates';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<FilesTemplateListResponseApplicationJson, void>(
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<FilesTemplateCreateResponseApplicationJson> create({
Future<DynamiteResponse<FilesTemplateCreateResponseApplicationJson, void>> 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<FilesTemplateCreateResponseApplicationJson, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<FilesTemplateCreateResponseApplicationJson, void>(
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<FilesTemplatePathResponseApplicationJson> path({
Future<DynamiteResponse<FilesTemplatePathResponseApplicationJson, void>> 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<FilesTemplatePathResponseApplicationJson, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<FilesTemplatePathResponseApplicationJson, void>(
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<FilesTransferOwnershipTransferResponseApplicationJson> transfer({
Future<DynamiteResponse<FilesTransferOwnershipTransferResponseApplicationJson, void>> 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<FilesTransferOwnershipTransferResponseApplicationJson, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<FilesTransferOwnershipTransferResponseApplicationJson, void>(
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<FilesTransferOwnershipAcceptResponseApplicationJson> accept({
Future<DynamiteResponse<FilesTransferOwnershipAcceptResponseApplicationJson, void>> 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<FilesTransferOwnershipAcceptResponseApplicationJson, void> acceptRaw({
required final int id,
final bool oCSAPIRequest = true,
}) {
var path = '/ocs/v2.php/apps/files/api/v1/transferownership/{id}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<FilesTransferOwnershipAcceptResponseApplicationJson, void>(
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<FilesTransferOwnershipRejectResponseApplicationJson> reject({
Future<DynamiteResponse<FilesTransferOwnershipRejectResponseApplicationJson, void>> 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<FilesTransferOwnershipRejectResponseApplicationJson, void> rejectRaw({
required final int id,
final bool oCSAPIRequest = true,
}) {
var path = '/ocs/v2.php/apps/files/api/v1/transferownership/{id}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<FilesTransferOwnershipRejectResponseApplicationJson, void>(
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<T>(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;
Object? serializeFiles<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

46
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<FilesExternalApiGetUserMountsResponseApplicationJson> getUserMounts({final bool oCSAPIRequest = true}) async {
Future<DynamiteResponse<FilesExternalApiGetUserMountsResponseApplicationJson, void>> getUserMounts({
final bool oCSAPIRequest = true,
}) async {
final rawResponse = getUserMountsRaw(
oCSAPIRequest: oCSAPIRequest,
);
return rawResponse.future;
}
/// Get the mount points visible for this user
DynamiteRawResponse<FilesExternalApiGetUserMountsResponseApplicationJson, void> getUserMountsRaw({
final bool oCSAPIRequest = true,
}) {
const path = '/ocs/v2.php/apps/files_external/api/v1/mounts';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<FilesExternalApiGetUserMountsResponseApplicationJson, void>(
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<T>(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;
Object? serializeFilesExternal<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

136
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<FilesRemindersApiGetResponseApplicationJson> $get({
Future<DynamiteResponse<FilesRemindersApiGetResponseApplicationJson, void>> $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<FilesRemindersApiGetResponseApplicationJson, void> $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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<FilesRemindersApiGetResponseApplicationJson, void>(
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<FilesRemindersApiSetResponseApplicationJson> $set({
Future<DynamiteResponse<FilesRemindersApiSetResponseApplicationJson, void>> $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<FilesRemindersApiSetResponseApplicationJson, void> $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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<FilesRemindersApiSetResponseApplicationJson, void>(
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<FilesRemindersApiRemoveResponseApplicationJson> remove({
Future<DynamiteResponse<FilesRemindersApiRemoveResponseApplicationJson, void>> 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<FilesRemindersApiRemoveResponseApplicationJson, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<FilesRemindersApiRemoveResponseApplicationJson, void>(
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<T>(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;
Object? serializeFilesReminders<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

895
packages/nextcloud/lib/src/api/files_sharing.openapi.dart

File diff suppressed because it is too large Load Diff

47
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<Uint8List> getPreview({
Future<DynamiteResponse<Uint8List, void>> 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<Uint8List, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<Uint8List, void>(
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<T>(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;
Object? serializeFilesTrashbin<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

47
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<Uint8List> getPreview({
Future<DynamiteResponse<Uint8List, void>> 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<Uint8List, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<Uint8List, void>(
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<T>(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;
Object? serializeFilesVersions<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

610
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<NewsSupportedAPIVersions> getSupportedApiVersions() async {
Future<DynamiteResponse<NewsSupportedAPIVersions, void>> getSupportedApiVersions() async {
final rawResponse = getSupportedApiVersionsRaw();
return rawResponse.future;
}
DynamiteRawResponse<NewsSupportedAPIVersions, void> getSupportedApiVersionsRaw() {
const path = '/index.php/apps/news/api';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<NewsSupportedAPIVersions, void>(
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<NewsListFolders> listFolders() async {
Future<DynamiteResponse<NewsListFolders, void>> listFolders() async {
final rawResponse = listFoldersRaw();
return rawResponse.future;
}
DynamiteRawResponse<NewsListFolders, void> listFoldersRaw() {
const path = '/index.php/apps/news/api/v1-3/folders';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<NewsListFolders, void>(
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<NewsListFolders> createFolder({required final String name}) async {
Future<DynamiteResponse<NewsListFolders, void>> createFolder({required final String name}) async {
final rawResponse = createFolderRaw(
name: name,
);
return rawResponse.future;
}
DynamiteRawResponse<NewsListFolders, void> createFolderRaw({required final String name}) {
const path = '/index.php/apps/news/api/v1-3/folders';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<NewsListFolders, void>(
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<void> renameFolder({
Future<DynamiteResponse<void, void>> renameFolder({
required final int folderId,
required final String name,
}) async {
final rawResponse = renameFolderRaw(
folderId: folderId,
name: name,
);
return rawResponse.future;
}
DynamiteRawResponse<void, void> renameFolderRaw({
required final int folderId,
required final String name,
}) {
var path = '/index.php/apps/news/api/v1-3/folders/{folderId}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
@ -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<void, void>(
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<void> deleteFolder({required final int folderId}) async {
Future<DynamiteResponse<void, void>> deleteFolder({required final int folderId}) async {
final rawResponse = deleteFolderRaw(
folderId: folderId,
);
return rawResponse.future;
}
DynamiteRawResponse<void, void> deleteFolderRaw({required final int folderId}) {
var path = '/index.php/apps/news/api/v1-3/folders/{folderId}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
@ -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<void, void>(
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<void> markFolderAsRead({
Future<DynamiteResponse<void, void>> markFolderAsRead({
required final int folderId,
required final int newestItemId,
}) async {
final rawResponse = markFolderAsReadRaw(
folderId: folderId,
newestItemId: newestItemId,
);
return rawResponse.future;
}
DynamiteRawResponse<void, void> markFolderAsReadRaw({
required final int folderId,
required final int newestItemId,
}) {
var path = '/index.php/apps/news/api/v1-3/folders/{folderId}/read';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
@ -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<void, void>(
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<NewsListFeeds> listFeeds() async {
Future<DynamiteResponse<NewsListFeeds, void>> listFeeds() async {
final rawResponse = listFeedsRaw();
return rawResponse.future;
}
DynamiteRawResponse<NewsListFeeds, void> listFeedsRaw() {
const path = '/index.php/apps/news/api/v1-3/feeds';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<NewsListFeeds, void>(
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<NewsListFeeds> addFeed({
Future<DynamiteResponse<NewsListFeeds, void>> addFeed({
required final String url,
final int? folderId,
}) async {
final rawResponse = addFeedRaw(
url: url,
folderId: folderId,
);
return rawResponse.future;
}
DynamiteRawResponse<NewsListFeeds, void> addFeedRaw({
required final String url,
final int? folderId,
}) {
const path = '/index.php/apps/news/api/v1-3/feeds';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<NewsListFeeds, void>(
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<void> deleteFeed({required final int feedId}) async {
Future<DynamiteResponse<void, void>> deleteFeed({required final int feedId}) async {
final rawResponse = deleteFeedRaw(
feedId: feedId,
);
return rawResponse.future;
}
DynamiteRawResponse<void, void> deleteFeedRaw({required final int feedId}) {
var path = '/index.php/apps/news/api/v1-3/feeds/{feedId}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
@ -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<void, void>(
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<void> moveFeed({
Future<DynamiteResponse<void, void>> moveFeed({
required final int feedId,
final int? folderId,
}) async {
final rawResponse = moveFeedRaw(
feedId: feedId,
folderId: folderId,
);
return rawResponse.future;
}
DynamiteRawResponse<void, void> moveFeedRaw({
required final int feedId,
final int? folderId,
}) {
var path = '/index.php/apps/news/api/v1-3/feeds/{feedId}/move';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
@ -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<void, void>(
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<void> renameFeed({
Future<DynamiteResponse<void, void>> renameFeed({
required final int feedId,
required final String feedTitle,
}) async {
final rawResponse = renameFeedRaw(
feedId: feedId,
feedTitle: feedTitle,
);
return rawResponse.future;
}
DynamiteRawResponse<void, void> renameFeedRaw({
required final int feedId,
required final String feedTitle,
}) {
var path = '/index.php/apps/news/api/v1-3/feeds/{feedId}/rename';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
@ -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<void, void>(
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<void> markFeedAsRead({
Future<DynamiteResponse<void, void>> markFeedAsRead({
required final int feedId,
required final int newestItemId,
}) async {
final rawResponse = markFeedAsReadRaw(
feedId: feedId,
newestItemId: newestItemId,
);
return rawResponse.future;
}
DynamiteRawResponse<void, void> markFeedAsReadRaw({
required final int feedId,
required final int newestItemId,
}) {
var path = '/index.php/apps/news/api/v1-3/feeds/{feedId}/read';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
@ -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<void, void>(
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<NewsListArticles> listArticles({
Future<DynamiteResponse<NewsListArticles, void>> 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<NewsListArticles, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<NewsListArticles, void>(
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<NewsListArticles> listUpdatedArticles({
Future<DynamiteResponse<NewsListArticles, void>> 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<NewsListArticles, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<NewsListArticles, void>(
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<void> markArticleAsRead({required final int itemId}) async {
Future<DynamiteResponse<void, void>> markArticleAsRead({required final int itemId}) async {
final rawResponse = markArticleAsReadRaw(
itemId: itemId,
);
return rawResponse.future;
}
DynamiteRawResponse<void, void> markArticleAsReadRaw({required final int itemId}) {
var path = '/index.php/apps/news/api/v1-3/items/{itemId}/read';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
@ -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<void, void>(
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<void> markArticleAsUnread({required final int itemId}) async {
Future<DynamiteResponse<void, void>> markArticleAsUnread({required final int itemId}) async {
final rawResponse = markArticleAsUnreadRaw(
itemId: itemId,
);
return rawResponse.future;
}
DynamiteRawResponse<void, void> markArticleAsUnreadRaw({required final int itemId}) {
var path = '/index.php/apps/news/api/v1-3/items/{itemId}/unread';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
@ -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<void, void>(
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<void> starArticle({required final int itemId}) async {
Future<DynamiteResponse<void, void>> starArticle({required final int itemId}) async {
final rawResponse = starArticleRaw(
itemId: itemId,
);
return rawResponse.future;
}
DynamiteRawResponse<void, void> starArticleRaw({required final int itemId}) {
var path = '/index.php/apps/news/api/v1-3/items/{itemId}/star';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
@ -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<void, void>(
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<void> unstarArticle({required final int itemId}) async {
Future<DynamiteResponse<void, void>> unstarArticle({required final int itemId}) async {
final rawResponse = unstarArticleRaw(
itemId: itemId,
);
return rawResponse.future;
}
DynamiteRawResponse<void, void> unstarArticleRaw({required final int itemId}) {
var path = '/index.php/apps/news/api/v1-3/items/{itemId}/unstar';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
@ -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<void, void>(
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<JsonObject>.new))
.build();
Serializers get newsSerializers => _serializers;
final Serializers _jsonSerializers = (_serializers.toBuilder()
..addPlugin(StandardJsonPlugin())
..addPlugin(const ContentStringPlugin()))
.build();
T deserializeNews<T>(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;
Object? serializeNews<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

272
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<BuiltList<NotesNote>> getNotes({
Future<DynamiteResponse<BuiltList<NotesNote>, 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<BuiltList<NotesNote>, 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<BuiltList<NotesNote>, 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<NotesNote>;
}
throw await DynamiteApiException.fromResponse(response); // coverage:ignore-line
}
Future<NotesNote> createNote({
Future<DynamiteResponse<NotesNote, void>> 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<NotesNote, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<NotesNote, void>(
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<NotesNote> getNote({
Future<DynamiteResponse<NotesNote, void>> 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<NotesNote, void> getNoteRaw({
required final int id,
final String exclude = '',
final String? ifNoneMatch,
}) {
var path = '/index.php/apps/notes/api/v1/notes/{id}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<NotesNote, void>(
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<NotesNote> updateNote({
Future<DynamiteResponse<NotesNote, void>> 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<NotesNote, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<NotesNote, void>(
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<String> deleteNote({required final int id}) async {
Future<DynamiteResponse<String, void>> deleteNote({required final int id}) async {
final rawResponse = deleteNoteRaw(
id: id,
);
return rawResponse.future;
}
DynamiteRawResponse<String, void> deleteNoteRaw({required final int id}) {
var path = '/index.php/apps/notes/api/v1/notes/{id}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<String, void>(
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<NotesSettings> getSettings() async {
Future<DynamiteResponse<NotesSettings, void>> getSettings() async {
final rawResponse = getSettingsRaw();
return rawResponse.future;
}
DynamiteRawResponse<NotesSettings, void> getSettingsRaw() {
const path = '/index.php/apps/notes/api/v1/settings';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<NotesSettings, void>(
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<NotesSettings> updateSettings({required final NotesSettings settings}) async {
Future<DynamiteResponse<NotesSettings, void>> updateSettings({required final NotesSettings settings}) async {
final rawResponse = updateSettingsRaw(
settings: settings,
);
return rawResponse.future;
}
DynamiteRawResponse<NotesSettings, void> updateSettingsRaw({required final NotesSettings settings}) {
const path = '/index.php/apps/notes/api/v1/settings';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<NotesSettings, void>(
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<JsonObject>.new))
.build();
Serializers get notesSerializers => _serializers;
final Serializers _jsonSerializers = (_serializers.toBuilder()
..addPlugin(StandardJsonPlugin())
..addPlugin(const ContentStringPlugin()))
.build();
T deserializeNotes<T>(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;
Object? serializeNotes<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

444
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<NotificationsApiGenerateNotificationResponseApplicationJson> generateNotification({
Future<DynamiteResponse<NotificationsApiGenerateNotificationResponseApplicationJson, void>> 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<NotificationsApiGenerateNotificationResponseApplicationJson, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<NotificationsApiGenerateNotificationResponseApplicationJson, void>(
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<NotificationsEndpointListNotificationsResponseApplicationJson,
NotificationsEndpointEndpointListNotificationsHeaders> listNotificationsRaw({
final NotificationsEndpointListNotificationsApiVersion apiVersion =
NotificationsEndpointListNotificationsApiVersion.v2,
final String oCSAPIRequest = 'true',
}) {
var path = '/ocs/v2.php/apps/notifications/api/{apiVersion}/notifications';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<NotificationsEndpointListNotificationsResponseApplicationJson,
NotificationsEndpointEndpointListNotificationsHeaders>(
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<NotificationsEndpointListNotificationsResponseApplicationJson,
NotificationsEndpointEndpointListNotificationsHeaders>(
_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<NotificationsEndpointDeleteAllNotificationsResponseApplicationJson> deleteAllNotifications({
Future<DynamiteResponse<NotificationsEndpointDeleteAllNotificationsResponseApplicationJson, void>>
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<NotificationsEndpointDeleteAllNotificationsResponseApplicationJson, void>
deleteAllNotificationsRaw({
final NotificationsEndpointDeleteAllNotificationsApiVersion apiVersion =
NotificationsEndpointDeleteAllNotificationsApiVersion.v2,
final String oCSAPIRequest = 'true',
}) {
var path = '/ocs/v2.php/apps/notifications/api/{apiVersion}/notifications';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<NotificationsEndpointDeleteAllNotificationsResponseApplicationJson, void>(
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<NotificationsEndpointGetNotificationResponseApplicationJson> getNotification({
Future<DynamiteResponse<NotificationsEndpointGetNotificationResponseApplicationJson, void>> 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<NotificationsEndpointGetNotificationResponseApplicationJson, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<NotificationsEndpointGetNotificationResponseApplicationJson, void>(
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<NotificationsEndpointDeleteNotificationResponseApplicationJson> deleteNotification({
Future<DynamiteResponse<NotificationsEndpointDeleteNotificationResponseApplicationJson, void>> 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<NotificationsEndpointDeleteNotificationResponseApplicationJson, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<NotificationsEndpointDeleteNotificationResponseApplicationJson, void>(
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<NotificationsEndpointConfirmIdsForUserResponseApplicationJson> confirmIdsForUser({
Future<DynamiteResponse<NotificationsEndpointConfirmIdsForUserResponseApplicationJson, void>> confirmIdsForUser({
required final List<int> 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<NotificationsEndpointConfirmIdsForUserResponseApplicationJson, void> confirmIdsForUserRaw({
required final List<int> ids,
final NotificationsEndpointConfirmIdsForUserApiVersion apiVersion =
NotificationsEndpointConfirmIdsForUserApiVersion.v2,
final String oCSAPIRequest = 'true',
}) {
var path = '/ocs/v2.php/apps/notifications/api/{apiVersion}/notifications/exists';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<NotificationsEndpointConfirmIdsForUserResponseApplicationJson, void>(
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<NotificationsPushRegisterDeviceResponseApplicationJson> registerDevice({
Future<DynamiteResponse<NotificationsPushRegisterDeviceResponseApplicationJson, void>> 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<NotificationsPushRegisterDeviceResponseApplicationJson, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<NotificationsPushRegisterDeviceResponseApplicationJson, void>(
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<NotificationsPushRemoveDeviceResponseApplicationJson> removeDevice({
Future<DynamiteResponse<NotificationsPushRemoveDeviceResponseApplicationJson, void>> 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<NotificationsPushRemoveDeviceResponseApplicationJson, void> removeDeviceRaw({
final NotificationsPushRemoveDeviceApiVersion apiVersion = NotificationsPushRemoveDeviceApiVersion.v2,
final String oCSAPIRequest = 'true',
}) {
var path = '/ocs/v2.php/apps/notifications/api/{apiVersion}/push';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<NotificationsPushRemoveDeviceResponseApplicationJson, void>(
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<NotificationsSettingsPersonalResponseApplicationJson> personal({
Future<DynamiteResponse<NotificationsSettingsPersonalResponseApplicationJson, void>> 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<NotificationsSettingsPersonalResponseApplicationJson, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<NotificationsSettingsPersonalResponseApplicationJson, void>(
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<NotificationsSettingsAdminResponseApplicationJson> admin({
Future<DynamiteResponse<NotificationsSettingsAdminResponseApplicationJson, void>> 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<NotificationsSettingsAdminResponseApplicationJson, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<NotificationsSettingsAdminResponseApplicationJson, void>(
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<String>.new))
.build();
Serializers get notificationsSerializers => _serializers;
final Serializers _jsonSerializers = (_serializers.toBuilder()
..addPlugin(StandardJsonPlugin())
..addPlugin(const ContentStringPlugin()))
.build();
T deserializeNotifications<T>(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;
Object? serializeNotifications<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

1889
packages/nextcloud/lib/src/api/provisioning_api.openapi.dart

File diff suppressed because it is too large Load Diff

43
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<DynamiteResponse<Uint8List, SettingsLogSettingsLogSettingsDownloadHeaders>> download() async {
final rawResponse = downloadRaw();
return rawResponse.future;
}
/// download logfile
///
/// This endpoint requires admin access
DynamiteRawResponse<Uint8List, SettingsLogSettingsLogSettingsDownloadHeaders> downloadRaw() {
const path = '/index.php/settings/admin/log/download';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<Uint8List, SettingsLogSettingsLogSettingsDownloadHeaders>(
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<Uint8List, SettingsLogSettingsLogSettingsDownloadHeaders>(
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<T>(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;
Object? serializeSettings<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

7
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<T>(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;
Object? serializeSharebymail<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

426
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<Uint8List> getFavicon({final String app = 'core'}) async {
Future<DynamiteResponse<Uint8List, void>> getFavicon({final String app = 'core'}) async {
final rawResponse = getFaviconRaw(
app: app,
);
return rawResponse.future;
}
/// Return a 32x32 favicon as png
DynamiteRawResponse<Uint8List, void> getFaviconRaw({final String app = 'core'}) {
var path = '/index.php/apps/theming/favicon/{app}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<Uint8List, void>(
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<Uint8List> getTouchIcon({final String app = 'core'}) async {
Future<DynamiteResponse<Uint8List, void>> getTouchIcon({final String app = 'core'}) async {
final rawResponse = getTouchIconRaw(
app: app,
);
return rawResponse.future;
}
/// Return a 512x512 icon for touch devices
DynamiteRawResponse<Uint8List, void> getTouchIconRaw({final String app = 'core'}) {
var path = '/index.php/apps/theming/icon/{app}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<Uint8List, void>(
response: _rootClient.doRequest(
'get',
uri,
headers,
body,
const {200},
),
bodyType: const FullType(Uint8List),
headersType: null,
serializers: _jsonSerializers,
);
}
/// Get a themed icon
Future<Uint8List> getThemedIcon({
Future<DynamiteResponse<Uint8List, void>> 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<Uint8List, void> getThemedIconRaw({
required final String app,
required final String image,
}) {
var path = '/index.php/apps/theming/img/{app}/{image}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<Uint8List, void>(
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<String> getThemeStylesheet({
Future<DynamiteResponse<String, void>> 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<String, void> getThemeStylesheetRaw({
required final String themeId,
final int plain = 0,
final int withCustomCss = 0,
}) {
var path = '/index.php/apps/theming/theme/{themeId}.css';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<String, void>(
response: _rootClient.doRequest(
'get',
uri,
headers,
body,
const {200},
),
bodyType: const FullType(String),
headersType: null,
serializers: _jsonSerializers,
);
}
/// Get an image
Future<Uint8List> getImage({
Future<DynamiteResponse<Uint8List, void>> getImage({
required final String key,
final int useSvg = 1,
}) async {
final rawResponse = getImageRaw(
key: key,
useSvg: useSvg,
);
return rawResponse.future;
}
/// Get an image
DynamiteRawResponse<Uint8List, void> getImageRaw({
required final String key,
final int useSvg = 1,
}) {
var path = '/index.php/apps/theming/image/{key}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<Uint8List, void>(
response: _rootClient.doRequest(
'get',
uri,
headers,
body,
const {200},
),
bodyType: const FullType(Uint8List),
headersType: null,
serializers: _jsonSerializers,
);
}
/// Get the manifest for an app
Future<DynamiteResponse<ThemingThemingGetManifestResponseApplicationJson, void>> getManifest({
required final String app,
}) async {
final rawResponse = getManifestRaw(
app: app,
);
return rawResponse.future;
}
/// Get the manifest for an app
Future<ThemingThemingGetManifestResponseApplicationJson> getManifest({required final String app}) async {
DynamiteRawResponse<ThemingThemingGetManifestResponseApplicationJson, void> getManifestRaw({
required final String app,
}) {
var path = '/index.php/apps/theming/manifest/{app}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<ThemingThemingGetManifestResponseApplicationJson, void>(
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<Uint8List> getBackground({final bool oCSAPIRequest = true}) async {
Future<DynamiteResponse<Uint8List, void>> getBackground({final bool oCSAPIRequest = true}) async {
final rawResponse = getBackgroundRaw(
oCSAPIRequest: oCSAPIRequest,
);
return rawResponse.future;
}
/// Get the background image
DynamiteRawResponse<Uint8List, void> getBackgroundRaw({final bool oCSAPIRequest = true}) {
const path = '/index.php/apps/theming/background';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<Uint8List, void>(
response: _rootClient.doRequest(
'get',
uri,
headers,
body,
const {200},
),
bodyType: const FullType(Uint8List),
headersType: null,
serializers: _jsonSerializers,
);
}
/// Set the background
Future<ThemingBackground> setBackground({
Future<DynamiteResponse<ThemingBackground, void>> 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<ThemingBackground, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<ThemingBackground, void>(
response: _rootClient.doRequest(
'post',
uri,
headers,
body,
const {200},
),
bodyType: const FullType(ThemingBackground),
headersType: null,
serializers: _jsonSerializers,
);
}
/// Delete the background
Future<ThemingBackground> deleteBackground({final bool oCSAPIRequest = true}) async {
Future<DynamiteResponse<ThemingBackground, void>> deleteBackground({final bool oCSAPIRequest = true}) async {
final rawResponse = deleteBackgroundRaw(
oCSAPIRequest: oCSAPIRequest,
);
return rawResponse.future;
}
/// Delete the background
DynamiteRawResponse<ThemingBackground, void> deleteBackgroundRaw({final bool oCSAPIRequest = true}) {
const path = '/index.php/apps/theming/background/custom';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<ThemingBackground, void>(
response: _rootClient.doRequest(
'delete',
uri,
headers,
body,
const {200},
),
bodyType: const FullType(ThemingBackground),
headersType: null,
serializers: _jsonSerializers,
);
}
/// Enable theme
Future<ThemingUserThemeEnableThemeResponseApplicationJson> enableTheme({
Future<DynamiteResponse<ThemingUserThemeEnableThemeResponseApplicationJson, void>> enableTheme({
required final String themeId,
final bool oCSAPIRequest = true,
}) async {
final rawResponse = enableThemeRaw(
themeId: themeId,
oCSAPIRequest: oCSAPIRequest,
);
return rawResponse.future;
}
/// Enable theme
DynamiteRawResponse<ThemingUserThemeEnableThemeResponseApplicationJson, void> enableThemeRaw({
required final String themeId,
final bool oCSAPIRequest = true,
}) {
var path = '/ocs/v2.php/apps/theming/api/v1/theme/{themeId}/enable';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<ThemingUserThemeEnableThemeResponseApplicationJson, void>(
response: _rootClient.doRequest(
'put',
uri,
headers,
body,
const {200},
),
bodyType: const FullType(ThemingUserThemeEnableThemeResponseApplicationJson),
headersType: null,
serializers: _jsonSerializers,
);
}
/// Disable theme
Future<ThemingUserThemeDisableThemeResponseApplicationJson> disableTheme({
Future<DynamiteResponse<ThemingUserThemeDisableThemeResponseApplicationJson, void>> disableTheme({
required final String themeId,
final bool oCSAPIRequest = true,
}) async {
final rawResponse = disableThemeRaw(
themeId: themeId,
oCSAPIRequest: oCSAPIRequest,
);
return rawResponse.future;
}
/// Disable theme
DynamiteRawResponse<ThemingUserThemeDisableThemeResponseApplicationJson, void> disableThemeRaw({
required final String themeId,
final bool oCSAPIRequest = true,
}) {
var path = '/ocs/v2.php/apps/theming/api/v1/theme/{themeId}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<ThemingUserThemeDisableThemeResponseApplicationJson, void>(
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<T>(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;
Object? serializeTheming<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

51
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<UpdatenotificationApiGetAppListResponseApplicationJson> getAppList({
Future<DynamiteResponse<UpdatenotificationApiGetAppListResponseApplicationJson, void>> 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<UpdatenotificationApiGetAppListResponseApplicationJson, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<UpdatenotificationApiGetAppListResponseApplicationJson, void>(
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<T>(final Object data) =>
_serializers.deserialize(data, specifiedType: FullType(T))! as T;
Object? serializeUpdatenotification<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

412
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<UppushCheckResponseApplicationJson> check() async {
Future<DynamiteResponse<UppushCheckResponseApplicationJson, void>> check() async {
final rawResponse = checkRaw();
return rawResponse.future;
}
/// Check if the UnifiedPush provider is present
DynamiteRawResponse<UppushCheckResponseApplicationJson, void> checkRaw() {
const path = '/index.php/apps/uppush';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<UppushCheckResponseApplicationJson, void>(
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<UppushSetKeepaliveResponseApplicationJson> setKeepalive({required final int keepalive}) async {
Future<DynamiteResponse<UppushSetKeepaliveResponseApplicationJson, void>> setKeepalive({
required final int keepalive,
}) async {
final rawResponse = setKeepaliveRaw(
keepalive: keepalive,
);
return rawResponse.future;
}
/// Set keepalive interval
///
/// This endpoint requires admin access
DynamiteRawResponse<UppushSetKeepaliveResponseApplicationJson, void> setKeepaliveRaw({required final int keepalive}) {
const path = '/index.php/apps/uppush/keepalive';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<UppushSetKeepaliveResponseApplicationJson, void>(
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<UppushCreateDeviceResponseApplicationJson> createDevice({required final String deviceName}) async {
Future<DynamiteResponse<UppushCreateDeviceResponseApplicationJson, void>> createDevice({
required final String deviceName,
}) async {
final rawResponse = createDeviceRaw(
deviceName: deviceName,
);
return rawResponse.future;
}
/// Request to create a new deviceId
DynamiteRawResponse<UppushCreateDeviceResponseApplicationJson, void> createDeviceRaw({
required final String deviceName,
}) {
const path = '/index.php/apps/uppush/device';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<UppushCreateDeviceResponseApplicationJson, void>(
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<UppushSyncDeviceResponseApplicationJson> syncDevice({required final String deviceId}) async {
Future<DynamiteResponse<UppushSyncDeviceResponseApplicationJson, void>> 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<UppushSyncDeviceResponseApplicationJson, void> syncDeviceRaw({required final String deviceId}) {
var path = '/index.php/apps/uppush/device/{deviceId}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<UppushSyncDeviceResponseApplicationJson, void>(
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<UppushDeleteDeviceResponseApplicationJson> deleteDevice({required final String deviceId}) async {
Future<DynamiteResponse<UppushDeleteDeviceResponseApplicationJson, void>> deleteDevice({
required final String deviceId,
}) async {
final rawResponse = deleteDeviceRaw(
deviceId: deviceId,
);
return rawResponse.future;
}
/// Delete a device
DynamiteRawResponse<UppushDeleteDeviceResponseApplicationJson, void> deleteDeviceRaw({
required final String deviceId,
}) {
var path = '/index.php/apps/uppush/device/{deviceId}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<UppushDeleteDeviceResponseApplicationJson, void>(
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<UppushCreateAppResponseApplicationJson> createApp({
Future<DynamiteResponse<UppushCreateAppResponseApplicationJson, void>> 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<UppushCreateAppResponseApplicationJson, void> createAppRaw({
required final String deviceId,
required final String appName,
}) {
const path = '/index.php/apps/uppush/app';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<UppushCreateAppResponseApplicationJson, void>(
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<UppushDeleteAppResponseApplicationJson> deleteApp({required final String token}) async {
Future<DynamiteResponse<UppushDeleteAppResponseApplicationJson, void>> deleteApp({
required final String token,
}) async {
final rawResponse = deleteAppRaw(
token: token,
);
return rawResponse.future;
}
/// Delete an authorization token
DynamiteRawResponse<UppushDeleteAppResponseApplicationJson, void> deleteAppRaw({required final String token}) {
var path = '/index.php/apps/uppush/app/{token}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<UppushDeleteAppResponseApplicationJson, void>(
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<UppushUnifiedpushDiscoveryResponseApplicationJson> unifiedpushDiscovery({required final String token}) async {
Future<DynamiteResponse<UppushUnifiedpushDiscoveryResponseApplicationJson, void>> unifiedpushDiscovery({
required final String token,
}) async {
final rawResponse = unifiedpushDiscoveryRaw(
token: token,
);
return rawResponse.future;
}
/// Unifiedpush discovery Following specifications
DynamiteRawResponse<UppushUnifiedpushDiscoveryResponseApplicationJson, void> unifiedpushDiscoveryRaw({
required final String token,
}) {
var path = '/index.php/apps/uppush/push/{token}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<UppushUnifiedpushDiscoveryResponseApplicationJson, void>(
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<UppushPushResponseApplicationJson> push({required final String token}) async {
Future<DynamiteResponse<UppushPushResponseApplicationJson, void>> push({required final String token}) async {
final rawResponse = pushRaw(
token: token,
);
return rawResponse.future;
}
/// Receive notifications from 3rd parties
DynamiteRawResponse<UppushPushResponseApplicationJson, void> pushRaw({required final String token}) {
var path = '/index.php/apps/uppush/push/{token}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<UppushPushResponseApplicationJson, void>(
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<UppushGatewayMatrixDiscoveryResponseApplicationJson> gatewayMatrixDiscovery() async {
Future<DynamiteResponse<UppushGatewayMatrixDiscoveryResponseApplicationJson, void>> gatewayMatrixDiscovery() async {
final rawResponse = gatewayMatrixDiscoveryRaw();
return rawResponse.future;
}
/// Matrix Gateway discovery
DynamiteRawResponse<UppushGatewayMatrixDiscoveryResponseApplicationJson, void> gatewayMatrixDiscoveryRaw() {
const path = '/index.php/apps/uppush/gateway/matrix';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<UppushGatewayMatrixDiscoveryResponseApplicationJson, void>(
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<UppushGatewayMatrixResponseApplicationJson> gatewayMatrix() async {
Future<DynamiteResponse<UppushGatewayMatrixResponseApplicationJson, void>> gatewayMatrix() async {
final rawResponse = gatewayMatrixRaw();
return rawResponse.future;
}
/// Matrix Gateway
DynamiteRawResponse<UppushGatewayMatrixResponseApplicationJson, void> gatewayMatrixRaw() {
const path = '/index.php/apps/uppush/gateway/matrix';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<UppushGatewayMatrixResponseApplicationJson, void>(
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<String>.new))
.build();
Serializers get uppushSerializers => _serializers;
final Serializers _jsonSerializers = (_serializers.toBuilder()
..addPlugin(StandardJsonPlugin())
..addPlugin(const ContentStringPlugin()))
.build();
T deserializeUppush<T>(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;
Object? serializeUppush<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

403
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<UserStatusHeartbeatHeartbeatResponseApplicationJson> heartbeat({
Future<DynamiteResponse<UserStatusHeartbeatHeartbeatResponseApplicationJson, void>> 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<UserStatusHeartbeatHeartbeatResponseApplicationJson, void> heartbeatRaw({
required final String status,
final bool oCSAPIRequest = true,
}) {
const path = '/ocs/v2.php/apps/user_status/api/v1/heartbeat';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<UserStatusHeartbeatHeartbeatResponseApplicationJson, void>(
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<UserStatusPredefinedStatusFindAllResponseApplicationJson> findAll({final bool oCSAPIRequest = true}) async {
Future<DynamiteResponse<UserStatusPredefinedStatusFindAllResponseApplicationJson, void>> findAll({
final bool oCSAPIRequest = true,
}) async {
final rawResponse = findAllRaw(
oCSAPIRequest: oCSAPIRequest,
);
return rawResponse.future;
}
/// Get all predefined messages
DynamiteRawResponse<UserStatusPredefinedStatusFindAllResponseApplicationJson, void> findAllRaw({
final bool oCSAPIRequest = true,
}) {
const path = '/ocs/v2.php/apps/user_status/api/v1/predefined_statuses';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<UserStatusPredefinedStatusFindAllResponseApplicationJson, void>(
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<UserStatusStatusesFindAllResponseApplicationJson> findAll({
Future<DynamiteResponse<UserStatusStatusesFindAllResponseApplicationJson, void>> 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<UserStatusStatusesFindAllResponseApplicationJson, void> findAllRaw({
final int? limit,
final int? offset,
final bool oCSAPIRequest = true,
}) {
const path = '/ocs/v2.php/apps/user_status/api/v1/statuses';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<UserStatusStatusesFindAllResponseApplicationJson, void>(
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<UserStatusStatusesFindResponseApplicationJson> find({
Future<DynamiteResponse<UserStatusStatusesFindResponseApplicationJson, void>> 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<UserStatusStatusesFindResponseApplicationJson, void> findRaw({
required final String userId,
final bool oCSAPIRequest = true,
}) {
var path = '/ocs/v2.php/apps/user_status/api/v1/statuses/{userId}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<UserStatusStatusesFindResponseApplicationJson, void>(
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<UserStatusUserStatusGetStatusResponseApplicationJson> getStatus({final bool oCSAPIRequest = true}) async {
Future<DynamiteResponse<UserStatusUserStatusGetStatusResponseApplicationJson, void>> getStatus({
final bool oCSAPIRequest = true,
}) async {
final rawResponse = getStatusRaw(
oCSAPIRequest: oCSAPIRequest,
);
return rawResponse.future;
}
/// Get the status of the current user
DynamiteRawResponse<UserStatusUserStatusGetStatusResponseApplicationJson, void> getStatusRaw({
final bool oCSAPIRequest = true,
}) {
const path = '/ocs/v2.php/apps/user_status/api/v1/user_status';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<UserStatusUserStatusGetStatusResponseApplicationJson, void>(
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<UserStatusUserStatusSetStatusResponseApplicationJson> setStatus({
Future<DynamiteResponse<UserStatusUserStatusSetStatusResponseApplicationJson, void>> 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<UserStatusUserStatusSetStatusResponseApplicationJson, void> setStatusRaw({
required final String statusType,
final bool oCSAPIRequest = true,
}) {
const path = '/ocs/v2.php/apps/user_status/api/v1/user_status/status';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<UserStatusUserStatusSetStatusResponseApplicationJson, void>(
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<UserStatusUserStatusSetPredefinedMessageResponseApplicationJson> setPredefinedMessage({
Future<DynamiteResponse<UserStatusUserStatusSetPredefinedMessageResponseApplicationJson, void>> 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<UserStatusUserStatusSetPredefinedMessageResponseApplicationJson, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<UserStatusUserStatusSetPredefinedMessageResponseApplicationJson, void>(
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<UserStatusUserStatusSetCustomMessageResponseApplicationJson> setCustomMessage({
Future<DynamiteResponse<UserStatusUserStatusSetCustomMessageResponseApplicationJson, void>> 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<UserStatusUserStatusSetCustomMessageResponseApplicationJson, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<UserStatusUserStatusSetCustomMessageResponseApplicationJson, void>(
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<UserStatusUserStatusClearMessageResponseApplicationJson> clearMessage({
Future<DynamiteResponse<UserStatusUserStatusClearMessageResponseApplicationJson, void>> clearMessage({
final bool oCSAPIRequest = true,
}) async {
final rawResponse = clearMessageRaw(
oCSAPIRequest: oCSAPIRequest,
);
return rawResponse.future;
}
/// Clear the message of the current user
DynamiteRawResponse<UserStatusUserStatusClearMessageResponseApplicationJson, void> clearMessageRaw({
final bool oCSAPIRequest = true,
}) {
const path = '/ocs/v2.php/apps/user_status/api/v1/user_status/message';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<UserStatusUserStatusClearMessageResponseApplicationJson, void>(
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<UserStatusUserStatusRevertStatusResponseApplicationJson> revertStatus({
Future<DynamiteResponse<UserStatusUserStatusRevertStatusResponseApplicationJson, void>> 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<UserStatusUserStatusRevertStatusResponseApplicationJson, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<UserStatusUserStatusRevertStatusResponseApplicationJson, void>(
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<T>(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;
Object? serializeUserStatus<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

277
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<WeatherStatusWeatherStatusSetModeResponseApplicationJson> setMode({
Future<DynamiteResponse<WeatherStatusWeatherStatusSetModeResponseApplicationJson, void>> 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<WeatherStatusWeatherStatusSetModeResponseApplicationJson, void> setModeRaw({
required final int mode,
final bool oCSAPIRequest = true,
}) {
const path = '/ocs/v2.php/apps/weather_status/api/v1/mode';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<WeatherStatusWeatherStatusSetModeResponseApplicationJson, void>(
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<WeatherStatusWeatherStatusUsePersonalAddressResponseApplicationJson> usePersonalAddress({
Future<DynamiteResponse<WeatherStatusWeatherStatusUsePersonalAddressResponseApplicationJson, void>>
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<WeatherStatusWeatherStatusUsePersonalAddressResponseApplicationJson, void> usePersonalAddressRaw({
final bool oCSAPIRequest = true,
}) async {
}) {
const path = '/ocs/v2.php/apps/weather_status/api/v1/use-personal';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<WeatherStatusWeatherStatusUsePersonalAddressResponseApplicationJson, void>(
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<WeatherStatusWeatherStatusGetLocationResponseApplicationJson> getLocation({
Future<DynamiteResponse<WeatherStatusWeatherStatusGetLocationResponseApplicationJson, void>> getLocation({
final bool oCSAPIRequest = true,
}) async {
final rawResponse = getLocationRaw(
oCSAPIRequest: oCSAPIRequest,
);
return rawResponse.future;
}
/// Get stored user location
DynamiteRawResponse<WeatherStatusWeatherStatusGetLocationResponseApplicationJson, void> getLocationRaw({
final bool oCSAPIRequest = true,
}) {
const path = '/ocs/v2.php/apps/weather_status/api/v1/location';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<WeatherStatusWeatherStatusGetLocationResponseApplicationJson, void>(
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<WeatherStatusWeatherStatusSetLocationResponseApplicationJson> setLocation({
Future<DynamiteResponse<WeatherStatusWeatherStatusSetLocationResponseApplicationJson, void>> 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<WeatherStatusWeatherStatusSetLocationResponseApplicationJson, void> 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 = <String, dynamic>{};
final headers = <String, String>{
@ -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<WeatherStatusWeatherStatusSetLocationResponseApplicationJson, void>(
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<WeatherStatusWeatherStatusGetForecastResponseApplicationJson> getForecast({
Future<DynamiteResponse<WeatherStatusWeatherStatusGetForecastResponseApplicationJson, void>> getForecast({
final bool oCSAPIRequest = true,
}) async {
final rawResponse = getForecastRaw(
oCSAPIRequest: oCSAPIRequest,
);
return rawResponse.future;
}
/// Get forecast for current location
DynamiteRawResponse<WeatherStatusWeatherStatusGetForecastResponseApplicationJson, void> getForecastRaw({
final bool oCSAPIRequest = true,
}) {
const path = '/ocs/v2.php/apps/weather_status/api/v1/forecast';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<WeatherStatusWeatherStatusGetForecastResponseApplicationJson, void>(
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<WeatherStatusWeatherStatusGetFavoritesResponseApplicationJson> getFavorites({
Future<DynamiteResponse<WeatherStatusWeatherStatusGetFavoritesResponseApplicationJson, void>> getFavorites({
final bool oCSAPIRequest = true,
}) async {
final rawResponse = getFavoritesRaw(
oCSAPIRequest: oCSAPIRequest,
);
return rawResponse.future;
}
/// Get favorites list
DynamiteRawResponse<WeatherStatusWeatherStatusGetFavoritesResponseApplicationJson, void> getFavoritesRaw({
final bool oCSAPIRequest = true,
}) {
const path = '/ocs/v2.php/apps/weather_status/api/v1/favorites';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<WeatherStatusWeatherStatusGetFavoritesResponseApplicationJson, void>(
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<WeatherStatusWeatherStatusSetFavoritesResponseApplicationJson> setFavorites({
Future<DynamiteResponse<WeatherStatusWeatherStatusSetFavoritesResponseApplicationJson, void>> setFavorites({
required final List<String> favorites,
final bool oCSAPIRequest = true,
}) async {
final rawResponse = setFavoritesRaw(
favorites: favorites,
oCSAPIRequest: oCSAPIRequest,
);
return rawResponse.future;
}
/// Set favorites list
DynamiteRawResponse<WeatherStatusWeatherStatusSetFavoritesResponseApplicationJson, void> setFavoritesRaw({
required final List<String> favorites,
final bool oCSAPIRequest = true,
}) {
const path = '/ocs/v2.php/apps/weather_status/api/v1/favorites';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
@ -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<WeatherStatusWeatherStatusSetFavoritesResponseApplicationJson, void>(
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<T>(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;
Object? serializeWeatherStatus<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

44
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<T>(final Object data) => serializers.deserialize(data, specifiedType: FullType(T))! as T;
// ignore: public_member_api_docs
Object? serializeNextcloud<T>(final T data) => serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

4
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,
);
}

6
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<WebDavMultistatus> _parseResponse(final HttpClientResponse response) async =>
WebDavMultistatus.fromXmlElement(xml.XmlDocument.parse(await response.body).rootElement);
WebDavMultistatus.fromXmlElement(xml.XmlDocument.parse(await response.string).rootElement);
Map<String, String> _getUploadHeaders({
required final DateTime? lastModified,
@ -205,7 +205,7 @@ class WebDavClient {
);
/// Gets the content of the file at [path].
Future<Uint8List> get(final Uri path) async => (await getStream(path)).bodyBytes;
Future<Uint8List> get(final Uri path) async => (await getStream(path)).bytes;
/// Gets the content of the file at [path].
Future<HttpClientResponse> getStream(final Uri path) async => _send(

179
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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,

10
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));
});
});

259
packages/nextcloud/test/news_test.dart

@ -26,12 +26,13 @@ void main() {
});
tearDown(() => container.destroy());
Future<NewsListFeeds> addWikipediaFeed([final int? folderID]) async => client.news.addFeed(
Future<DynamiteResponse<NewsListFeeds, void>> addWikipediaFeed([final int? folderID]) async =>
client.news.addFeed(
url: 'http://host.docker.internal:${rssServer.port}/wikipedia.xml',
folderId: folderID,
);
Future<NewsListFeeds> addNasaFeed() async => client.news.addFeed(
Future<DynamiteResponse<NewsListFeeds, void>> 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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
response = await client.news.listArticles(type: NewsListType.unread.index);
expect(response.statusCode, 200);
expect(() => response.headers, isA<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
final starredArticles = response.body.items.length;
expect(starredArticles, 0);
response = await client.news.listArticles();
expect(response.statusCode, 200);
expect(() => response.headers, isA<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
expect(response.body.items, hasLength(0));
});
},
retry: retryCount,

117
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
expect(response.body.notesPath, 'Test Notes');
expect(response.body.fileSuffix, '.txt');
expect(response.body.noteMode, NotesSettings_NoteMode.preview);
});
},
retry: retryCount,

40
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<void>());
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));

36
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<void>());
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<void>());
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<void>());
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<void>());
expect(app.body.ocs.data.id, isNotEmpty);
}
});
});

5
packages/nextcloud/test/settings_test.dart

@ -22,8 +22,9 @@ Future<void> 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());
});
});
}

43
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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

165
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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<void>());
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,

Loading…
Cancel
Save