// 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 'notifications.openapi.g.dart'; class NotificationsResponse extends DynamiteResponse { NotificationsResponse( super.data, super.headers, ); @override String toString() => 'NotificationsResponse(data: $data, headers: $headers)'; } class NotificationsApiException extends DynamiteApiException { NotificationsApiException( super.statusCode, super.headers, super.body, ); static Future fromResponse(final HttpClientResponse response) async { final data = await response.bodyBytes; String body; try { body = utf8.decode(data); } on FormatException { body = 'binary'; } return NotificationsApiException( response.statusCode, response.responseHeaders, body, ); } @override String toString() => 'NotificationsApiException(statusCode: $statusCode, headers: $headers, body: $body)'; } class NotificationsClient extends DynamiteClient { NotificationsClient( super.baseURL, { super.baseHeaders, super.userAgent, super.httpClient, super.cookieJar, super.authentications, }); NotificationsClient.fromClient(final DynamiteClient client) : super( client.baseURL, baseHeaders: client.baseHeaders, httpClient: client.httpClient, cookieJar: client.cookieJar, authentications: client.authentications, ); Future listNotifications() async { const path = '/ocs/v2.php/apps/notifications/api/v2/notifications'; final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; if (authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers); } else 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 bearer or basic_auth'); // coverage:ignore-line } 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(NotificationsListNotifications), )! as NotificationsListNotifications; } throw await NotificationsApiException.fromResponse(response); // coverage:ignore-line } Future deleteAllNotifications() async { const path = '/ocs/v2.php/apps/notifications/api/v2/notifications'; final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; if (authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers); } else { throw Exception('Missing authentication for bearer'); // coverage:ignore-line } 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 NotificationsApiException.fromResponse(response); // coverage:ignore-line } Future getNotification({required final int id}) async { var path = '/ocs/v2.php/apps/notifications/api/v2/notifications/{id}'; final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; if (authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers); } else 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 bearer or basic_auth'); // coverage:ignore-line } path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); 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(NotificationsGetNotification), )! as NotificationsGetNotification; } throw await NotificationsApiException.fromResponse(response); // coverage:ignore-line } Future deleteNotification({required final int id}) async { var path = '/ocs/v2.php/apps/notifications/api/v2/notifications/{id}'; final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; if (authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers); } else { throw Exception('Missing authentication for bearer'); // coverage:ignore-line } 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 _jsonSerializers.deserialize( await response.jsonBody, specifiedType: const FullType(NotificationsEmptyOCS), )! as NotificationsEmptyOCS; } throw await NotificationsApiException.fromResponse(response); // coverage:ignore-line } Future registerDevice({ required final String pushTokenHash, required final String devicePublicKey, required final String proxyServer, }) async { const path = '/ocs/v2.php/apps/notifications/api/v2/push'; final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; if (authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers); } else { throw Exception('Missing authentication for bearer'); // coverage:ignore-line } queryParameters['pushTokenHash'] = pushTokenHash; queryParameters['devicePublicKey'] = devicePublicKey; queryParameters['proxyServer'] = proxyServer; final response = await doRequest( 'post', Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), headers, body, ); if (response.statusCode == 201) { return _jsonSerializers.deserialize( await response.jsonBody, specifiedType: const FullType(NotificationsPushServerRegistration), )! as NotificationsPushServerRegistration; } throw await NotificationsApiException.fromResponse(response); // coverage:ignore-line } Future removeDevice() async { const path = '/ocs/v2.php/apps/notifications/api/v2/push'; final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; if (authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers); } else { throw Exception('Missing authentication for bearer'); // coverage:ignore-line } final response = await doRequest( 'delete', Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), headers, body, ); if (response.statusCode == 202) { return response.body; } throw await NotificationsApiException.fromResponse(response); // coverage:ignore-line } Future sendAdminNotification({ required final String userId, required final String shortMessage, final String longMessage = '', }) async { var path = '/ocs/v2.php/apps/notifications/api/v2/admin_notifications/{userId}'; final queryParameters = {}; final headers = { 'Accept': 'application/json', }; Uint8List? body; if (authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { headers.addAll(authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers); } else { throw Exception('Missing authentication for bearer'); // coverage:ignore-line } path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); queryParameters['shortMessage'] = shortMessage; if (longMessage != '') { queryParameters['longMessage'] = longMessage; } 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(NotificationsEmptyOCS), )! as NotificationsEmptyOCS; } throw await NotificationsApiException.fromResponse(response); // coverage:ignore-line } } abstract class NotificationsOCSMeta implements Built { factory NotificationsOCSMeta([final void Function(NotificationsOCSMetaBuilder)? b]) = _$NotificationsOCSMeta; const NotificationsOCSMeta._(); factory NotificationsOCSMeta.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; String get status; int get statuscode; String? get message; String? get totalitems; String? get itemsperpage; static Serializer get serializer => _$notificationsOCSMetaSerializer; } abstract class NotificationsNotificationAction implements Built { factory NotificationsNotificationAction([final void Function(NotificationsNotificationActionBuilder)? b]) = _$NotificationsNotificationAction; const NotificationsNotificationAction._(); factory NotificationsNotificationAction.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; String get label; String get link; String get type; bool? get primary; static Serializer get serializer => _$notificationsNotificationActionSerializer; } abstract class NotificationsNotification implements Built { factory NotificationsNotification([final void Function(NotificationsNotificationBuilder)? b]) = _$NotificationsNotification; const NotificationsNotification._(); factory NotificationsNotification.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; @BuiltValueField(wireName: 'notification_id') int get notificationId; String get app; String get user; String get datetime; @BuiltValueField(wireName: 'object_type') String get objectType; @BuiltValueField(wireName: 'object_id') String get objectId; String get subject; String get message; String get link; String? get subjectRich; JsonObject? get subjectRichParameters; String? get messageRich; JsonObject? get messageRichParameters; String? get icon; bool? get shouldNotify; BuiltList get actions; static Serializer get serializer => _$notificationsNotificationSerializer; } abstract class NotificationsListNotifications_Ocs implements Built { factory NotificationsListNotifications_Ocs([final void Function(NotificationsListNotifications_OcsBuilder)? b]) = _$NotificationsListNotifications_Ocs; const NotificationsListNotifications_Ocs._(); factory NotificationsListNotifications_Ocs.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; NotificationsOCSMeta get meta; BuiltList get data; static Serializer get serializer => _$notificationsListNotificationsOcsSerializer; } abstract class NotificationsListNotifications implements Built { factory NotificationsListNotifications([final void Function(NotificationsListNotificationsBuilder)? b]) = _$NotificationsListNotifications; const NotificationsListNotifications._(); factory NotificationsListNotifications.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; NotificationsListNotifications_Ocs get ocs; static Serializer get serializer => _$notificationsListNotificationsSerializer; } abstract class NotificationsGetNotification_Ocs implements Built { factory NotificationsGetNotification_Ocs([final void Function(NotificationsGetNotification_OcsBuilder)? b]) = _$NotificationsGetNotification_Ocs; const NotificationsGetNotification_Ocs._(); factory NotificationsGetNotification_Ocs.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; NotificationsOCSMeta get meta; NotificationsNotification get data; static Serializer get serializer => _$notificationsGetNotificationOcsSerializer; } abstract class NotificationsGetNotification implements Built { factory NotificationsGetNotification([final void Function(NotificationsGetNotificationBuilder)? b]) = _$NotificationsGetNotification; const NotificationsGetNotification._(); factory NotificationsGetNotification.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; NotificationsGetNotification_Ocs get ocs; static Serializer get serializer => _$notificationsGetNotificationSerializer; } abstract class NotificationsEmptyOCS_Ocs implements Built { factory NotificationsEmptyOCS_Ocs([final void Function(NotificationsEmptyOCS_OcsBuilder)? b]) = _$NotificationsEmptyOCS_Ocs; const NotificationsEmptyOCS_Ocs._(); factory NotificationsEmptyOCS_Ocs.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; NotificationsOCSMeta get meta; BuiltList get data; static Serializer get serializer => _$notificationsEmptyOCSOcsSerializer; } abstract class NotificationsEmptyOCS implements Built { factory NotificationsEmptyOCS([final void Function(NotificationsEmptyOCSBuilder)? b]) = _$NotificationsEmptyOCS; const NotificationsEmptyOCS._(); factory NotificationsEmptyOCS.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; NotificationsEmptyOCS_Ocs get ocs; static Serializer get serializer => _$notificationsEmptyOCSSerializer; } abstract class NotificationsPushServerSubscription implements Built { factory NotificationsPushServerSubscription([final void Function(NotificationsPushServerSubscriptionBuilder)? b]) = _$NotificationsPushServerSubscription; const NotificationsPushServerSubscription._(); factory NotificationsPushServerSubscription.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; String get publicKey; String get deviceIdentifier; String get signature; String? get message; static Serializer get serializer => _$notificationsPushServerSubscriptionSerializer; } abstract class NotificationsPushServerRegistration_Ocs implements Built { factory NotificationsPushServerRegistration_Ocs([ final void Function(NotificationsPushServerRegistration_OcsBuilder)? b, ]) = _$NotificationsPushServerRegistration_Ocs; const NotificationsPushServerRegistration_Ocs._(); factory NotificationsPushServerRegistration_Ocs.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; NotificationsOCSMeta get meta; NotificationsPushServerSubscription get data; static Serializer get serializer => _$notificationsPushServerRegistrationOcsSerializer; } abstract class NotificationsPushServerRegistration implements Built { factory NotificationsPushServerRegistration([final void Function(NotificationsPushServerRegistrationBuilder)? b]) = _$NotificationsPushServerRegistration; const NotificationsPushServerRegistration._(); factory NotificationsPushServerRegistration.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; NotificationsPushServerRegistration_Ocs get ocs; static Serializer get serializer => _$notificationsPushServerRegistrationSerializer; } abstract class NotificationsCapabilities_Notifications implements Built { factory NotificationsCapabilities_Notifications([ final void Function(NotificationsCapabilities_NotificationsBuilder)? b, ]) = _$NotificationsCapabilities_Notifications; const NotificationsCapabilities_Notifications._(); factory NotificationsCapabilities_Notifications.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; @BuiltValueField(wireName: 'ocs-endpoints') BuiltList? get ocsEndpoints; BuiltList? get push; @BuiltValueField(wireName: 'admin-notifications') BuiltList? get adminNotifications; static Serializer get serializer => _$notificationsCapabilitiesNotificationsSerializer; } abstract class NotificationsCapabilities implements Built { factory NotificationsCapabilities([final void Function(NotificationsCapabilitiesBuilder)? b]) = _$NotificationsCapabilities; const NotificationsCapabilities._(); factory NotificationsCapabilities.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; NotificationsCapabilities_Notifications get notifications; static Serializer get serializer => _$notificationsCapabilitiesSerializer; } abstract class NotificationsNotificationDecryptedSubject implements Built { factory NotificationsNotificationDecryptedSubject([ final void Function(NotificationsNotificationDecryptedSubjectBuilder)? b, ]) = _$NotificationsNotificationDecryptedSubject; const NotificationsNotificationDecryptedSubject._(); factory NotificationsNotificationDecryptedSubject.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; int? get nid; String? get app; String? get subject; String? get type; String? get id; bool? get delete; @BuiltValueField(wireName: 'delete-all') bool? get deleteAll; static Serializer get serializer => _$notificationsNotificationDecryptedSubjectSerializer; } final Serializers _serializers = (Serializers().toBuilder() ..addBuilderFactory(const FullType(NotificationsListNotifications), NotificationsListNotifications.new) ..add(NotificationsListNotifications.serializer) ..addBuilderFactory(const FullType(NotificationsListNotifications_Ocs), NotificationsListNotifications_Ocs.new) ..add(NotificationsListNotifications_Ocs.serializer) ..addBuilderFactory(const FullType(NotificationsOCSMeta), NotificationsOCSMeta.new) ..add(NotificationsOCSMeta.serializer) ..addBuilderFactory(const FullType(NotificationsNotification), NotificationsNotification.new) ..add(NotificationsNotification.serializer) ..addBuilderFactory(const FullType(NotificationsNotificationAction), NotificationsNotificationAction.new) ..add(NotificationsNotificationAction.serializer) ..addBuilderFactory( const FullType(BuiltList, [FullType(NotificationsNotificationAction)]), ListBuilder.new, ) ..addBuilderFactory( const FullType(BuiltList, [FullType(NotificationsNotification)]), ListBuilder.new, ) ..addBuilderFactory(const FullType(NotificationsGetNotification), NotificationsGetNotification.new) ..add(NotificationsGetNotification.serializer) ..addBuilderFactory(const FullType(NotificationsGetNotification_Ocs), NotificationsGetNotification_Ocs.new) ..add(NotificationsGetNotification_Ocs.serializer) ..addBuilderFactory(const FullType(NotificationsEmptyOCS), NotificationsEmptyOCS.new) ..add(NotificationsEmptyOCS.serializer) ..addBuilderFactory(const FullType(NotificationsEmptyOCS_Ocs), NotificationsEmptyOCS_Ocs.new) ..add(NotificationsEmptyOCS_Ocs.serializer) ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonObject)]), ListBuilder.new) ..addBuilderFactory(const FullType(NotificationsPushServerRegistration), NotificationsPushServerRegistration.new) ..add(NotificationsPushServerRegistration.serializer) ..addBuilderFactory( const FullType(NotificationsPushServerRegistration_Ocs), NotificationsPushServerRegistration_Ocs.new, ) ..add(NotificationsPushServerRegistration_Ocs.serializer) ..addBuilderFactory(const FullType(NotificationsPushServerSubscription), NotificationsPushServerSubscription.new) ..add(NotificationsPushServerSubscription.serializer) ..addBuilderFactory(const FullType(NotificationsCapabilities), NotificationsCapabilities.new) ..add(NotificationsCapabilities.serializer) ..addBuilderFactory( const FullType(NotificationsCapabilities_Notifications), NotificationsCapabilities_Notifications.new, ) ..add(NotificationsCapabilities_Notifications.serializer) ..addBuilderFactory(const FullType(BuiltList, [FullType(String)]), ListBuilder.new) ..addBuilderFactory( const FullType(NotificationsNotificationDecryptedSubject), NotificationsNotificationDecryptedSubject.new, ) ..add(NotificationsNotificationDecryptedSubject.serializer)) .build(); Serializers get notificationsSerializers => _serializers; final Serializers _jsonSerializers = (_serializers.toBuilder() ..addPlugin(StandardJsonPlugin()) ..addPlugin(const ContentStringPlugin())) .build(); // coverage:ignore-start T deserializeNotifications(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T; Object? serializeNotifications(final T data) => _serializers.serialize(data, specifiedType: FullType(T)); // coverage:ignore-end