// ignore_for_file: camel_case_types // ignore_for_file: public_member_api_docs import 'dart:convert'; import 'dart:typed_data'; import 'package:built_collection/built_collection.dart'; import 'package:built_value/built_value.dart'; import 'package:built_value/json_object.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; import 'package:dynamite_runtime/content_string.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:universal_io/io.dart'; export 'package:dynamite_runtime/http_client.dart'; part 'notes.openapi.g.dart'; class NotesResponse extends DynamiteResponse { NotesResponse( super.data, super.headers, ); @override String toString() => 'NotesResponse(data: $data, headers: $headers)'; } class NotesApiException extends DynamiteApiException { NotesApiException( super.statusCode, super.headers, super.body, ); static Future fromResponse(final HttpClientResponse response) async { String body; try { body = await response.body; } on FormatException { body = 'binary'; } return NotesApiException( response.statusCode, response.responseHeaders, body, ); } @override String toString() => 'NotesApiException(statusCode: $statusCode, headers: $headers, body: $body)'; } class NotesClient extends DynamiteClient { NotesClient( super.baseURL, { super.baseHeaders, super.userAgent, super.httpClient, super.cookieJar, super.authentications, }); NotesClient.fromClient(final DynamiteClient client) : super( client.baseURL, baseHeaders: client.baseHeaders, httpClient: client.httpClient, cookieJar: client.cookieJar, authentications: client.authentications, ); Future> getNotes({ final String? category, final String exclude = '', final int pruneBefore = 0, final int chunkSize = 0, final String? chunkCursor, final String? ifNoneMatch, }) async { const path = '/index.php/apps/notes/api/v1/notes'; final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; // coverage:ignore-start if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); } else { throw Exception('Missing authentication for basic_auth'); } // coverage:ignore-end if (category != null) { queryParameters['category'] = category; } if (exclude != '') { queryParameters['exclude'] = exclude; } if (pruneBefore != 0) { queryParameters['pruneBefore'] = pruneBefore.toString(); } if (chunkSize != 0) { queryParameters['chunkSize'] = chunkSize.toString(); } if (chunkCursor != null) { queryParameters['chunkCursor'] = chunkCursor; } if (ifNoneMatch != null) { headers['If-None-Match'] = ifNoneMatch; } final response = await doRequest( 'get', Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), headers, body, ); if (response.statusCode == 200) { return _jsonSerializers.deserialize( await response.jsonBody, specifiedType: const FullType(BuiltList, [FullType(NotesNote)]), )! as BuiltList; } throw await NotesApiException.fromResponse(response); // coverage:ignore-line } Future createNote({ final String category = '', final String title = '', final String content = '', final int modified = 0, final int favorite = 0, }) async { const path = '/index.php/apps/notes/api/v1/notes'; final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; // coverage:ignore-start if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); } else { throw Exception('Missing authentication for basic_auth'); } // coverage:ignore-end if (category != '') { queryParameters['category'] = category; } if (title != '') { queryParameters['title'] = title; } if (content != '') { queryParameters['content'] = content; } if (modified != 0) { queryParameters['modified'] = modified.toString(); } if (favorite != 0) { queryParameters['favorite'] = favorite.toString(); } final response = await doRequest( 'post', Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), headers, body, ); if (response.statusCode == 200) { return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NotesNote))! as NotesNote; } throw await NotesApiException.fromResponse(response); // coverage:ignore-line } Future getNote({ required final int id, final String exclude = '', final String? ifNoneMatch, }) async { var path = '/index.php/apps/notes/api/v1/notes/{id}'; final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; // coverage:ignore-start if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); } else { throw Exception('Missing authentication for basic_auth'); } // coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); if (exclude != '') { queryParameters['exclude'] = exclude; } if (ifNoneMatch != null) { headers['If-None-Match'] = ifNoneMatch; } final response = await doRequest( 'get', Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), headers, body, ); if (response.statusCode == 200) { return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NotesNote))! as NotesNote; } throw await NotesApiException.fromResponse(response); // coverage:ignore-line } Future updateNote({ required final int id, final String? content, final int? modified, final String? title, final String? category, final int? favorite, final String? ifMatch, }) async { var path = '/index.php/apps/notes/api/v1/notes/{id}'; final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; // coverage:ignore-start if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); } else { throw Exception('Missing authentication for basic_auth'); } // coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); if (content != null) { queryParameters['content'] = content; } if (modified != null) { queryParameters['modified'] = modified.toString(); } if (title != null) { queryParameters['title'] = title; } if (category != null) { queryParameters['category'] = category; } if (favorite != null) { queryParameters['favorite'] = favorite.toString(); } if (ifMatch != null) { headers['If-Match'] = ifMatch; } final response = await doRequest( 'put', Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), headers, body, ); if (response.statusCode == 200) { return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NotesNote))! as NotesNote; } throw await NotesApiException.fromResponse(response); // coverage:ignore-line } Future deleteNote({required final int id}) async { var path = '/index.php/apps/notes/api/v1/notes/{id}'; final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; // coverage:ignore-start if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); } else { throw Exception('Missing authentication for basic_auth'); } // coverage:ignore-end path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); final response = await doRequest( 'delete', Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), headers, body, ); if (response.statusCode == 200) { return response.body; } throw await NotesApiException.fromResponse(response); // coverage:ignore-line } Future getSettings() async { const path = '/index.php/apps/notes/api/v1/settings'; final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; // coverage:ignore-start if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); } else { throw Exception('Missing authentication for basic_auth'); } // coverage:ignore-end final response = await doRequest( 'get', Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), headers, body, ); if (response.statusCode == 200) { return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NotesSettings))! as NotesSettings; } throw await NotesApiException.fromResponse(response); // coverage:ignore-line } Future updateSettings({required final NotesSettings settings}) async { const path = '/index.php/apps/notes/api/v1/settings'; final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; // coverage:ignore-start if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers); } else { throw Exception('Missing authentication for basic_auth'); } // coverage:ignore-end 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).toString(), headers, body, ); if (response.statusCode == 200) { return _jsonSerializers.deserialize(await response.jsonBody, specifiedType: const FullType(NotesSettings))! as NotesSettings; } throw await NotesApiException.fromResponse(response); // coverage:ignore-line } } abstract class NotesNote implements Built { factory NotesNote([final void Function(NotesNoteBuilder)? b]) = _$NotesNote; // coverage:ignore-start const NotesNote._(); // coverage:ignore-end // coverage:ignore-start factory NotesNote.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 int get id; String get etag; bool get readonly; String get content; String get title; String get category; bool get favorite; int get modified; bool get error; String get errorType; static Serializer get serializer => _$notesNoteSerializer; } class NotesSettings_NoteMode extends EnumClass { const NotesSettings_NoteMode._(super.name); static const NotesSettings_NoteMode edit = _$notesSettingsNoteModeEdit; static const NotesSettings_NoteMode preview = _$notesSettingsNoteModePreview; static const NotesSettings_NoteMode rich = _$notesSettingsNoteModeRich; // coverage:ignore-start static BuiltSet get values => _$notesSettingsNoteModeValues; // coverage:ignore-end static NotesSettings_NoteMode valueOf(final String name) => _$valueOfNotesSettings_NoteMode(name); static Serializer get serializer => _$notesSettingsNoteModeSerializer; } abstract class NotesSettings implements Built { factory NotesSettings([final void Function(NotesSettingsBuilder)? b]) = _$NotesSettings; // coverage:ignore-start const NotesSettings._(); // coverage:ignore-end // coverage:ignore-start factory NotesSettings.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 String get notesPath; String get fileSuffix; NotesSettings_NoteMode get noteMode; static Serializer get serializer => _$notesSettingsSerializer; } abstract class NotesCapabilities_Notes implements Built { factory NotesCapabilities_Notes([final void Function(NotesCapabilities_NotesBuilder)? b]) = _$NotesCapabilities_Notes; // coverage:ignore-start const NotesCapabilities_Notes._(); // coverage:ignore-end // coverage:ignore-start factory NotesCapabilities_Notes.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 @BuiltValueField(wireName: 'api_version') BuiltList? get apiVersion; String? get version; static Serializer get serializer => _$notesCapabilitiesNotesSerializer; } abstract class NotesCapabilities implements Built { factory NotesCapabilities([final void Function(NotesCapabilitiesBuilder)? b]) = _$NotesCapabilities; // coverage:ignore-start const NotesCapabilities._(); // coverage:ignore-end // coverage:ignore-start factory NotesCapabilities.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 NotesCapabilities_Notes get notes; static Serializer get serializer => _$notesCapabilitiesSerializer; } abstract class NotesOCSMeta implements Built { factory NotesOCSMeta([final void Function(NotesOCSMetaBuilder)? b]) = _$NotesOCSMeta; // coverage:ignore-start const NotesOCSMeta._(); // coverage:ignore-end // coverage:ignore-start factory NotesOCSMeta.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 String get status; int get statuscode; String? get message; String? get totalitems; String? get itemsperpage; static Serializer get serializer => _$notesOCSMetaSerializer; } abstract class NotesEmptyOCS_Ocs implements Built { factory NotesEmptyOCS_Ocs([final void Function(NotesEmptyOCS_OcsBuilder)? b]) = _$NotesEmptyOCS_Ocs; // coverage:ignore-start const NotesEmptyOCS_Ocs._(); // coverage:ignore-end // coverage:ignore-start factory NotesEmptyOCS_Ocs.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 NotesOCSMeta get meta; BuiltList get data; static Serializer get serializer => _$notesEmptyOCSOcsSerializer; } abstract class NotesEmptyOCS implements Built { factory NotesEmptyOCS([final void Function(NotesEmptyOCSBuilder)? b]) = _$NotesEmptyOCS; // coverage:ignore-start const NotesEmptyOCS._(); // coverage:ignore-end // coverage:ignore-start factory NotesEmptyOCS.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 NotesEmptyOCS_Ocs get ocs; static Serializer get serializer => _$notesEmptyOCSSerializer; } // coverage:ignore-start final Serializers _serializers = (Serializers().toBuilder() ..addBuilderFactory(const FullType(NotesNote), NotesNote.new) ..add(NotesNote.serializer) ..addBuilderFactory(const FullType(BuiltList, [FullType(NotesNote)]), ListBuilder.new) ..addBuilderFactory(const FullType(NotesSettings), NotesSettings.new) ..add(NotesSettings.serializer) ..add(NotesSettings_NoteMode.serializer) ..addBuilderFactory(const FullType(NotesCapabilities), NotesCapabilities.new) ..add(NotesCapabilities.serializer) ..addBuilderFactory(const FullType(NotesCapabilities_Notes), NotesCapabilities_Notes.new) ..add(NotesCapabilities_Notes.serializer) ..addBuilderFactory(const FullType(BuiltList, [FullType(String)]), ListBuilder.new) ..addBuilderFactory(const FullType(NotesOCSMeta), NotesOCSMeta.new) ..add(NotesOCSMeta.serializer) ..addBuilderFactory(const FullType(NotesEmptyOCS), NotesEmptyOCS.new) ..add(NotesEmptyOCS.serializer) ..addBuilderFactory(const FullType(NotesEmptyOCS_Ocs), NotesEmptyOCS_Ocs.new) ..add(NotesEmptyOCS_Ocs.serializer) ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonObject)]), ListBuilder.new)) .build(); Serializers get notesSerializers => _serializers; final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); T deserializeNotes(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; Object? serializeNotes(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end