From db924c0eebb40d9b13bcf2909aa7330da7b1b31c Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sat, 19 Nov 2022 22:08:56 +0100 Subject: [PATCH] dynamite,nextcloud: Cleanup merge mess --- .../dynamite/lib/src/openapi_builder.dart | 6 ----- .../nextcloud/lib/src/nextcloud.openapi.dart | 24 +++++++++++++++---- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/packages/dynamite/lib/src/openapi_builder.dart b/packages/dynamite/lib/src/openapi_builder.dart index 0ba2e9a9..572a904a 100644 --- a/packages/dynamite/lib/src/openapi_builder.dart +++ b/packages/dynamite/lib/src/openapi_builder.dart @@ -910,7 +910,6 @@ class OpenAPIBuilder implements Builder { for (final header in {...baseHeaders, ...headers}.entries) { request.headers.add(header.key, header.value); } -<<<<<<< Updated upstream if (body != null) { request.add(body.toList()); } @@ -927,11 +926,6 @@ class OpenAPIBuilder implements Builder { responseHeaders[name] = values.last; }); return Response( -======= - - final response = await http.Response.fromStream(await request.send()); - return _Response( ->>>>>>> Stashed changes response.statusCode, responseHeaders, await response.bodyBytes, diff --git a/packages/nextcloud/lib/src/nextcloud.openapi.dart b/packages/nextcloud/lib/src/nextcloud.openapi.dart index b52db6ef..9ed307d6 100644 --- a/packages/nextcloud/lib/src/nextcloud.openapi.dart +++ b/packages/nextcloud/lib/src/nextcloud.openapi.dart @@ -15,8 +15,22 @@ extension HttpClientResponseBody on HttpClientResponse { Future get body async => utf8.decode(await bodyBytes); } -class Response { +class Response { Response( + this.data, + this.headers, + ); + + final T data; + + final U headers; + + @override + String toString() => 'Response(data: $data, headers: $headers)'; +} + +class _Response { + _Response( this.statusCode, this.headers, this.body, @@ -29,17 +43,17 @@ class Response { final Uint8List body; @override - String toString() => 'Response(statusCode: $statusCode, headers: $headers, body: ${utf8.decode(body)})'; + String toString() => '_Response(statusCode: $statusCode, headers: $headers, body: ${utf8.decode(body)})'; } -class ApiException extends Response implements Exception { +class ApiException extends _Response implements Exception { ApiException( super.statusCode, super.headers, super.body, ); - factory ApiException.fromResponse(Response response) => ApiException( + factory ApiException.fromResponse(_Response response) => ApiException( response.statusCode, response.headers, response.body, @@ -104,7 +118,7 @@ class Client { NotificationsClient get notifications => NotificationsClient(this); ProvisioningApiClient get provisioningApi => ProvisioningApiClient(this); UserStatusClient get userStatus => UserStatusClient(this); - Future doRequest( + Future<_Response> doRequest( String method, String path, Map headers,