From a91723672a46d2da0e95e572ab95eb209039df60 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Mon, 4 Sep 2023 20:29:55 +0200 Subject: [PATCH] refactor(nextcloud): Update comments API Signed-off-by: jld3103 --- external/nextcloud-server | 2 +- .../lib/src/api/comments.openapi.dart | 124 ------------------ .../lib/src/api/comments.openapi.g.dart | 89 ------------- .../lib/src/api/comments.openapi.json | 44 +------ 4 files changed, 2 insertions(+), 257 deletions(-) diff --git a/external/nextcloud-server b/external/nextcloud-server index cdea1d62..eb1b09da 160000 --- a/external/nextcloud-server +++ b/external/nextcloud-server @@ -1 +1 @@ -Subproject commit cdea1d62ba712b2c43fff51d8029674d10645842 +Subproject commit eb1b09da6728d300aecf65fb28d3d49e546a9bee diff --git a/packages/nextcloud/lib/src/api/comments.openapi.dart b/packages/nextcloud/lib/src/api/comments.openapi.dart index c130a18f..89186f15 100644 --- a/packages/nextcloud/lib/src/api/comments.openapi.dart +++ b/packages/nextcloud/lib/src/api/comments.openapi.dart @@ -1,6 +1,5 @@ // ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs -import 'dart:typed_data'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; @@ -67,124 +66,6 @@ class CommentsClient extends DynamiteClient { cookieJar: client.cookieJar, authentications: client.authentications, ); - - CommentsNotificationsClient get notifications => CommentsNotificationsClient(this); -} - -class CommentsNotificationsClient { - CommentsNotificationsClient(this._rootClient); - - final CommentsClient _rootClient; - - /// View a notification - Future view({required final String id}) async { - var path = '/index.php/apps/comments/notifications/view/{id}'; - final queryParameters = {}; - final headers = {}; - Uint8List? body; - // coverage:ignore-start - if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, - ); - } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { - headers.addAll( - _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, - ); - } - // coverage:ignore-end - path = path.replaceAll('{id}', Uri.encodeQueryComponent(id)); - final response = await _rootClient.doRequest( - 'get', - Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), - headers, - body, - ); - if (response.statusCode == 303) { - return _jsonSerializers.deserialize( - response.responseHeaders, - specifiedType: const FullType(CommentsNotificationsNotificationsViewHeaders), - )! as CommentsNotificationsNotificationsViewHeaders; - } - throw await CommentsApiException.fromResponse(response); // coverage:ignore-line - } -} - -@BuiltValue(instantiable: false) -abstract interface class CommentsNotificationsNotificationsViewHeadersInterface { - String? get location; - CommentsNotificationsNotificationsViewHeadersInterface rebuild( - final void Function(CommentsNotificationsNotificationsViewHeadersInterfaceBuilder) updates, - ); - CommentsNotificationsNotificationsViewHeadersInterfaceBuilder toBuilder(); -} - -abstract class CommentsNotificationsNotificationsViewHeaders - implements - CommentsNotificationsNotificationsViewHeadersInterface, - Built { - factory CommentsNotificationsNotificationsViewHeaders([ - final void Function(CommentsNotificationsNotificationsViewHeadersBuilder)? b, - ]) = _$CommentsNotificationsNotificationsViewHeaders; - - // coverage:ignore-start - const CommentsNotificationsNotificationsViewHeaders._(); - // coverage:ignore-end - - // coverage:ignore-start - factory CommentsNotificationsNotificationsViewHeaders.fromJson(final Map json) => - _jsonSerializers.deserializeWith(serializer, json)!; - // coverage:ignore-end - - // coverage:ignore-start - Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; - // coverage:ignore-end - @BuiltValueSerializer(custom: true) - static Serializer get serializer => - _$CommentsNotificationsNotificationsViewHeadersSerializer(); -} - -class _$CommentsNotificationsNotificationsViewHeadersSerializer - implements StructuredSerializer { - @override - final Iterable types = const [ - CommentsNotificationsNotificationsViewHeaders, - _$CommentsNotificationsNotificationsViewHeaders, - ]; - - @override - final String wireName = 'CommentsNotificationsNotificationsViewHeaders'; - - @override - Iterable serialize( - final Serializers serializers, - final CommentsNotificationsNotificationsViewHeaders object, { - final FullType specifiedType = FullType.unspecified, - }) { - throw UnimplementedError(); - } - - @override - CommentsNotificationsNotificationsViewHeaders deserialize( - final Serializers serializers, - final Iterable serialized, { - final FullType specifiedType = FullType.unspecified, - }) { - final result = CommentsNotificationsNotificationsViewHeadersBuilder(); - - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current! as String; - iterator.moveNext(); - final value = iterator.current! as String; - switch (key) { - case 'location': - result.location = value; - } - } - - return result.build(); - } } @BuiltValue(instantiable: false) @@ -244,11 +125,6 @@ abstract class CommentsCapabilities // coverage:ignore-start final Serializers _serializers = (Serializers().toBuilder() - ..addBuilderFactory( - const FullType(CommentsNotificationsNotificationsViewHeaders), - CommentsNotificationsNotificationsViewHeaders.new, - ) - ..add(CommentsNotificationsNotificationsViewHeaders.serializer) ..addBuilderFactory(const FullType(CommentsCapabilities), CommentsCapabilities.new) ..add(CommentsCapabilities.serializer) ..addBuilderFactory(const FullType(CommentsCapabilities_Files), CommentsCapabilities_Files.new) diff --git a/packages/nextcloud/lib/src/api/comments.openapi.g.dart b/packages/nextcloud/lib/src/api/comments.openapi.g.dart index 35fbaaf6..7bed4783 100644 --- a/packages/nextcloud/lib/src/api/comments.openapi.g.dart +++ b/packages/nextcloud/lib/src/api/comments.openapi.g.dart @@ -86,95 +86,6 @@ class _$CommentsCapabilitiesSerializer implements StructuredSerializer - (CommentsNotificationsNotificationsViewHeadersBuilder()..update(updates))._build(); - - _$CommentsNotificationsNotificationsViewHeaders._({this.location}) : super._(); - - @override - CommentsNotificationsNotificationsViewHeaders rebuild( - void Function(CommentsNotificationsNotificationsViewHeadersBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - CommentsNotificationsNotificationsViewHeadersBuilder toBuilder() => - CommentsNotificationsNotificationsViewHeadersBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is CommentsNotificationsNotificationsViewHeaders && location == other.location; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, location.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'CommentsNotificationsNotificationsViewHeaders')..add('location', location)) - .toString(); - } -} - -class CommentsNotificationsNotificationsViewHeadersBuilder - implements - Builder, - CommentsNotificationsNotificationsViewHeadersInterfaceBuilder { - _$CommentsNotificationsNotificationsViewHeaders? _$v; - - String? _location; - String? get location => _$this._location; - set location(covariant String? location) => _$this._location = location; - - CommentsNotificationsNotificationsViewHeadersBuilder(); - - CommentsNotificationsNotificationsViewHeadersBuilder get _$this { - final $v = _$v; - if ($v != null) { - _location = $v.location; - _$v = null; - } - return this; - } - - @override - void replace(covariant CommentsNotificationsNotificationsViewHeaders other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$CommentsNotificationsNotificationsViewHeaders; - } - - @override - void update(void Function(CommentsNotificationsNotificationsViewHeadersBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - CommentsNotificationsNotificationsViewHeaders build() => _build(); - - _$CommentsNotificationsNotificationsViewHeaders _build() { - final _$result = _$v ?? _$CommentsNotificationsNotificationsViewHeaders._(location: location); - replace(_$result); - return _$result; - } -} - abstract mixin class CommentsCapabilities_FilesInterfaceBuilder { void replace(CommentsCapabilities_FilesInterface other); void update(void Function(CommentsCapabilities_FilesInterfaceBuilder) updates); diff --git a/packages/nextcloud/lib/src/api/comments.openapi.json b/packages/nextcloud/lib/src/api/comments.openapi.json index f44ff3e2..aba16252 100644 --- a/packages/nextcloud/lib/src/api/comments.openapi.json +++ b/packages/nextcloud/lib/src/api/comments.openapi.json @@ -42,48 +42,6 @@ } } }, - "paths": { - "/index.php/apps/comments/notifications/view/{id}": { - "get": { - "operationId": "notifications-view", - "summary": "View a notification", - "tags": [ - "notifications" - ], - "security": [ - {}, - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of the notification", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "303": { - "description": "Redirected to notification", - "headers": { - "Location": { - "schema": { - "type": "string" - } - } - } - } - } - } - } - }, + "paths": {}, "tags": [] } \ No newline at end of file