// 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'; 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:collection/collection.dart'; import 'package:dynamite_runtime/built_value.dart'; import 'package:dynamite_runtime/http_client.dart'; import 'package:meta/meta.dart'; import 'package:universal_io/io.dart'; part 'notes.openapi.g.dart'; class Client extends DynamiteClient { Client( super.baseURL, { super.baseHeaders, super.userAgent, super.httpClient, super.cookieJar, super.authentications, }); Client.fromClient(final DynamiteClient client) : super( client.baseURL, baseHeaders: client.baseHeaders, httpClient: client.httpClient, cookieJar: client.cookieJar, authentications: client.authentications, ); /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// /// Parameters: /// * [category] /// * [exclude] Defaults to `''`. /// * [pruneBefore] Defaults to `0`. /// * [chunkSize] Defaults to `0`. /// * [chunkCursor] /// * [ifNoneMatch] /// /// Status codes: /// * 200 /// /// See: /// * [getNotesRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future, void>> getNotes({ final String? category, final String exclude = '', final int pruneBefore = 0, final int chunkSize = 0, 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; } /// This method and the response it returns is experimental. The API might change without a major version bump. /// /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// /// Parameters: /// * [category] /// * [exclude] Defaults to `''`. /// * [pruneBefore] Defaults to `0`. /// * [chunkSize] Defaults to `0`. /// * [chunkCursor] /// * [ifNoneMatch] /// /// Status codes: /// * 200 /// /// See: /// * [getNotes] for an operation that returns a [DynamiteResponse] with a stable API. @experimental DynamiteRawResponse, void> getNotesRaw({ final String? category, final String exclude = '', final int pruneBefore = 0, final int chunkSize = 0, final String? chunkCursor, final String? ifNoneMatch, }) { final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; // coverage:ignore-start final authentication = authentications.firstWhereOrNull( (final auth) => switch (auth) { DynamiteHttpBasicAuthentication() => true, _ => false, }, ); if (authentication != null) { headers.addAll( authentication.headers, ); } else { throw Exception('Missing authentication for basic_auth'); } // coverage:ignore-end 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; } const path = '/index.php/apps/notes/api/v1/notes'; final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); return DynamiteRawResponse, void>( response: executeRequest( 'get', uri, headers, body, const {200}, ), bodyType: const FullType(BuiltList, [FullType(Note)]), headersType: null, serializers: _jsonSerializers, ); } /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// /// Parameters: /// * [category] Defaults to `''`. /// * [title] Defaults to `''`. /// * [content] Defaults to `''`. /// * [modified] Defaults to `0`. /// * [favorite] Defaults to `0`. /// /// Status codes: /// * 200 /// /// See: /// * [createNoteRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> createNote({ final String category = '', final String title = '', 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; } /// This method and the response it returns is experimental. The API might change without a major version bump. /// /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// /// Parameters: /// * [category] Defaults to `''`. /// * [title] Defaults to `''`. /// * [content] Defaults to `''`. /// * [modified] Defaults to `0`. /// * [favorite] Defaults to `0`. /// /// Status codes: /// * 200 /// /// See: /// * [createNote] for an operation that returns a [DynamiteResponse] with a stable API. @experimental DynamiteRawResponse createNoteRaw({ final String category = '', final String title = '', final String content = '', final int modified = 0, final int favorite = 0, }) { final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; // coverage:ignore-start final authentication = authentications.firstWhereOrNull( (final auth) => switch (auth) { DynamiteHttpBasicAuthentication() => true, _ => false, }, ); if (authentication != null) { headers.addAll( authentication.headers, ); } else { throw Exception('Missing authentication for basic_auth'); } // coverage:ignore-end 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(); } const path = '/index.php/apps/notes/api/v1/notes'; final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); return DynamiteRawResponse( response: executeRequest( 'post', uri, headers, body, const {200}, ), bodyType: const FullType(Note), headersType: null, serializers: _jsonSerializers, ); } /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// /// Parameters: /// * [exclude] Defaults to `''`. /// * [ifNoneMatch] /// /// Status codes: /// * 200 /// /// See: /// * [getNoteRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getNote({ required final int id, final String exclude = '', final String? ifNoneMatch, }) async { final rawResponse = getNoteRaw( id: id, exclude: exclude, ifNoneMatch: ifNoneMatch, ); return rawResponse.future; } /// This method and the response it returns is experimental. The API might change without a major version bump. /// /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// /// Parameters: /// * [exclude] Defaults to `''`. /// * [ifNoneMatch] /// /// Status codes: /// * 200 /// /// See: /// * [getNote] for an operation that returns a [DynamiteResponse] with a stable API. @experimental DynamiteRawResponse getNoteRaw({ required final int id, final String exclude = '', final String? ifNoneMatch, }) { final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; // coverage:ignore-start final authentication = authentications.firstWhereOrNull( (final auth) => switch (auth) { DynamiteHttpBasicAuthentication() => true, _ => false, }, ); if (authentication != null) { headers.addAll( authentication.headers, ); } else { throw Exception('Missing authentication for basic_auth'); } // coverage:ignore-end final id0 = Uri.encodeQueryComponent(id.toString()); if (exclude != '') { queryParameters['exclude'] = exclude; } if (ifNoneMatch != null) { headers['If-None-Match'] = ifNoneMatch; } final path = '/index.php/apps/notes/api/v1/notes/$id0'; final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); return DynamiteRawResponse( response: executeRequest( 'get', uri, headers, body, const {200}, ), bodyType: const FullType(Note), headersType: null, serializers: _jsonSerializers, ); } /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// /// Parameters: /// * [content] /// * [modified] /// * [title] /// * [category] /// * [favorite] /// * [ifMatch] /// /// Status codes: /// * 200 /// /// See: /// * [updateNoteRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> updateNote({ required final int id, final String? content, final int? modified, final String? title, final String? category, 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; } /// This method and the response it returns is experimental. The API might change without a major version bump. /// /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// /// Parameters: /// * [content] /// * [modified] /// * [title] /// * [category] /// * [favorite] /// * [ifMatch] /// /// Status codes: /// * 200 /// /// See: /// * [updateNote] for an operation that returns a [DynamiteResponse] with a stable API. @experimental DynamiteRawResponse updateNoteRaw({ required final int id, final String? content, final int? modified, final String? title, final String? category, final int? favorite, final String? ifMatch, }) { final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; // coverage:ignore-start final authentication = authentications.firstWhereOrNull( (final auth) => switch (auth) { DynamiteHttpBasicAuthentication() => true, _ => false, }, ); if (authentication != null) { headers.addAll( authentication.headers, ); } else { throw Exception('Missing authentication for basic_auth'); } // coverage:ignore-end final id0 = 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 path = '/index.php/apps/notes/api/v1/notes/$id0'; final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); return DynamiteRawResponse( response: executeRequest( 'put', uri, headers, body, const {200}, ), bodyType: const FullType(Note), headersType: null, serializers: _jsonSerializers, ); } /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// /// Status codes: /// * 200 /// /// See: /// * [deleteNoteRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> deleteNote({required final int id}) async { final rawResponse = deleteNoteRaw( id: id, ); return rawResponse.future; } /// This method and the response it returns is experimental. The API might change without a major version bump. /// /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// /// Status codes: /// * 200 /// /// See: /// * [deleteNote] for an operation that returns a [DynamiteResponse] with a stable API. @experimental DynamiteRawResponse deleteNoteRaw({required final int id}) { final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; // coverage:ignore-start final authentication = authentications.firstWhereOrNull( (final auth) => switch (auth) { DynamiteHttpBasicAuthentication() => true, _ => false, }, ); if (authentication != null) { headers.addAll( authentication.headers, ); } else { throw Exception('Missing authentication for basic_auth'); } // coverage:ignore-end final id0 = Uri.encodeQueryComponent(id.toString()); final path = '/index.php/apps/notes/api/v1/notes/$id0'; final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); return DynamiteRawResponse( response: executeRequest( 'delete', uri, headers, body, const {200}, ), bodyType: const FullType(String), headersType: null, serializers: _jsonSerializers, ); } /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// /// Status codes: /// * 200 /// /// See: /// * [getSettingsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> getSettings() async { final rawResponse = getSettingsRaw(); return rawResponse.future; } /// This method and the response it returns is experimental. The API might change without a major version bump. /// /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// /// Status codes: /// * 200 /// /// See: /// * [getSettings] for an operation that returns a [DynamiteResponse] with a stable API. @experimental DynamiteRawResponse getSettingsRaw() { final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; // coverage:ignore-start final authentication = authentications.firstWhereOrNull( (final auth) => switch (auth) { DynamiteHttpBasicAuthentication() => true, _ => false, }, ); if (authentication != null) { headers.addAll( authentication.headers, ); } else { throw Exception('Missing authentication for basic_auth'); } // coverage:ignore-end const path = '/index.php/apps/notes/api/v1/settings'; final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); return DynamiteRawResponse( response: executeRequest( 'get', uri, headers, body, const {200}, ), bodyType: const FullType(Settings), headersType: null, serializers: _jsonSerializers, ); } /// Returns a [Future] containing a [DynamiteResponse] with the status code, deserialized body and headers. /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// /// Status codes: /// * 200 /// /// See: /// * [updateSettingsRaw] for an experimental operation that returns a [DynamiteRawResponse] that can be serialized. Future> updateSettings({required final Settings settings}) async { final rawResponse = updateSettingsRaw( settings: settings, ); return rawResponse.future; } /// This method and the response it returns is experimental. The API might change without a major version bump. /// /// Returns a [Future] containing a [DynamiteRawResponse] with the raw [HttpClientResponse] and serialization helpers. /// Throws a [DynamiteApiException] if the API call does not return an expected status code. /// /// Status codes: /// * 200 /// /// See: /// * [updateSettings] for an operation that returns a [DynamiteResponse] with a stable API. @experimental DynamiteRawResponse updateSettingsRaw({required final Settings settings}) { final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; // coverage:ignore-start final authentication = authentications.firstWhereOrNull( (final auth) => switch (auth) { DynamiteHttpBasicAuthentication() => true, _ => false, }, ); if (authentication != null) { headers.addAll( authentication.headers, ); } else { throw Exception('Missing authentication for basic_auth'); } // coverage:ignore-end headers['Content-Type'] = 'application/json'; body = utf8.encode(json.encode(_jsonSerializers.serialize(settings, specifiedType: const FullType(Settings)))); const path = '/index.php/apps/notes/api/v1/settings'; final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null); return DynamiteRawResponse( response: executeRequest( 'put', uri, headers, body, const {200}, ), bodyType: const FullType(Settings), headersType: null, serializers: _jsonSerializers, ); } } @BuiltValue(instantiable: false) abstract interface class NoteInterface { 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; } abstract class Note implements NoteInterface, Built { factory Note([final void Function(NoteBuilder)? b]) = _$Note; // coverage:ignore-start const Note._(); // coverage:ignore-end // coverage:ignore-start factory Note.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 static Serializer get serializer => _$noteSerializer; } class Settings_NoteMode extends EnumClass { const Settings_NoteMode._(super.name); static const Settings_NoteMode edit = _$settingsNoteModeEdit; static const Settings_NoteMode preview = _$settingsNoteModePreview; static const Settings_NoteMode rich = _$settingsNoteModeRich; // coverage:ignore-start static BuiltSet get values => _$settingsNoteModeValues; // coverage:ignore-end static Settings_NoteMode valueOf(final String name) => _$valueOfSettings_NoteMode(name); static Serializer get serializer => _$settingsNoteModeSerializer; } @BuiltValue(instantiable: false) abstract interface class SettingsInterface { String get notesPath; String get fileSuffix; Settings_NoteMode get noteMode; } abstract class Settings implements SettingsInterface, Built { factory Settings([final void Function(SettingsBuilder)? b]) = _$Settings; // coverage:ignore-start const Settings._(); // coverage:ignore-end // coverage:ignore-start factory Settings.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 static Serializer get serializer => _$settingsSerializer; } @BuiltValue(instantiable: false) abstract interface class Capabilities_NotesInterface { @BuiltValueField(wireName: 'api_version') BuiltList? get apiVersion; String? get version; } abstract class Capabilities_Notes implements Capabilities_NotesInterface, Built { factory Capabilities_Notes([final void Function(Capabilities_NotesBuilder)? b]) = _$Capabilities_Notes; // coverage:ignore-start const Capabilities_Notes._(); // coverage:ignore-end // coverage:ignore-start factory Capabilities_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 static Serializer get serializer => _$capabilitiesNotesSerializer; } @BuiltValue(instantiable: false) abstract interface class CapabilitiesInterface { Capabilities_Notes get notes; } abstract class Capabilities implements CapabilitiesInterface, Built { factory Capabilities([final void Function(CapabilitiesBuilder)? b]) = _$Capabilities; // coverage:ignore-start const Capabilities._(); // coverage:ignore-end // coverage:ignore-start factory Capabilities.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 static Serializer get serializer => _$capabilitiesSerializer; } @BuiltValue(instantiable: false) abstract interface class OCSMetaInterface { String get status; int get statuscode; String? get message; String? get totalitems; String? get itemsperpage; } abstract class OCSMeta implements OCSMetaInterface, Built { factory OCSMeta([final void Function(OCSMetaBuilder)? b]) = _$OCSMeta; // coverage:ignore-start const OCSMeta._(); // coverage:ignore-end // coverage:ignore-start factory OCSMeta.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 static Serializer get serializer => _$oCSMetaSerializer; } @BuiltValue(instantiable: false) abstract interface class EmptyOCS_OcsInterface { OCSMeta get meta; BuiltList get data; } abstract class EmptyOCS_Ocs implements EmptyOCS_OcsInterface, Built { factory EmptyOCS_Ocs([final void Function(EmptyOCS_OcsBuilder)? b]) = _$EmptyOCS_Ocs; // coverage:ignore-start const EmptyOCS_Ocs._(); // coverage:ignore-end // coverage:ignore-start factory EmptyOCS_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 static Serializer get serializer => _$emptyOCSOcsSerializer; } @BuiltValue(instantiable: false) abstract interface class EmptyOCSInterface { EmptyOCS_Ocs get ocs; } abstract class EmptyOCS implements EmptyOCSInterface, Built { factory EmptyOCS([final void Function(EmptyOCSBuilder)? b]) = _$EmptyOCS; // coverage:ignore-start const EmptyOCS._(); // coverage:ignore-end // coverage:ignore-start factory EmptyOCS.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 static Serializer get serializer => _$emptyOCSSerializer; } // coverage:ignore-start final Serializers _serializers = (Serializers().toBuilder() ..addBuilderFactory(const FullType(Note), Note.new) ..add(Note.serializer) ..addBuilderFactory(const FullType(BuiltList, [FullType(Note)]), ListBuilder.new) ..addBuilderFactory(const FullType(Settings), Settings.new) ..add(Settings.serializer) ..add(Settings_NoteMode.serializer) ..addBuilderFactory(const FullType(Capabilities), Capabilities.new) ..add(Capabilities.serializer) ..addBuilderFactory(const FullType(Capabilities_Notes), Capabilities_Notes.new) ..add(Capabilities_Notes.serializer) ..addBuilderFactory(const FullType(BuiltList, [FullType(String)]), ListBuilder.new) ..addBuilderFactory(const FullType(OCSMeta), OCSMeta.new) ..add(OCSMeta.serializer) ..addBuilderFactory(const FullType(EmptyOCS), EmptyOCS.new) ..add(EmptyOCS.serializer) ..addBuilderFactory(const FullType(EmptyOCS_Ocs), EmptyOCS_Ocs.new) ..add(EmptyOCS_Ocs.serializer) ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonObject)]), ListBuilder.new)) .build(); final Serializers _jsonSerializers = (_serializers.toBuilder() ..add(DynamiteDoubleSerializer()) ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); // coverage:ignore-end