Browse Source

refactor(nextcloud): Adjust to generated specs

pull/465/head
jld3103 1 year ago
parent
commit
32eab1d979
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 4
      packages/nextcloud/lib/nextcloud.dart
  2. 4999
      packages/nextcloud/lib/src/api/core.openapi.dart
  3. 18735
      packages/nextcloud/lib/src/api/core.openapi.g.dart
  4. 31
      packages/nextcloud/lib/src/api/notes.openapi.dart
  5. 278
      packages/nextcloud/lib/src/api/notes.openapi.g.dart
  6. 83
      packages/nextcloud/lib/src/api/notifications.openapi.dart
  7. 323
      packages/nextcloud/lib/src/api/notifications.openapi.g.dart
  8. 5053
      packages/nextcloud/lib/src/api/provisioning_api.openapi.dart
  9. 20159
      packages/nextcloud/lib/src/api/provisioning_api.openapi.g.dart
  10. 2
      packages/nextcloud/lib/src/api/provisioning_api.openapi.json
  11. 203
      packages/nextcloud/lib/src/api/settings.openapi.dart
  12. 91
      packages/nextcloud/lib/src/api/settings.openapi.g.dart
  13. 739
      packages/nextcloud/lib/src/api/theming.openapi.dart
  14. 1961
      packages/nextcloud/lib/src/api/theming.openapi.g.dart
  15. 1352
      packages/nextcloud/lib/src/api/user_status.openapi.dart
  16. 3899
      packages/nextcloud/lib/src/api/user_status.openapi.g.dart
  17. 21
      packages/nextcloud/lib/src/client.dart
  18. 54
      packages/nextcloud/lib/src/helpers.dart
  19. 20
      packages/nextcloud/lib/src/helpers/core.dart
  20. 12
      packages/nextcloud/lib/src/helpers/news.dart
  21. 63
      packages/nextcloud/lib/src/helpers/notifications.dart
  22. 28
      packages/nextcloud/lib/src/helpers/notifications.g.dart
  23. 6
      packages/nextcloud/lib/src/version_supported.dart
  24. 2
      packages/nextcloud/pubspec.yaml
  25. 49
      packages/nextcloud/test/core_test.dart
  26. 28
      packages/nextcloud/test/helper.dart
  27. 26
      packages/nextcloud/test/news_test.dart
  28. 2
      packages/nextcloud/test/notes_test.dart
  29. 15
      packages/nextcloud/test/notifications_test.dart
  30. 29
      packages/nextcloud/test/provisioning_api_test.dart
  31. 29
      packages/nextcloud/test/settings_test.dart
  32. 1
      packages/nextcloud/test/uppush_test.dart
  33. 158
      packages/nextcloud/test/user_status_test.dart

4
packages/nextcloud/lib/nextcloud.dart

@ -9,7 +9,9 @@ export 'src/api/uppush.openapi.dart';
export 'src/api/user_status.openapi.dart';
export 'src/app_type.dart';
export 'src/client.dart';
export 'src/helpers.dart';
export 'src/helpers/core.dart';
export 'src/helpers/news.dart';
export 'src/helpers/notifications.dart';
export 'src/version_supported.dart';
export 'src/webdav/client.dart';
export 'src/webdav/file.dart';

4999
packages/nextcloud/lib/src/api/core.openapi.dart

File diff suppressed because it is too large Load Diff

18735
packages/nextcloud/lib/src/api/core.openapi.g.dart

File diff suppressed because it is too large Load Diff

31
packages/nextcloud/lib/src/api/notes.openapi.dart

@ -387,6 +387,32 @@ abstract class NotesSettings implements Built<NotesSettings, NotesSettingsBuilde
static Serializer<NotesSettings> get serializer => _$notesSettingsSerializer;
}
abstract class NotesCapabilities_Notes implements Built<NotesCapabilities_Notes, NotesCapabilities_NotesBuilder> {
factory NotesCapabilities_Notes([final void Function(NotesCapabilities_NotesBuilder)? b]) = _$NotesCapabilities_Notes;
const NotesCapabilities_Notes._();
factory NotesCapabilities_Notes.fromJson(final Map<String, dynamic> json) =>
_jsonSerializers.deserializeWith(serializer, json)!;
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>;
@BuiltValueField(wireName: 'api_version')
BuiltList<String>? get apiVersion;
String? get version;
static Serializer<NotesCapabilities_Notes> get serializer => _$notesCapabilitiesNotesSerializer;
}
abstract class NotesCapabilities implements Built<NotesCapabilities, NotesCapabilitiesBuilder> {
factory NotesCapabilities([final void Function(NotesCapabilitiesBuilder)? b]) = _$NotesCapabilities;
const NotesCapabilities._();
factory NotesCapabilities.fromJson(final Map<String, dynamic> json) =>
_jsonSerializers.deserializeWith(serializer, json)!;
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>;
NotesCapabilities_Notes get notes;
static Serializer<NotesCapabilities> get serializer => _$notesCapabilitiesSerializer;
}
abstract class NotesOCSMeta implements Built<NotesOCSMeta, NotesOCSMetaBuilder> {
factory NotesOCSMeta([final void Function(NotesOCSMetaBuilder)? b]) = _$NotesOCSMeta;
const NotesOCSMeta._();
@ -434,6 +460,11 @@ final Serializers _serializers = (Serializers().toBuilder()
..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<String>.new)
..addBuilderFactory(const FullType(NotesOCSMeta), NotesOCSMeta.new)
..add(NotesOCSMeta.serializer)
..addBuilderFactory(const FullType(NotesEmptyOCS), NotesEmptyOCS.new)

278
packages/nextcloud/lib/src/api/notes.openapi.g.dart

@ -33,6 +33,8 @@ final BuiltSet<NotesSettings_NoteMode> _$notesSettingsNoteModeValues =
Serializer<NotesNote> _$notesNoteSerializer = _$NotesNoteSerializer();
Serializer<NotesSettings_NoteMode> _$notesSettingsNoteModeSerializer = _$NotesSettings_NoteModeSerializer();
Serializer<NotesSettings> _$notesSettingsSerializer = _$NotesSettingsSerializer();
Serializer<NotesCapabilities_Notes> _$notesCapabilitiesNotesSerializer = _$NotesCapabilities_NotesSerializer();
Serializer<NotesCapabilities> _$notesCapabilitiesSerializer = _$NotesCapabilitiesSerializer();
Serializer<NotesOCSMeta> _$notesOCSMetaSerializer = _$NotesOCSMetaSerializer();
Serializer<NotesEmptyOCS_Ocs> _$notesEmptyOCSOcsSerializer = _$NotesEmptyOCS_OcsSerializer();
Serializer<NotesEmptyOCS> _$notesEmptyOCSSerializer = _$NotesEmptyOCSSerializer();
@ -186,6 +188,96 @@ class _$NotesSettingsSerializer implements StructuredSerializer<NotesSettings> {
}
}
class _$NotesCapabilities_NotesSerializer implements StructuredSerializer<NotesCapabilities_Notes> {
@override
final Iterable<Type> types = const [NotesCapabilities_Notes, _$NotesCapabilities_Notes];
@override
final String wireName = 'NotesCapabilities_Notes';
@override
Iterable<Object?> serialize(Serializers serializers, NotesCapabilities_Notes object,
{FullType specifiedType = FullType.unspecified}) {
final result = <Object?>[];
Object? value;
value = object.apiVersion;
if (value != null) {
result
..add('api_version')
..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(String)])));
}
value = object.version;
if (value != null) {
result
..add('version')
..add(serializers.serialize(value, specifiedType: const FullType(String)));
}
return result;
}
@override
NotesCapabilities_Notes deserialize(Serializers serializers, Iterable<Object?> serialized,
{FullType specifiedType = FullType.unspecified}) {
final result = NotesCapabilities_NotesBuilder();
final iterator = serialized.iterator;
while (iterator.moveNext()) {
final key = iterator.current! as String;
iterator.moveNext();
final Object? value = iterator.current;
switch (key) {
case 'api_version':
result.apiVersion.replace(serializers.deserialize(value,
specifiedType: const FullType(BuiltList, [FullType(String)]))! as BuiltList<Object?>);
break;
case 'version':
result.version = serializers.deserialize(value, specifiedType: const FullType(String)) as String?;
break;
}
}
return result.build();
}
}
class _$NotesCapabilitiesSerializer implements StructuredSerializer<NotesCapabilities> {
@override
final Iterable<Type> types = const [NotesCapabilities, _$NotesCapabilities];
@override
final String wireName = 'NotesCapabilities';
@override
Iterable<Object?> serialize(Serializers serializers, NotesCapabilities object,
{FullType specifiedType = FullType.unspecified}) {
final result = <Object?>[
'notes',
serializers.serialize(object.notes, specifiedType: const FullType(NotesCapabilities_Notes)),
];
return result;
}
@override
NotesCapabilities deserialize(Serializers serializers, Iterable<Object?> serialized,
{FullType specifiedType = FullType.unspecified}) {
final result = NotesCapabilitiesBuilder();
final iterator = serialized.iterator;
while (iterator.moveNext()) {
final key = iterator.current! as String;
iterator.moveNext();
final Object? value = iterator.current;
switch (key) {
case 'notes':
result.notes.replace(serializers.deserialize(value, specifiedType: const FullType(NotesCapabilities_Notes))!
as NotesCapabilities_Notes);
break;
}
}
return result.build();
}
}
class _$NotesOCSMetaSerializer implements StructuredSerializer<NotesOCSMeta> {
@override
final Iterable<Type> types = const [NotesOCSMeta, _$NotesOCSMeta];
@ -644,6 +736,192 @@ class NotesSettingsBuilder implements Builder<NotesSettings, NotesSettingsBuilde
}
}
class _$NotesCapabilities_Notes extends NotesCapabilities_Notes {
@override
final BuiltList<String>? apiVersion;
@override
final String? version;
factory _$NotesCapabilities_Notes([void Function(NotesCapabilities_NotesBuilder)? updates]) =>
(NotesCapabilities_NotesBuilder()..update(updates))._build();
_$NotesCapabilities_Notes._({this.apiVersion, this.version}) : super._();
@override
NotesCapabilities_Notes rebuild(void Function(NotesCapabilities_NotesBuilder) updates) =>
(toBuilder()..update(updates)).build();
@override
NotesCapabilities_NotesBuilder toBuilder() => NotesCapabilities_NotesBuilder()..replace(this);
@override
bool operator ==(Object other) {
if (identical(other, this)) return true;
return other is NotesCapabilities_Notes && apiVersion == other.apiVersion && version == other.version;
}
@override
int get hashCode {
var _$hash = 0;
_$hash = $jc(_$hash, apiVersion.hashCode);
_$hash = $jc(_$hash, version.hashCode);
_$hash = $jf(_$hash);
return _$hash;
}
@override
String toString() {
return (newBuiltValueToStringHelper(r'NotesCapabilities_Notes')
..add('apiVersion', apiVersion)
..add('version', version))
.toString();
}
}
class NotesCapabilities_NotesBuilder implements Builder<NotesCapabilities_Notes, NotesCapabilities_NotesBuilder> {
_$NotesCapabilities_Notes? _$v;
ListBuilder<String>? _apiVersion;
ListBuilder<String> get apiVersion => _$this._apiVersion ??= ListBuilder<String>();
set apiVersion(ListBuilder<String>? apiVersion) => _$this._apiVersion = apiVersion;
String? _version;
String? get version => _$this._version;
set version(String? version) => _$this._version = version;
NotesCapabilities_NotesBuilder();
NotesCapabilities_NotesBuilder get _$this {
final $v = _$v;
if ($v != null) {
_apiVersion = $v.apiVersion?.toBuilder();
_version = $v.version;
_$v = null;
}
return this;
}
@override
void replace(NotesCapabilities_Notes other) {
ArgumentError.checkNotNull(other, 'other');
_$v = other as _$NotesCapabilities_Notes;
}
@override
void update(void Function(NotesCapabilities_NotesBuilder)? updates) {
if (updates != null) updates(this);
}
@override
NotesCapabilities_Notes build() => _build();
_$NotesCapabilities_Notes _build() {
_$NotesCapabilities_Notes _$result;
try {
_$result = _$v ?? _$NotesCapabilities_Notes._(apiVersion: _apiVersion?.build(), version: version);
} catch (_) {
late String _$failedField;
try {
_$failedField = 'apiVersion';
_apiVersion?.build();
} catch (e) {
throw BuiltValueNestedFieldError(r'NotesCapabilities_Notes', _$failedField, e.toString());
}
rethrow;
}
replace(_$result);
return _$result;
}
}
class _$NotesCapabilities extends NotesCapabilities {
@override
final NotesCapabilities_Notes notes;
factory _$NotesCapabilities([void Function(NotesCapabilitiesBuilder)? updates]) =>
(NotesCapabilitiesBuilder()..update(updates))._build();
_$NotesCapabilities._({required this.notes}) : super._() {
BuiltValueNullFieldError.checkNotNull(notes, r'NotesCapabilities', 'notes');
}
@override
NotesCapabilities rebuild(void Function(NotesCapabilitiesBuilder) updates) => (toBuilder()..update(updates)).build();
@override
NotesCapabilitiesBuilder toBuilder() => NotesCapabilitiesBuilder()..replace(this);
@override
bool operator ==(Object other) {
if (identical(other, this)) return true;
return other is NotesCapabilities && notes == other.notes;
}
@override
int get hashCode {
var _$hash = 0;
_$hash = $jc(_$hash, notes.hashCode);
_$hash = $jf(_$hash);
return _$hash;
}
@override
String toString() {
return (newBuiltValueToStringHelper(r'NotesCapabilities')..add('notes', notes)).toString();
}
}
class NotesCapabilitiesBuilder implements Builder<NotesCapabilities, NotesCapabilitiesBuilder> {
_$NotesCapabilities? _$v;
NotesCapabilities_NotesBuilder? _notes;
NotesCapabilities_NotesBuilder get notes => _$this._notes ??= NotesCapabilities_NotesBuilder();
set notes(NotesCapabilities_NotesBuilder? notes) => _$this._notes = notes;
NotesCapabilitiesBuilder();
NotesCapabilitiesBuilder get _$this {
final $v = _$v;
if ($v != null) {
_notes = $v.notes.toBuilder();
_$v = null;
}
return this;
}
@override
void replace(NotesCapabilities other) {
ArgumentError.checkNotNull(other, 'other');
_$v = other as _$NotesCapabilities;
}
@override
void update(void Function(NotesCapabilitiesBuilder)? updates) {
if (updates != null) updates(this);
}
@override
NotesCapabilities build() => _build();
_$NotesCapabilities _build() {
_$NotesCapabilities _$result;
try {
_$result = _$v ?? _$NotesCapabilities._(notes: notes.build());
} catch (_) {
late String _$failedField;
try {
_$failedField = 'notes';
notes.build();
} catch (e) {
throw BuiltValueNestedFieldError(r'NotesCapabilities', _$failedField, e.toString());
}
rethrow;
}
replace(_$result);
return _$result;
}
}
class _$NotesOCSMeta extends NotesOCSMeta {
@override
final String status;

83
packages/nextcloud/lib/src/api/notifications.openapi.dart

@ -80,10 +80,12 @@ class NotificationsClient extends DynamiteClient {
'Accept': 'application/json',
};
Uint8List? body;
if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) {
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 basic_auth'); // coverage:ignore-line
throw Exception('Missing authentication for bearer or basic_auth'); // coverage:ignore-line
}
final response = await doRequest(
'get',
@ -107,10 +109,10 @@ class NotificationsClient extends DynamiteClient {
'Accept': 'application/json',
};
Uint8List? body;
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);
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 basic_auth'); // coverage:ignore-line
throw Exception('Missing authentication for bearer'); // coverage:ignore-line
}
final response = await doRequest(
'delete',
@ -131,10 +133,12 @@ class NotificationsClient extends DynamiteClient {
'Accept': 'application/json',
};
Uint8List? body;
if (authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) {
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 basic_auth'); // coverage:ignore-line
throw Exception('Missing authentication for bearer or basic_auth'); // coverage:ignore-line
}
path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString()));
final response = await doRequest(
@ -159,10 +163,10 @@ class NotificationsClient extends DynamiteClient {
'Accept': 'application/json',
};
Uint8List? body;
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);
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 basic_auth'); // coverage:ignore-line
throw Exception('Missing authentication for bearer'); // coverage:ignore-line
}
path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString()));
final response = await doRequest(
@ -191,10 +195,10 @@ class NotificationsClient extends DynamiteClient {
'Accept': 'application/json',
};
Uint8List? body;
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);
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 basic_auth'); // coverage:ignore-line
throw Exception('Missing authentication for bearer'); // coverage:ignore-line
}
queryParameters['pushTokenHash'] = pushTokenHash;
queryParameters['devicePublicKey'] = devicePublicKey;
@ -221,10 +225,10 @@ class NotificationsClient extends DynamiteClient {
'Accept': 'application/json',
};
Uint8List? body;
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);
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 basic_auth'); // coverage:ignore-line
throw Exception('Missing authentication for bearer'); // coverage:ignore-line
}
final response = await doRequest(
'delete',
@ -249,10 +253,10 @@ class NotificationsClient extends DynamiteClient {
'Accept': 'application/json',
};
Uint8List? body;
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);
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 basic_auth'); // coverage:ignore-line
throw Exception('Missing authentication for bearer'); // coverage:ignore-line
}
path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId));
queryParameters['shortMessage'] = shortMessage;
@ -473,6 +477,39 @@ abstract class NotificationsPushServerRegistration
_$notificationsPushServerRegistrationSerializer;
}
abstract class NotificationsCapabilities_Notifications
implements Built<NotificationsCapabilities_Notifications, NotificationsCapabilities_NotificationsBuilder> {
factory NotificationsCapabilities_Notifications([
final void Function(NotificationsCapabilities_NotificationsBuilder)? b,
]) = _$NotificationsCapabilities_Notifications;
const NotificationsCapabilities_Notifications._();
factory NotificationsCapabilities_Notifications.fromJson(final Map<String, dynamic> json) =>
_jsonSerializers.deserializeWith(serializer, json)!;
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>;
@BuiltValueField(wireName: 'ocs-endpoints')
BuiltList<String>? get ocsEndpoints;
BuiltList<String>? get push;
@BuiltValueField(wireName: 'admin-notifications')
BuiltList<String>? get adminNotifications;
static Serializer<NotificationsCapabilities_Notifications> get serializer =>
_$notificationsCapabilitiesNotificationsSerializer;
}
abstract class NotificationsCapabilities implements Built<NotificationsCapabilities, NotificationsCapabilitiesBuilder> {
factory NotificationsCapabilities([final void Function(NotificationsCapabilitiesBuilder)? b]) =
_$NotificationsCapabilities;
const NotificationsCapabilities._();
factory NotificationsCapabilities.fromJson(final Map<String, dynamic> json) =>
_jsonSerializers.deserializeWith(serializer, json)!;
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>;
NotificationsCapabilities_Notifications get notifications;
static Serializer<NotificationsCapabilities> get serializer => _$notificationsCapabilitiesSerializer;
}
abstract class NotificationsNotificationDecryptedSubject
implements Built<NotificationsNotificationDecryptedSubject, NotificationsNotificationDecryptedSubjectBuilder> {
factory NotificationsNotificationDecryptedSubject([
@ -533,6 +570,14 @@ final Serializers _serializers = (Serializers().toBuilder()
..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<String>.new)
..addBuilderFactory(
const FullType(NotificationsNotificationDecryptedSubject),
NotificationsNotificationDecryptedSubject.new,

323
packages/nextcloud/lib/src/api/notifications.openapi.g.dart

@ -26,6 +26,9 @@ Serializer<NotificationsPushServerRegistration_Ocs> _$notificationsPushServerReg
_$NotificationsPushServerRegistration_OcsSerializer();
Serializer<NotificationsPushServerRegistration> _$notificationsPushServerRegistrationSerializer =
_$NotificationsPushServerRegistrationSerializer();
Serializer<NotificationsCapabilities_Notifications> _$notificationsCapabilitiesNotificationsSerializer =
_$NotificationsCapabilities_NotificationsSerializer();
Serializer<NotificationsCapabilities> _$notificationsCapabilitiesSerializer = _$NotificationsCapabilitiesSerializer();
Serializer<NotificationsNotificationDecryptedSubject> _$notificationsNotificationDecryptedSubjectSerializer =
_$NotificationsNotificationDecryptedSubjectSerializer();
@ -702,6 +705,113 @@ class _$NotificationsPushServerRegistrationSerializer
}
}
class _$NotificationsCapabilities_NotificationsSerializer
implements StructuredSerializer<NotificationsCapabilities_Notifications> {
@override
final Iterable<Type> types = const [
NotificationsCapabilities_Notifications,
_$NotificationsCapabilities_Notifications
];
@override
final String wireName = 'NotificationsCapabilities_Notifications';
@override
Iterable<Object?> serialize(Serializers serializers, NotificationsCapabilities_Notifications object,
{FullType specifiedType = FullType.unspecified}) {
final result = <Object?>[];
Object? value;
value = object.ocsEndpoints;
if (value != null) {
result
..add('ocs-endpoints')
..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(String)])));
}
value = object.push;
if (value != null) {
result
..add('push')
..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(String)])));
}
value = object.adminNotifications;
if (value != null) {
result
..add('admin-notifications')
..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(String)])));
}
return result;
}
@override
NotificationsCapabilities_Notifications deserialize(Serializers serializers, Iterable<Object?> serialized,
{FullType specifiedType = FullType.unspecified}) {
final result = NotificationsCapabilities_NotificationsBuilder();
final iterator = serialized.iterator;
while (iterator.moveNext()) {
final key = iterator.current! as String;
iterator.moveNext();
final Object? value = iterator.current;
switch (key) {
case 'ocs-endpoints':
result.ocsEndpoints.replace(serializers.deserialize(value,
specifiedType: const FullType(BuiltList, [FullType(String)]))! as BuiltList<Object?>);
break;
case 'push':
result.push.replace(serializers.deserialize(value,
specifiedType: const FullType(BuiltList, [FullType(String)]))! as BuiltList<Object?>);
break;
case 'admin-notifications':
result.adminNotifications.replace(serializers.deserialize(value,
specifiedType: const FullType(BuiltList, [FullType(String)]))! as BuiltList<Object?>);
break;
}
}
return result.build();
}
}
class _$NotificationsCapabilitiesSerializer implements StructuredSerializer<NotificationsCapabilities> {
@override
final Iterable<Type> types = const [NotificationsCapabilities, _$NotificationsCapabilities];
@override
final String wireName = 'NotificationsCapabilities';
@override
Iterable<Object?> serialize(Serializers serializers, NotificationsCapabilities object,
{FullType specifiedType = FullType.unspecified}) {
final result = <Object?>[
'notifications',
serializers.serialize(object.notifications,
specifiedType: const FullType(NotificationsCapabilities_Notifications)),
];
return result;
}
@override
NotificationsCapabilities deserialize(Serializers serializers, Iterable<Object?> serialized,
{FullType specifiedType = FullType.unspecified}) {
final result = NotificationsCapabilitiesBuilder();
final iterator = serialized.iterator;
while (iterator.moveNext()) {
final key = iterator.current! as String;
iterator.moveNext();
final Object? value = iterator.current;
switch (key) {
case 'notifications':
result.notifications.replace(
serializers.deserialize(value, specifiedType: const FullType(NotificationsCapabilities_Notifications))!
as NotificationsCapabilities_Notifications);
break;
}
}
return result.build();
}
}
class _$NotificationsNotificationDecryptedSubjectSerializer
implements StructuredSerializer<NotificationsNotificationDecryptedSubject> {
@override
@ -2237,6 +2347,219 @@ class NotificationsPushServerRegistrationBuilder
}
}
class _$NotificationsCapabilities_Notifications extends NotificationsCapabilities_Notifications {
@override
final BuiltList<String>? ocsEndpoints;
@override
final BuiltList<String>? push;
@override
final BuiltList<String>? adminNotifications;
factory _$NotificationsCapabilities_Notifications(
[void Function(NotificationsCapabilities_NotificationsBuilder)? updates]) =>
(NotificationsCapabilities_NotificationsBuilder()..update(updates))._build();
_$NotificationsCapabilities_Notifications._({this.ocsEndpoints, this.push, this.adminNotifications}) : super._();
@override
NotificationsCapabilities_Notifications rebuild(
void Function(NotificationsCapabilities_NotificationsBuilder) updates) =>
(toBuilder()..update(updates)).build();
@override
NotificationsCapabilities_NotificationsBuilder toBuilder() =>
NotificationsCapabilities_NotificationsBuilder()..replace(this);
@override
bool operator ==(Object other) {
if (identical(other, this)) return true;
return other is NotificationsCapabilities_Notifications &&
ocsEndpoints == other.ocsEndpoints &&
push == other.push &&
adminNotifications == other.adminNotifications;
}
@override
int get hashCode {
var _$hash = 0;
_$hash = $jc(_$hash, ocsEndpoints.hashCode);
_$hash = $jc(_$hash, push.hashCode);
_$hash = $jc(_$hash, adminNotifications.hashCode);
_$hash = $jf(_$hash);
return _$hash;
}
@override
String toString() {
return (newBuiltValueToStringHelper(r'NotificationsCapabilities_Notifications')
..add('ocsEndpoints', ocsEndpoints)
..add('push', push)
..add('adminNotifications', adminNotifications))
.toString();
}
}
class NotificationsCapabilities_NotificationsBuilder
implements Builder<NotificationsCapabilities_Notifications, NotificationsCapabilities_NotificationsBuilder> {
_$NotificationsCapabilities_Notifications? _$v;
ListBuilder<String>? _ocsEndpoints;
ListBuilder<String> get ocsEndpoints => _$this._ocsEndpoints ??= ListBuilder<String>();
set ocsEndpoints(ListBuilder<String>? ocsEndpoints) => _$this._ocsEndpoints = ocsEndpoints;
ListBuilder<String>? _push;
ListBuilder<String> get push => _$this._push ??= ListBuilder<String>();
set push(ListBuilder<String>? push) => _$this._push = push;
ListBuilder<String>? _adminNotifications;
ListBuilder<String> get adminNotifications => _$this._adminNotifications ??= ListBuilder<String>();
set adminNotifications(ListBuilder<String>? adminNotifications) => _$this._adminNotifications = adminNotifications;
NotificationsCapabilities_NotificationsBuilder();
NotificationsCapabilities_NotificationsBuilder get _$this {
final $v = _$v;
if ($v != null) {
_ocsEndpoints = $v.ocsEndpoints?.toBuilder();
_push = $v.push?.toBuilder();
_adminNotifications = $v.adminNotifications?.toBuilder();
_$v = null;
}
return this;
}
@override
void replace(NotificationsCapabilities_Notifications other) {
ArgumentError.checkNotNull(other, 'other');
_$v = other as _$NotificationsCapabilities_Notifications;
}
@override
void update(void Function(NotificationsCapabilities_NotificationsBuilder)? updates) {
if (updates != null) updates(this);
}
@override
NotificationsCapabilities_Notifications build() => _build();
_$NotificationsCapabilities_Notifications _build() {
_$NotificationsCapabilities_Notifications _$result;
try {
_$result = _$v ??
_$NotificationsCapabilities_Notifications._(
ocsEndpoints: _ocsEndpoints?.build(),
push: _push?.build(),
adminNotifications: _adminNotifications?.build());
} catch (_) {
late String _$failedField;
try {
_$failedField = 'ocsEndpoints';
_ocsEndpoints?.build();
_$failedField = 'push';
_push?.build();
_$failedField = 'adminNotifications';
_adminNotifications?.build();
} catch (e) {
throw BuiltValueNestedFieldError(r'NotificationsCapabilities_Notifications', _$failedField, e.toString());
}
rethrow;
}
replace(_$result);
return _$result;
}
}
class _$NotificationsCapabilities extends NotificationsCapabilities {
@override
final NotificationsCapabilities_Notifications notifications;
factory _$NotificationsCapabilities([void Function(NotificationsCapabilitiesBuilder)? updates]) =>
(NotificationsCapabilitiesBuilder()..update(updates))._build();
_$NotificationsCapabilities._({required this.notifications}) : super._() {
BuiltValueNullFieldError.checkNotNull(notifications, r'NotificationsCapabilities', 'notifications');
}
@override
NotificationsCapabilities rebuild(void Function(NotificationsCapabilitiesBuilder) updates) =>
(toBuilder()..update(updates)).build();
@override
NotificationsCapabilitiesBuilder toBuilder() => NotificationsCapabilitiesBuilder()..replace(this);
@override
bool operator ==(Object other) {
if (identical(other, this)) return true;
return other is NotificationsCapabilities && notifications == other.notifications;
}
@override
int get hashCode {
var _$hash = 0;
_$hash = $jc(_$hash, notifications.hashCode);
_$hash = $jf(_$hash);
return _$hash;
}
@override
String toString() {
return (newBuiltValueToStringHelper(r'NotificationsCapabilities')..add('notifications', notifications)).toString();
}
}
class NotificationsCapabilitiesBuilder implements Builder<NotificationsCapabilities, NotificationsCapabilitiesBuilder> {
_$NotificationsCapabilities? _$v;
NotificationsCapabilities_NotificationsBuilder? _notifications;
NotificationsCapabilities_NotificationsBuilder get notifications =>
_$this._notifications ??= NotificationsCapabilities_NotificationsBuilder();
set notifications(NotificationsCapabilities_NotificationsBuilder? notifications) =>
_$this._notifications = notifications;
NotificationsCapabilitiesBuilder();
NotificationsCapabilitiesBuilder get _$this {
final $v = _$v;
if ($v != null) {
_notifications = $v.notifications.toBuilder();
_$v = null;
}
return this;
}
@override
void replace(NotificationsCapabilities other) {
ArgumentError.checkNotNull(other, 'other');
_$v = other as _$NotificationsCapabilities;
}
@override
void update(void Function(NotificationsCapabilitiesBuilder)? updates) {
if (updates != null) updates(this);
}
@override
NotificationsCapabilities build() => _build();
_$NotificationsCapabilities _build() {
_$NotificationsCapabilities _$result;
try {
_$result = _$v ?? _$NotificationsCapabilities._(notifications: notifications.build());
} catch (_) {
late String _$failedField;
try {
_$failedField = 'notifications';
notifications.build();
} catch (e) {
throw BuiltValueNestedFieldError(r'NotificationsCapabilities', _$failedField, e.toString());
}
rethrow;
}
replace(_$result);
return _$result;
}
}
class _$NotificationsNotificationDecryptedSubject extends NotificationsNotificationDecryptedSubject {
@override
final int? nid;

5053
packages/nextcloud/lib/src/api/provisioning_api.openapi.dart

File diff suppressed because it is too large Load Diff

20159
packages/nextcloud/lib/src/api/provisioning_api.openapi.g.dart

File diff suppressed because it is too large Load Diff

2
packages/nextcloud/lib/src/api/provisioning_api.openapi.json

@ -3479,7 +3479,7 @@
{
"name": "app",
"in": "path",
"description": "ID if the app",
"description": "ID of the app",
"required": true,
"schema": {
"type": "string"

203
packages/nextcloud/lib/src/api/settings.openapi.dart

@ -0,0 +1,203 @@
// ignore_for_file: camel_case_types
// ignore_for_file: public_member_api_docs
import 'dart:convert';
import 'dart:typed_data';
import 'package:built_value/built_value.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 'settings.openapi.g.dart';
class SettingsResponse<T, U> extends DynamiteResponse<T, U> {
SettingsResponse(
super.data,
super.headers,
);
@override
String toString() => 'SettingsResponse(data: $data, headers: $headers)';
}
class SettingsApiException extends DynamiteApiException {
SettingsApiException(
super.statusCode,
super.headers,
super.body,
);
static Future<SettingsApiException> fromResponse(final HttpClientResponse response) async {
final data = await response.bodyBytes;
String body;
try {
body = utf8.decode(data);
} on FormatException {
body = 'binary';
}
return SettingsApiException(
response.statusCode,
response.responseHeaders,
body,
);
}
@override
String toString() => 'SettingsApiException(statusCode: $statusCode, headers: $headers, body: $body)';
}
class SettingsClient extends DynamiteClient {
SettingsClient(
super.baseURL, {
super.baseHeaders,
super.userAgent,
super.httpClient,
super.cookieJar,
super.authentications,
});
SettingsClient.fromClient(final DynamiteClient client)
: super(
client.baseURL,
baseHeaders: client.baseHeaders,
httpClient: client.httpClient,
cookieJar: client.cookieJar,
authentications: client.authentications,
);
SettingsLogSettingsClient get logSettings => SettingsLogSettingsClient(this);
}
class SettingsLogSettingsClient {
SettingsLogSettingsClient(this.rootClient);
final SettingsClient rootClient;
/// download logfile
///
/// This endpoint requires admin access
Future<SettingsResponse<Uint8List, SettingsLogSettingsLogSettingsDownloadHeaders>> download() async {
const path = '/index.php/settings/admin/log/download';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
'Accept': 'application/octet-stream',
};
Uint8List? body;
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);
} else {
throw Exception('Missing authentication for bearer_auth or basic_auth'); // coverage:ignore-line
}
final response = await rootClient.doRequest(
'get',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
headers,
body,
);
if (response.statusCode == 200) {
return SettingsResponse<Uint8List, SettingsLogSettingsLogSettingsDownloadHeaders>(
await response.bodyBytes,
_jsonSerializers.deserialize(
response.responseHeaders,
specifiedType: const FullType(SettingsLogSettingsLogSettingsDownloadHeaders),
)! as SettingsLogSettingsLogSettingsDownloadHeaders,
);
}
throw await SettingsApiException.fromResponse(response); // coverage:ignore-line
}
}
abstract class SettingsLogSettingsLogSettingsDownloadHeaders
implements
Built<SettingsLogSettingsLogSettingsDownloadHeaders, SettingsLogSettingsLogSettingsDownloadHeadersBuilder> {
factory SettingsLogSettingsLogSettingsDownloadHeaders([
final void Function(SettingsLogSettingsLogSettingsDownloadHeadersBuilder)? b,
]) = _$SettingsLogSettingsLogSettingsDownloadHeaders;
const SettingsLogSettingsLogSettingsDownloadHeaders._();
factory SettingsLogSettingsLogSettingsDownloadHeaders.fromJson(final Map<String, dynamic> json) =>
_jsonSerializers.deserializeWith(serializer, json)!;
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>;
@BuiltValueField(wireName: 'content-disposition')
String? get contentDisposition;
@BuiltValueSerializer(custom: true)
static Serializer<SettingsLogSettingsLogSettingsDownloadHeaders> get serializer =>
_$SettingsLogSettingsLogSettingsDownloadHeadersSerializer();
}
class _$SettingsLogSettingsLogSettingsDownloadHeadersSerializer
implements StructuredSerializer<SettingsLogSettingsLogSettingsDownloadHeaders> {
@override
final Iterable<Type> types = const [
SettingsLogSettingsLogSettingsDownloadHeaders,
_$SettingsLogSettingsLogSettingsDownloadHeaders
];
@override
final String wireName = 'SettingsLogSettingsLogSettingsDownloadHeaders';
@override
Iterable<Object?> serialize(
final Serializers serializers,
final SettingsLogSettingsLogSettingsDownloadHeaders object, {
final FullType specifiedType = FullType.unspecified,
}) {
throw UnimplementedError();
}
@override
SettingsLogSettingsLogSettingsDownloadHeaders deserialize(
final Serializers serializers,
final Iterable<Object?> serialized, {
final FullType specifiedType = FullType.unspecified,
}) {
final result = SettingsLogSettingsLogSettingsDownloadHeadersBuilder();
final iterator = serialized.iterator;
while (iterator.moveNext()) {
final key = iterator.current! as String;
iterator.moveNext();
final value = iterator.current! as String;
switch (key) {
case 'content-disposition':
result.contentDisposition = value;
break;
}
}
return result.build();
}
}
final Serializers _serializers = (Serializers().toBuilder()
..addBuilderFactory(
const FullType(SettingsLogSettingsLogSettingsDownloadHeaders),
SettingsLogSettingsLogSettingsDownloadHeaders.new,
)
..add(SettingsLogSettingsLogSettingsDownloadHeaders.serializer))
.build();
Serializers get settingsSerializers => _serializers;
final Serializers _jsonSerializers = (_serializers.toBuilder()
..addPlugin(StandardJsonPlugin())
..addPlugin(const ContentStringPlugin()))
.build();
// coverage:ignore-start
T deserializeSettings<T>(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;
Object? serializeSettings<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

91
packages/nextcloud/lib/src/api/settings.openapi.g.dart

@ -0,0 +1,91 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'settings.openapi.dart';
// **************************************************************************
// BuiltValueGenerator
// **************************************************************************
class _$SettingsLogSettingsLogSettingsDownloadHeaders extends SettingsLogSettingsLogSettingsDownloadHeaders {
@override
final String? contentDisposition;
factory _$SettingsLogSettingsLogSettingsDownloadHeaders(
[void Function(SettingsLogSettingsLogSettingsDownloadHeadersBuilder)? updates]) =>
(SettingsLogSettingsLogSettingsDownloadHeadersBuilder()..update(updates))._build();
_$SettingsLogSettingsLogSettingsDownloadHeaders._({this.contentDisposition}) : super._();
@override
SettingsLogSettingsLogSettingsDownloadHeaders rebuild(
void Function(SettingsLogSettingsLogSettingsDownloadHeadersBuilder) updates) =>
(toBuilder()..update(updates)).build();
@override
SettingsLogSettingsLogSettingsDownloadHeadersBuilder toBuilder() =>
SettingsLogSettingsLogSettingsDownloadHeadersBuilder()..replace(this);
@override
bool operator ==(Object other) {
if (identical(other, this)) return true;
return other is SettingsLogSettingsLogSettingsDownloadHeaders && contentDisposition == other.contentDisposition;
}
@override
int get hashCode {
var _$hash = 0;
_$hash = $jc(_$hash, contentDisposition.hashCode);
_$hash = $jf(_$hash);
return _$hash;
}
@override
String toString() {
return (newBuiltValueToStringHelper(r'SettingsLogSettingsLogSettingsDownloadHeaders')
..add('contentDisposition', contentDisposition))
.toString();
}
}
class SettingsLogSettingsLogSettingsDownloadHeadersBuilder
implements
Builder<SettingsLogSettingsLogSettingsDownloadHeaders, SettingsLogSettingsLogSettingsDownloadHeadersBuilder> {
_$SettingsLogSettingsLogSettingsDownloadHeaders? _$v;
String? _contentDisposition;
String? get contentDisposition => _$this._contentDisposition;
set contentDisposition(String? contentDisposition) => _$this._contentDisposition = contentDisposition;
SettingsLogSettingsLogSettingsDownloadHeadersBuilder();
SettingsLogSettingsLogSettingsDownloadHeadersBuilder get _$this {
final $v = _$v;
if ($v != null) {
_contentDisposition = $v.contentDisposition;
_$v = null;
}
return this;
}
@override
void replace(SettingsLogSettingsLogSettingsDownloadHeaders other) {
ArgumentError.checkNotNull(other, 'other');
_$v = other as _$SettingsLogSettingsLogSettingsDownloadHeaders;
}
@override
void update(void Function(SettingsLogSettingsLogSettingsDownloadHeadersBuilder)? updates) {
if (updates != null) updates(this);
}
@override
SettingsLogSettingsLogSettingsDownloadHeaders build() => _build();
_$SettingsLogSettingsLogSettingsDownloadHeaders _build() {
final _$result = _$v ?? _$SettingsLogSettingsLogSettingsDownloadHeaders._(contentDisposition: contentDisposition);
replace(_$result);
return _$result;
}
}
// ignore_for_file: deprecated_member_use_from_same_package,type=lint

739
packages/nextcloud/lib/src/api/theming.openapi.dart

@ -0,0 +1,739 @@
// 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 'theming.openapi.g.dart';
class ThemingResponse<T, U> extends DynamiteResponse<T, U> {
ThemingResponse(
super.data,
super.headers,
);
@override
String toString() => 'ThemingResponse(data: $data, headers: $headers)';
}
class ThemingApiException extends DynamiteApiException {
ThemingApiException(
super.statusCode,
super.headers,
super.body,
);
static Future<ThemingApiException> fromResponse(final HttpClientResponse response) async {
final data = await response.bodyBytes;
String body;
try {
body = utf8.decode(data);
} on FormatException {
body = 'binary';
}
return ThemingApiException(
response.statusCode,
response.responseHeaders,
body,
);
}
@override
String toString() => 'ThemingApiException(statusCode: $statusCode, headers: $headers, body: $body)';
}
class ThemingClient extends DynamiteClient {
ThemingClient(
super.baseURL, {
super.baseHeaders,
super.userAgent,
super.httpClient,
super.cookieJar,
super.authentications,
});
ThemingClient.fromClient(final DynamiteClient client)
: super(
client.baseURL,
baseHeaders: client.baseHeaders,
httpClient: client.httpClient,
cookieJar: client.cookieJar,
authentications: client.authentications,
);
ThemingIconClient get icon => ThemingIconClient(this);
ThemingThemingClient get theming => ThemingThemingClient(this);
ThemingUserThemeClient get userTheme => ThemingUserThemeClient(this);
}
class ThemingIconClient {
ThemingIconClient(this.rootClient);
final ThemingClient rootClient;
/// Return a 32x32 favicon as png
Future<Uint8List> getFavicon({final String app = 'core'}) async {
var path = '/index.php/apps/theming/favicon/{app}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
'Accept': 'image/x-icon',
};
Uint8List? body;
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);
}
path = path.replaceAll('{app}', Uri.encodeQueryComponent(app));
final response = await rootClient.doRequest(
'get',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
headers,
body,
);
if (response.statusCode == 200) {
return response.bodyBytes;
}
throw await ThemingApiException.fromResponse(response); // coverage:ignore-line
}
/// Return a 512x512 icon for touch devices
Future<Uint8List> getTouchIcon({final String app = 'core'}) async {
var path = '/index.php/apps/theming/icon/{app}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
'Accept': 'image/png',
};
Uint8List? body;
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);
}
path = path.replaceAll('{app}', Uri.encodeQueryComponent(app));
final response = await rootClient.doRequest(
'get',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
headers,
body,
);
if (response.statusCode == 200) {
return response.bodyBytes;
}
throw await ThemingApiException.fromResponse(response); // coverage:ignore-line
}
/// Get a themed icon
Future<Uint8List> getThemedIcon({
required final String app,
required final String image,
}) async {
var path = '/index.php/apps/theming/img/{app}/{image}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
'Accept': 'image/svg+xml',
};
Uint8List? body;
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);
}
path = path.replaceAll('{app}', Uri.encodeQueryComponent(app));
if (!RegExp(r'^.+$').hasMatch(image)) {
throw Exception('Invalid value "$image" for parameter "image" with pattern "${r'^.+$'}"'); // coverage:ignore-line
}
path = path.replaceAll('{image}', Uri.encodeQueryComponent(image));
final response = await rootClient.doRequest(
'get',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
headers,
body,
);
if (response.statusCode == 200) {
return response.bodyBytes;
}
throw await ThemingApiException.fromResponse(response); // coverage:ignore-line
}
}
/// Class ThemingController
/// handle ajax requests to update the theme
class ThemingThemingClient {
ThemingThemingClient(this.rootClient);
final ThemingClient rootClient;
/// Get the CSS stylesheet for a theme
Future<String> getThemeStylesheet({
required final String themeId,
final int plain = 0,
final int withCustomCss = 0,
}) async {
var path = '/index.php/apps/theming/theme/{themeId}.css';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
'Accept': 'text/css',
};
Uint8List? body;
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);
}
path = path.replaceAll('{themeId}', Uri.encodeQueryComponent(themeId));
if (plain != 0) {
queryParameters['plain'] = plain.toString();
}
if (withCustomCss != 0) {
queryParameters['withCustomCss'] = withCustomCss.toString();
}
final response = await rootClient.doRequest(
'get',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
headers,
body,
);
if (response.statusCode == 200) {
return response.body;
}
throw await ThemingApiException.fromResponse(response); // coverage:ignore-line
}
/// Get an image
Future<Uint8List> getImage({
required final String key,
final int useSvg = 1,
}) async {
var path = '/index.php/apps/theming/image/{key}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
'Accept': '*/*',
};
Uint8List? body;
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);
}
path = path.replaceAll('{key}', Uri.encodeQueryComponent(key));
if (useSvg != 1) {
queryParameters['useSvg'] = useSvg.toString();
}
final response = await rootClient.doRequest(
'get',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
headers,
body,
);
if (response.statusCode == 200) {
return response.bodyBytes;
}
throw await ThemingApiException.fromResponse(response); // coverage:ignore-line
}
/// Get the manifest for an app
Future<ThemingThemingGetManifestResponse200ApplicationJson> getManifest({required final String app}) async {
var path = '/index.php/apps/theming/manifest/{app}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
'Accept': 'application/json',
};
Uint8List? body;
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);
}
path = path.replaceAll('{app}', Uri.encodeQueryComponent(app));
final response = await rootClient.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(ThemingThemingGetManifestResponse200ApplicationJson),
)! as ThemingThemingGetManifestResponse200ApplicationJson;
}
throw await ThemingApiException.fromResponse(response); // coverage:ignore-line
}
}
class ThemingUserThemeClient {
ThemingUserThemeClient(this.rootClient);
final ThemingClient rootClient;
/// Get the background image
Future<Uint8List> getBackground({final String oCSAPIRequest = 'true'}) async {
const path = '/index.php/apps/theming/background';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
'Accept': '*/*',
};
Uint8List? body;
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);
} else {
throw Exception('Missing authentication for bearer_auth or basic_auth'); // coverage:ignore-line
}
headers['OCS-APIRequest'] = oCSAPIRequest;
final response = await rootClient.doRequest(
'get',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
headers,
body,
);
if (response.statusCode == 200) {
return response.bodyBytes;
}
throw await ThemingApiException.fromResponse(response); // coverage:ignore-line
}
/// Set the background
Future<ThemingBackground> setBackground({
required final String type,
final String value = '',
final String? color,
final String oCSAPIRequest = 'true',
}) async {
var path = '/index.php/apps/theming/background/{type}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
'Accept': 'application/json',
};
Uint8List? body;
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);
} else {
throw Exception('Missing authentication for bearer_auth or basic_auth'); // coverage:ignore-line
}
path = path.replaceAll('{type}', Uri.encodeQueryComponent(type));
if (value != '') {
queryParameters['value'] = value;
}
if (color != null) {
queryParameters['color'] = color;
}
headers['OCS-APIRequest'] = oCSAPIRequest;
final response = await rootClient.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(ThemingBackground))!
as ThemingBackground;
}
throw await ThemingApiException.fromResponse(response); // coverage:ignore-line
}
/// Delete the background
Future<ThemingBackground> deleteBackground({final String oCSAPIRequest = 'true'}) async {
const path = '/index.php/apps/theming/background/custom';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
'Accept': 'application/json',
};
Uint8List? body;
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);
} else {
throw Exception('Missing authentication for bearer_auth or basic_auth'); // coverage:ignore-line
}
headers['OCS-APIRequest'] = oCSAPIRequest;
final response = await rootClient.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(ThemingBackground))!
as ThemingBackground;
}
throw await ThemingApiException.fromResponse(response); // coverage:ignore-line
}
/// Enable theme
Future<ThemingUserThemeEnableThemeResponse200ApplicationJson> enableTheme({
required final String themeId,
final String oCSAPIRequest = 'true',
}) async {
var path = '/ocs/v2.php/apps/theming/api/v1/theme/{themeId}/enable';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
'Accept': 'application/json',
};
Uint8List? body;
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);
} else {
throw Exception('Missing authentication for bearer_auth or basic_auth'); // coverage:ignore-line
}
path = path.replaceAll('{themeId}', Uri.encodeQueryComponent(themeId));
headers['OCS-APIRequest'] = oCSAPIRequest;
final response = await rootClient.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(ThemingUserThemeEnableThemeResponse200ApplicationJson),
)! as ThemingUserThemeEnableThemeResponse200ApplicationJson;
}
throw await ThemingApiException.fromResponse(response); // coverage:ignore-line
}
/// Disable theme
Future<ThemingUserThemeDisableThemeResponse200ApplicationJson> disableTheme({
required final String themeId,
final String oCSAPIRequest = 'true',
}) async {
var path = '/ocs/v2.php/apps/theming/api/v1/theme/{themeId}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{
'Accept': 'application/json',
};
Uint8List? body;
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);
} else {
throw Exception('Missing authentication for bearer_auth or basic_auth'); // coverage:ignore-line
}
path = path.replaceAll('{themeId}', Uri.encodeQueryComponent(themeId));
headers['OCS-APIRequest'] = oCSAPIRequest;
final response = await rootClient.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(ThemingUserThemeDisableThemeResponse200ApplicationJson),
)! as ThemingUserThemeDisableThemeResponse200ApplicationJson;
}
throw await ThemingApiException.fromResponse(response); // coverage:ignore-line
}
}
abstract class ThemingThemingGetManifestResponse200ApplicationJson_Icons
implements
Built<ThemingThemingGetManifestResponse200ApplicationJson_Icons,
ThemingThemingGetManifestResponse200ApplicationJson_IconsBuilder> {
factory ThemingThemingGetManifestResponse200ApplicationJson_Icons([
final void Function(ThemingThemingGetManifestResponse200ApplicationJson_IconsBuilder)? b,
]) = _$ThemingThemingGetManifestResponse200ApplicationJson_Icons;
const ThemingThemingGetManifestResponse200ApplicationJson_Icons._();
factory ThemingThemingGetManifestResponse200ApplicationJson_Icons.fromJson(final Map<String, dynamic> json) =>
_jsonSerializers.deserializeWith(serializer, json)!;
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>;
String get src;
String get type;
String get sizes;
static Serializer<ThemingThemingGetManifestResponse200ApplicationJson_Icons> get serializer =>
_$themingThemingGetManifestResponse200ApplicationJsonIconsSerializer;
}
abstract class ThemingThemingGetManifestResponse200ApplicationJson
implements
Built<ThemingThemingGetManifestResponse200ApplicationJson,
ThemingThemingGetManifestResponse200ApplicationJsonBuilder> {
factory ThemingThemingGetManifestResponse200ApplicationJson([
final void Function(ThemingThemingGetManifestResponse200ApplicationJsonBuilder)? b,
]) = _$ThemingThemingGetManifestResponse200ApplicationJson;
const ThemingThemingGetManifestResponse200ApplicationJson._();
factory ThemingThemingGetManifestResponse200ApplicationJson.fromJson(final Map<String, dynamic> json) =>
_jsonSerializers.deserializeWith(serializer, json)!;
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>;
String get name;
@BuiltValueField(wireName: 'short_name')
String get shortName;
@BuiltValueField(wireName: 'start_url')
String get startUrl;
@BuiltValueField(wireName: 'theme_color')
String get themeColor;
@BuiltValueField(wireName: 'background_color')
String get backgroundColor;
String get description;
BuiltList<ThemingThemingGetManifestResponse200ApplicationJson_Icons> get icons;
String get display;
static Serializer<ThemingThemingGetManifestResponse200ApplicationJson> get serializer =>
_$themingThemingGetManifestResponse200ApplicationJsonSerializer;
}
abstract class ThemingBackground implements Built<ThemingBackground, ThemingBackgroundBuilder> {
factory ThemingBackground([final void Function(ThemingBackgroundBuilder)? b]) = _$ThemingBackground;
const ThemingBackground._();
factory ThemingBackground.fromJson(final Map<String, dynamic> json) =>
_jsonSerializers.deserializeWith(serializer, json)!;
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>;
String? get backgroundImage;
String get backgroundColor;
int get version;
static Serializer<ThemingBackground> get serializer => _$themingBackgroundSerializer;
}
abstract class ThemingOCSMeta implements Built<ThemingOCSMeta, ThemingOCSMetaBuilder> {
factory ThemingOCSMeta([final void Function(ThemingOCSMetaBuilder)? b]) = _$ThemingOCSMeta;
const ThemingOCSMeta._();
factory ThemingOCSMeta.fromJson(final Map<String, dynamic> json) =>
_jsonSerializers.deserializeWith(serializer, json)!;
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>;
String get status;
int get statuscode;
String? get message;
String? get totalitems;
String? get itemsperpage;
static Serializer<ThemingOCSMeta> get serializer => _$themingOCSMetaSerializer;
}
abstract class ThemingUserThemeEnableThemeResponse200ApplicationJson_Ocs
implements
Built<ThemingUserThemeEnableThemeResponse200ApplicationJson_Ocs,
ThemingUserThemeEnableThemeResponse200ApplicationJson_OcsBuilder> {
factory ThemingUserThemeEnableThemeResponse200ApplicationJson_Ocs([
final void Function(ThemingUserThemeEnableThemeResponse200ApplicationJson_OcsBuilder)? b,
]) = _$ThemingUserThemeEnableThemeResponse200ApplicationJson_Ocs;
const ThemingUserThemeEnableThemeResponse200ApplicationJson_Ocs._();
factory ThemingUserThemeEnableThemeResponse200ApplicationJson_Ocs.fromJson(final Map<String, dynamic> json) =>
_jsonSerializers.deserializeWith(serializer, json)!;
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>;
ThemingOCSMeta get meta;
JsonObject get data;
static Serializer<ThemingUserThemeEnableThemeResponse200ApplicationJson_Ocs> get serializer =>
_$themingUserThemeEnableThemeResponse200ApplicationJsonOcsSerializer;
}
abstract class ThemingUserThemeEnableThemeResponse200ApplicationJson
implements
Built<ThemingUserThemeEnableThemeResponse200ApplicationJson,
ThemingUserThemeEnableThemeResponse200ApplicationJsonBuilder> {
factory ThemingUserThemeEnableThemeResponse200ApplicationJson([
final void Function(ThemingUserThemeEnableThemeResponse200ApplicationJsonBuilder)? b,
]) = _$ThemingUserThemeEnableThemeResponse200ApplicationJson;
const ThemingUserThemeEnableThemeResponse200ApplicationJson._();
factory ThemingUserThemeEnableThemeResponse200ApplicationJson.fromJson(final Map<String, dynamic> json) =>
_jsonSerializers.deserializeWith(serializer, json)!;
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>;
ThemingUserThemeEnableThemeResponse200ApplicationJson_Ocs get ocs;
static Serializer<ThemingUserThemeEnableThemeResponse200ApplicationJson> get serializer =>
_$themingUserThemeEnableThemeResponse200ApplicationJsonSerializer;
}
abstract class ThemingUserThemeDisableThemeResponse200ApplicationJson_Ocs
implements
Built<ThemingUserThemeDisableThemeResponse200ApplicationJson_Ocs,
ThemingUserThemeDisableThemeResponse200ApplicationJson_OcsBuilder> {
factory ThemingUserThemeDisableThemeResponse200ApplicationJson_Ocs([
final void Function(ThemingUserThemeDisableThemeResponse200ApplicationJson_OcsBuilder)? b,
]) = _$ThemingUserThemeDisableThemeResponse200ApplicationJson_Ocs;
const ThemingUserThemeDisableThemeResponse200ApplicationJson_Ocs._();
factory ThemingUserThemeDisableThemeResponse200ApplicationJson_Ocs.fromJson(final Map<String, dynamic> json) =>
_jsonSerializers.deserializeWith(serializer, json)!;
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>;
ThemingOCSMeta get meta;
JsonObject get data;
static Serializer<ThemingUserThemeDisableThemeResponse200ApplicationJson_Ocs> get serializer =>
_$themingUserThemeDisableThemeResponse200ApplicationJsonOcsSerializer;
}
abstract class ThemingUserThemeDisableThemeResponse200ApplicationJson
implements
Built<ThemingUserThemeDisableThemeResponse200ApplicationJson,
ThemingUserThemeDisableThemeResponse200ApplicationJsonBuilder> {
factory ThemingUserThemeDisableThemeResponse200ApplicationJson([
final void Function(ThemingUserThemeDisableThemeResponse200ApplicationJsonBuilder)? b,
]) = _$ThemingUserThemeDisableThemeResponse200ApplicationJson;
const ThemingUserThemeDisableThemeResponse200ApplicationJson._();
factory ThemingUserThemeDisableThemeResponse200ApplicationJson.fromJson(final Map<String, dynamic> json) =>
_jsonSerializers.deserializeWith(serializer, json)!;
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>;
ThemingUserThemeDisableThemeResponse200ApplicationJson_Ocs get ocs;
static Serializer<ThemingUserThemeDisableThemeResponse200ApplicationJson> get serializer =>
_$themingUserThemeDisableThemeResponse200ApplicationJsonSerializer;
}
abstract class ThemingPublicCapabilities_Theming
implements Built<ThemingPublicCapabilities_Theming, ThemingPublicCapabilities_ThemingBuilder> {
factory ThemingPublicCapabilities_Theming([final void Function(ThemingPublicCapabilities_ThemingBuilder)? b]) =
_$ThemingPublicCapabilities_Theming;
const ThemingPublicCapabilities_Theming._();
factory ThemingPublicCapabilities_Theming.fromJson(final Map<String, dynamic> json) =>
_jsonSerializers.deserializeWith(serializer, json)!;
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>;
String get name;
String get url;
String get slogan;
String get color;
@BuiltValueField(wireName: 'color-text')
String get colorText;
@BuiltValueField(wireName: 'color-element')
String get colorElement;
@BuiltValueField(wireName: 'color-element-bright')
String get colorElementBright;
@BuiltValueField(wireName: 'color-element-dark')
String get colorElementDark;
String get logo;
String get background;
@BuiltValueField(wireName: 'background-plain')
bool get backgroundPlain;
@BuiltValueField(wireName: 'background-default')
bool get backgroundDefault;
String get logoheader;
String get favicon;
static Serializer<ThemingPublicCapabilities_Theming> get serializer => _$themingPublicCapabilitiesThemingSerializer;
}
abstract class ThemingPublicCapabilities implements Built<ThemingPublicCapabilities, ThemingPublicCapabilitiesBuilder> {
factory ThemingPublicCapabilities([final void Function(ThemingPublicCapabilitiesBuilder)? b]) =
_$ThemingPublicCapabilities;
const ThemingPublicCapabilities._();
factory ThemingPublicCapabilities.fromJson(final Map<String, dynamic> json) =>
_jsonSerializers.deserializeWith(serializer, json)!;
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>;
ThemingPublicCapabilities_Theming get theming;
static Serializer<ThemingPublicCapabilities> get serializer => _$themingPublicCapabilitiesSerializer;
}
final Serializers _serializers = (Serializers().toBuilder()
..addBuilderFactory(
const FullType(ThemingThemingGetManifestResponse200ApplicationJson),
ThemingThemingGetManifestResponse200ApplicationJson.new,
)
..add(ThemingThemingGetManifestResponse200ApplicationJson.serializer)
..addBuilderFactory(
const FullType(ThemingThemingGetManifestResponse200ApplicationJson_Icons),
ThemingThemingGetManifestResponse200ApplicationJson_Icons.new,
)
..add(ThemingThemingGetManifestResponse200ApplicationJson_Icons.serializer)
..addBuilderFactory(
const FullType(BuiltList, [FullType(ThemingThemingGetManifestResponse200ApplicationJson_Icons)]),
ListBuilder<ThemingThemingGetManifestResponse200ApplicationJson_Icons>.new,
)
..addBuilderFactory(const FullType(ThemingBackground), ThemingBackground.new)
..add(ThemingBackground.serializer)
..addBuilderFactory(
const FullType(ThemingUserThemeEnableThemeResponse200ApplicationJson),
ThemingUserThemeEnableThemeResponse200ApplicationJson.new,
)
..add(ThemingUserThemeEnableThemeResponse200ApplicationJson.serializer)
..addBuilderFactory(
const FullType(ThemingUserThemeEnableThemeResponse200ApplicationJson_Ocs),
ThemingUserThemeEnableThemeResponse200ApplicationJson_Ocs.new,
)
..add(ThemingUserThemeEnableThemeResponse200ApplicationJson_Ocs.serializer)
..addBuilderFactory(const FullType(ThemingOCSMeta), ThemingOCSMeta.new)
..add(ThemingOCSMeta.serializer)
..addBuilderFactory(
const FullType(ThemingUserThemeDisableThemeResponse200ApplicationJson),
ThemingUserThemeDisableThemeResponse200ApplicationJson.new,
)
..add(ThemingUserThemeDisableThemeResponse200ApplicationJson.serializer)
..addBuilderFactory(
const FullType(ThemingUserThemeDisableThemeResponse200ApplicationJson_Ocs),
ThemingUserThemeDisableThemeResponse200ApplicationJson_Ocs.new,
)
..add(ThemingUserThemeDisableThemeResponse200ApplicationJson_Ocs.serializer)
..addBuilderFactory(const FullType(ThemingPublicCapabilities), ThemingPublicCapabilities.new)
..add(ThemingPublicCapabilities.serializer)
..addBuilderFactory(const FullType(ThemingPublicCapabilities_Theming), ThemingPublicCapabilities_Theming.new)
..add(ThemingPublicCapabilities_Theming.serializer))
.build();
Serializers get themingSerializers => _serializers;
final Serializers _jsonSerializers = (_serializers.toBuilder()
..addPlugin(StandardJsonPlugin())
..addPlugin(const ContentStringPlugin()))
.build();
// coverage:ignore-start
T deserializeTheming<T>(final Object data) => _serializers.deserialize(data, specifiedType: FullType(T))! as T;
Object? serializeTheming<T>(final T data) => _serializers.serialize(data, specifiedType: FullType(T));
// coverage:ignore-end

1961
packages/nextcloud/lib/src/api/theming.openapi.g.dart

File diff suppressed because it is too large Load Diff

1352
packages/nextcloud/lib/src/api/user_status.openapi.dart

File diff suppressed because it is too large Load Diff

3899
packages/nextcloud/lib/src/api/user_status.openapi.g.dart

File diff suppressed because it is too large Load Diff

21
packages/nextcloud/lib/src/client.dart

@ -6,6 +6,8 @@ import 'package:nextcloud/src/api/news.openapi.dart';
import 'package:nextcloud/src/api/notes.openapi.dart';
import 'package:nextcloud/src/api/notifications.openapi.dart';
import 'package:nextcloud/src/api/provisioning_api.openapi.dart';
import 'package:nextcloud/src/api/settings.openapi.dart';
import 'package:nextcloud/src/api/theming.openapi.dart';
import 'package:nextcloud/src/api/uppush.openapi.dart';
import 'package:nextcloud/src/api/user_status.openapi.dart';
import 'package:nextcloud/src/app_type.dart';
@ -18,22 +20,27 @@ class NextcloudClient extends DynamiteClient {
super.baseURL, {
this.loginName,
final String? password,
final String? appPassword,
final String? language,
final AppType appType = AppType.unknown,
final String? userAgentOverride,
super.cookieJar,
}) : super(
baseHeaders: (<String, String?>{
'OCS-APIRequest': 'true',
'Accept-Language': language,
}..removeWhere((final _, final value) => value == null))
.cast<String, String>(),
userAgent: userAgentOverride ?? appType.userAgent,
authentications: [
if (loginName != null && password != null) ...[
if (appPassword != null) ...[
DynamiteHttpBearerAuthentication(
token: appPassword,
),
],
if (loginName != null && (password ?? appPassword) != null) ...[
DynamiteHttpBasicAuthentication(
username: loginName,
password: password,
password: (password ?? appPassword)!,
),
],
],
@ -50,6 +57,8 @@ class NextcloudClient extends DynamiteClient {
ProvisioningApiClient? _provisioningApi;
UppushClient? _uppush;
UserStatusClient? _userStatus;
SettingsClient? _settings;
ThemingClient? _theming;
/// Client for WebDAV
WebDavClient get webdav => _webdav ??= WebDavClient(this);
@ -74,6 +83,12 @@ class NextcloudClient extends DynamiteClient {
/// Client for the user status APIs
UserStatusClient get userStatus => _userStatus ??= UserStatusClient.fromClient(this);
/// Client for the settings APIs
SettingsClient get settings => _settings ??= SettingsClient.fromClient(this);
/// Client for the theming APIs
ThemingClient get theming => _theming ??= ThemingClient.fromClient(this);
}
// ignore: public_member_api_docs

54
packages/nextcloud/lib/src/helpers.dart

@ -1,54 +0,0 @@
// ignore_for_file: public_member_api_docs
import 'dart:convert';
import 'package:crypto/crypto.dart';
import 'package:crypton/crypton.dart';
import 'package:nextcloud/src/api/notifications.openapi.dart';
/// Generates the push token hash which is just sha512
String generatePushTokenHash(final String pushToken) => sha512.convert(utf8.encode(pushToken)).toString();
/// Decrypts the subject of a push notification
NotificationsNotificationDecryptedSubject decryptPushNotificationSubject(
final RSAPrivateKey privateKey,
final String subject,
) =>
NotificationsNotificationDecryptedSubject.fromJson(
json.decode(privateKey.decrypt(subject)) as Map<String, dynamic>,
);
/// See https://github.com/nextcloud/news/blob/4a107b3d53c4fe651ac704251b99e04a53cd587f/lib/Db/ListType.php
enum NewsListType {
feed(0),
folder(1),
starred(2),
allItems(3),
shared(4),
explore(5),
unread(6);
const NewsListType(this.code);
final int code;
}
enum ShareType {
user(0),
group(1),
usergroup(2),
link(3),
email(4),
// 5 was contact, is no longer used
remote(6),
circle(7),
guest(8),
remoteGroup(9),
room(10),
// 11 is userroom, but it's only used internally
deck(12),
deckUser(13);
const ShareType(this.code);
final int code;
}

20
packages/nextcloud/lib/src/helpers/core.dart

@ -0,0 +1,20 @@
// ignore_for_file: public_member_api_docs
enum ShareType {
user,
group,
usergroup,
link,
email,
@Deprecated('No longer used')
contact,
remote,
circle,
guest,
remoteGroup,
room,
@Deprecated('Only used internally')
userroom,
deck,
deckUser,
}

12
packages/nextcloud/lib/src/helpers/news.dart

@ -0,0 +1,12 @@
// ignore_for_file: public_member_api_docs
/// See https://github.com/nextcloud/news/blob/4a107b3d53c4fe651ac704251b99e04a53cd587f/lib/Db/ListType.php
enum NewsListType {
feed,
folder,
starred,
allItems,
shared,
explore,
unread,
}

63
packages/nextcloud/lib/src/helpers/notifications.dart

@ -0,0 +1,63 @@
import 'dart:convert';
import 'package:crypto/crypto.dart';
import 'package:crypton/crypton.dart';
import 'package:json_annotation/json_annotation.dart';
part 'notifications.g.dart';
/// Generates the push token hash which is just sha512
String generatePushTokenHash(final String pushToken) => sha512.convert(utf8.encode(pushToken)).toString();
@JsonSerializable()
// ignore: public_member_api_docs
class NotificationsDecryptedSubject {
// ignore: public_member_api_docs
NotificationsDecryptedSubject({
this.nid,
this.app,
this.subject,
this.type,
this.id,
this.delete,
this.deleteAll,
});
// ignore: public_member_api_docs
factory NotificationsDecryptedSubject.fromJson(final Map<String, dynamic> json) =>
_$NotificationsDecryptedSubjectFromJson(json);
/// ID if the notification
final int? nid;
/// App that sent the notification
final String? app;
/// Subject of the notification
final String? subject;
/// Type of the notification
final String? type;
/// ID of the notification
final String? id;
/// Delete the notification
final bool? delete;
/// Delete all notifications
@JsonKey(name: 'delete-all')
final bool? deleteAll;
// ignore: public_member_api_docs
Map<String, dynamic> toJson() => _$NotificationsDecryptedSubjectToJson(this);
}
/// Decrypts the subject of a push notification
NotificationsDecryptedSubject decryptPushNotificationSubject(
final RSAPrivateKey privateKey,
final String subject,
) =>
NotificationsDecryptedSubject.fromJson(
json.decode(privateKey.decrypt(subject)) as Map<String, dynamic>,
);

28
packages/nextcloud/lib/src/helpers/notifications.g.dart

@ -0,0 +1,28 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'notifications.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
NotificationsDecryptedSubject _$NotificationsDecryptedSubjectFromJson(Map<String, dynamic> json) =>
NotificationsDecryptedSubject(
nid: json['nid'] as int?,
app: json['app'] as String?,
subject: json['subject'] as String?,
type: json['type'] as String?,
id: json['id'] as String?,
delete: json['delete'] as bool?,
deleteAll: json['delete-all'] as bool?,
);
Map<String, dynamic> _$NotificationsDecryptedSubjectToJson(NotificationsDecryptedSubject instance) => <String, dynamic>{
'nid': instance.nid,
'app': instance.app,
'subject': instance.subject,
'type': instance.type,
'id': instance.id,
'delete': instance.delete,
'delete-all': instance.deleteAll,
};

6
packages/nextcloud/lib/src/version_supported.dart

@ -17,14 +17,14 @@ extension CoreVersionSupported on CoreClient {
/// Check if the core/Server version is supported by this client
///
/// Also returns the supported version number
(bool, int) isSupported(final CoreServerCapabilities_Ocs_Data capabilities) => (
(bool, int) isSupported(final CoreOcsGetCapabilitiesResponse200ApplicationJson_Ocs_Data capabilities) => (
capabilities.version.major == coreSupportedVersion,
coreSupportedVersion,
);
}
// ignore: public_member_api_docs
extension CoreStatusVersionSupported on CoreServerStatus {
extension CoreStatusVersionSupported on CoreStatus {
/// Check if the core/Server version is supported
bool get isSupported => version.startsWith('$coreSupportedVersion.');
}
@ -48,7 +48,7 @@ extension NotesVersionSupported on NotesClient {
/// Check if the notes app version is supported by this client
///
/// Also returns the supported API version number
(bool, int) isSupported(final CoreServerCapabilities_Ocs_Data capabilities) => (
(bool, int) isSupported(final CoreOcsGetCapabilitiesResponse200ApplicationJson_Ocs_Data capabilities) => (
capabilities.capabilities.notes?.apiVersion
?.map(Version.parse)
.where((final version) => version.major == notesSupportedVersion)

2
packages/nextcloud/pubspec.yaml

@ -15,6 +15,7 @@ dependencies:
url: https://github.com/provokateurin/nextcloud-neon
path: packages/dynamite/dynamite_runtime
intl: ^0.18.0
json_annotation: ^4.8.1
universal_io: ^2.2.0
version: ^3.0.2
xml: ^6.3.0
@ -28,6 +29,7 @@ dev_dependencies:
git:
url: https://github.com/provokateurin/nextcloud-neon
path: packages/dynamite/dynamite
json_serializable: ^6.6.2
nit_picking:
git:
url: https://github.com/stack11/dart_nit_picking

49
packages/nextcloud/test/core_test.dart

@ -20,7 +20,7 @@ void main() {
tearDown(() => container.destroy());
test('Is supported from capabilities', () async {
final (supported, _) = client.core.isSupported((await client.core.getCapabilities()).ocs.data);
final (supported, _) = client.core.isSupported((await client.core.ocs.getCapabilities()).ocs.data);
expect(supported, isTrue);
});
@ -42,7 +42,7 @@ void main() {
});
test('Get capabilities', () async {
final capabilities = await client.core.getCapabilities();
final capabilities = await client.core.ocs.getCapabilities();
expect(capabilities.ocs.data.version.major, coreSupportedVersion);
expect(capabilities.ocs.data.version.string, startsWith('$coreSupportedVersion.'));
expect(capabilities.ocs.data.capabilities.theming!.name, 'Nextcloud');
@ -59,7 +59,7 @@ void main() {
});
test('Get navigation apps', () async {
final navigationApps = await client.core.getNavigationApps();
final navigationApps = await client.core.navigation.getAppsNavigation();
expect(navigationApps.ocs.data, hasLength(6));
expect(navigationApps.ocs.data[0].id, 'dashboard');
expect(navigationApps.ocs.data[1].id, 'files');
@ -69,14 +69,16 @@ void main() {
expect(navigationApps.ocs.data[5].id, 'news');
});
test('Autocomplete', () async {
final response = await client.core.autocomplete(
test(
'Autocomplete',
() async {
final response = await client.core.autoComplete.$get(
search: '',
itemType: 'call',
itemId: 'new',
shareTypes: [
ShareType.user.code,
ShareType.group.code,
ShareType.user.index,
ShareType.group.index,
],
);
expect(response.ocs.data, hasLength(3));
@ -85,7 +87,7 @@ void main() {
expect(response.ocs.data[0].label, 'admin');
expect(response.ocs.data[0].icon, 'icon-user');
expect(response.ocs.data[0].source, 'users');
expect(response.ocs.data[0].status.string, isNull);
expect(response.ocs.data[0].status, isEmpty);
expect(response.ocs.data[0].subline, '');
expect(response.ocs.data[0].shareWithDisplayNameUnique, 'admin@example.com');
@ -93,7 +95,7 @@ void main() {
expect(response.ocs.data[1].label, 'User Two');
expect(response.ocs.data[1].icon, 'icon-user');
expect(response.ocs.data[1].source, 'users');
expect(response.ocs.data[1].status.string, isNull);
expect(response.ocs.data[1].status, isEmpty);
expect(response.ocs.data[1].subline, '');
expect(response.ocs.data[1].shareWithDisplayNameUnique, 'user2');
@ -101,46 +103,43 @@ void main() {
expect(response.ocs.data[2].label, 'admin');
expect(response.ocs.data[2].icon, '');
expect(response.ocs.data[2].source, 'groups');
expect(response.ocs.data[2].status.string, isEmpty);
expect(response.ocs.data[2].status, isEmpty);
expect(response.ocs.data[2].subline, '');
expect(response.ocs.data[2].shareWithDisplayNameUnique, '');
});
},
skip: true, // TODO: This test only works on 28+ due to a bug fix with the status
);
test('Get preview', () async {
final response = await client.core.getPreview(file: 'Nextcloud.png');
final response = await client.core.preview.getPreview(file: 'Nextcloud.png');
expect(response, isNotEmpty);
});
test('Get avatar', () async {
final response = await client.core.getAvatar(userId: 'admin', size: 32);
expect(response, isNotEmpty);
final response = await client.core.avatar.getAvatar(userId: 'admin', size: 32);
expect(response.data, isNotEmpty);
});
test('Get dark avatar', () async {
final response = await client.core.getDarkAvatar(userId: 'admin', size: 32);
expect(response, isNotEmpty);
final response = await client.core.avatar.getAvatarDark(userId: 'admin', size: 32);
expect(response.data, isNotEmpty);
});
test('Delete app password', () async {
client = await getTestClient(
container,
useAppPassword: true,
);
await client.core.deleteAppPassword();
await client.core.appPassword.deleteAppPassword();
expect(
() => client.core.getCapabilities(),
() => client.core.appPassword.deleteAppPassword(),
throwsA(predicate((final e) => (e! as DynamiteApiException).statusCode == 401)),
);
});
test('Unified search providers', () async {
final response = await client.core.unifiedSearchProviders();
final response = await client.core.unifiedSearch.getProviders();
expect(response.ocs.data, hasLength(13));
});
test('Unified search', () async {
final response = await client.core.unifiedSearch(
final response = await client.core.unifiedSearch.search(
providerId: 'settings',
term: 'Personal info',
);

28
packages/nextcloud/test/helper.dart

@ -46,8 +46,7 @@ class DockerContainer {
),
);
Future<String> collectLogs() async {
final serverLogs = (await runExecutableArguments(
Future<String> serverLogs() async => (await runExecutableArguments(
'docker',
[
'logs',
@ -56,7 +55,8 @@ class DockerContainer {
stdoutEncoding: utf8,
))
.stdout as String;
final nextcloudLogs = (await runExecutableArguments(
Future<String> nextcloudLogs() async => (await runExecutableArguments(
'docker',
[
'exec',
@ -68,8 +68,7 @@ class DockerContainer {
))
.stdout as String;
return '$serverLogs\n\n$nextcloudLogs';
}
Future<String> allLogs() async => '${await serverLogs()}\n\n${await nextcloudLogs()}';
}
class TestNextcloudClient extends NextcloudClient {
@ -77,6 +76,7 @@ class TestNextcloudClient extends NextcloudClient {
super.baseURL, {
super.loginName,
super.password,
super.appPassword,
super.language,
super.appType,
super.userAgentOverride,
@ -87,16 +87,11 @@ class TestNextcloudClient extends NextcloudClient {
Future<TestNextcloudClient> getTestClient(
final DockerContainer container, {
final String? username = 'user1',
final String? password = 'user1',
final bool useAppPassword = false,
final AppType appType = AppType.unknown,
final String? userAgentOverride,
}) async {
// ignore: prefer_asserts_with_message
assert(!useAppPassword || (username != null && password != null));
var clientPassword = password;
if (useAppPassword) {
String? appPassword;
if (username != null) {
final inputStream = StreamController<List<int>>();
final process = runExecutableArguments(
'docker',
@ -108,24 +103,25 @@ Future<TestNextcloudClient> getTestClient(
'-f',
'occ',
'user:add-app-password',
username!,
username,
],
stdin: inputStream.stream,
);
inputStream.add(utf8.encode(password!));
inputStream.add(utf8.encode(username));
await inputStream.close();
final result = await process;
if (result.exitCode != 0) {
throw Exception('Failed to run generate app password command\n${result.stderr}\n${result.stdout}');
}
clientPassword = (result.stdout as String).split('\n')[1];
appPassword = (result.stdout as String).split('\n')[1];
}
final client = TestNextcloudClient(
'http://localhost:${container.port}',
loginName: username,
password: clientPassword,
password: username,
appPassword: appPassword,
appType: appType,
userAgentOverride: userAgentOverride,
cookieJar: CookieJar(),

26
packages/nextcloud/test/news_test.dart

@ -92,7 +92,7 @@ void main() {
test('Mark feed as read', () async {
final feedsResponse = await addWikipediaFeed();
var articlesResponse = await client.news.listArticles(type: NewsListType.unread.code);
var articlesResponse = await client.news.listArticles(type: NewsListType.unread.index);
expect(articlesResponse.items.length, greaterThan(0));
await client.news.markFeedAsRead(
@ -100,7 +100,7 @@ void main() {
newestItemId: feedsResponse.newestItemId!,
);
articlesResponse = await client.news.listArticles(type: NewsListType.unread.code);
articlesResponse = await client.news.listArticles(type: NewsListType.unread.index);
expect(articlesResponse.items, hasLength(0));
});
@ -145,36 +145,36 @@ void main() {
test('Mark article as read', () async {
await addWikipediaFeed();
var response = await client.news.listArticles(type: NewsListType.unread.code);
var response = await client.news.listArticles(type: NewsListType.unread.index);
final unreadArticles = response.items.length;
expect(unreadArticles, greaterThan(0));
await client.news.markArticleAsRead(
itemId: response.items[0].id,
);
response = await client.news.listArticles(type: NewsListType.unread.code);
response = await client.news.listArticles(type: NewsListType.unread.index);
expect(response.items, hasLength(unreadArticles - 1));
});
test('Mark article as unread', () async {
await addWikipediaFeed();
var response = await client.news.listArticles(type: NewsListType.unread.code);
var response = await client.news.listArticles(type: NewsListType.unread.index);
final readArticle = response.items[0];
await client.news.markArticleAsRead(itemId: readArticle.id);
response = await client.news.listArticles(type: NewsListType.unread.code);
response = await client.news.listArticles(type: NewsListType.unread.index);
final unreadArticles = response.items.length;
expect(unreadArticles, greaterThan(0));
await client.news.markArticleAsUnread(itemId: readArticle.id);
response = await client.news.listArticles(type: NewsListType.unread.code);
response = await client.news.listArticles(type: NewsListType.unread.index);
expect(response.items, hasLength(unreadArticles + 1));
});
test('Star article', () async {
await addWikipediaFeed();
var response = await client.news.listArticles(type: NewsListType.starred.code);
var response = await client.news.listArticles(type: NewsListType.starred.index);
final starredArticles = response.items.length;
expect(starredArticles, 0);
@ -182,7 +182,7 @@ void main() {
await client.news.starArticle(
itemId: response.items[0].id,
);
response = await client.news.listArticles(type: NewsListType.starred.code);
response = await client.news.listArticles(type: NewsListType.starred.index);
expect(response.items, hasLength(1));
});
@ -195,13 +195,13 @@ void main() {
await client.news.starArticle(
itemId: item.id,
);
response = await client.news.listArticles(type: NewsListType.starred.code);
response = await client.news.listArticles(type: NewsListType.starred.index);
expect(response.items, hasLength(1));
await client.news.unstarArticle(
itemId: item.id,
);
response = await client.news.listArticles(type: NewsListType.starred.code);
response = await client.news.listArticles(type: NewsListType.starred.index);
expect(response.items, hasLength(0));
});
@ -257,7 +257,7 @@ void main() {
final foldersResponse = await client.news.createFolder(name: 'test1');
final feedsResponse = await addWikipediaFeed(1);
var articlesResponse = await client.news.listArticles(type: NewsListType.unread.code);
var articlesResponse = await client.news.listArticles(type: NewsListType.unread.index);
expect(articlesResponse.items.length, greaterThan(0));
await client.news.markFolderAsRead(
@ -265,7 +265,7 @@ void main() {
newestItemId: feedsResponse.newestItemId!,
);
articlesResponse = await client.news.listArticles(type: NewsListType.unread.code);
articlesResponse = await client.news.listArticles(type: NewsListType.unread.index);
expect(articlesResponse.items, hasLength(0));
});
});

2
packages/nextcloud/test/notes_test.dart

@ -20,7 +20,7 @@ void main() {
tearDown(() => container.destroy());
test('Is supported', () async {
final (supported, _) = client.notes.isSupported((await client.core.getCapabilities()).ocs.data);
final (supported, _) = client.notes.isSupported((await client.core.ocs.getCapabilities()).ocs.data);
expect(supported, isTrue);
});

15
packages/nextcloud/test/notifications_test.dart

@ -20,7 +20,6 @@ void main() {
client = await getTestClient(
container,
username: 'admin',
password: 'admin',
);
});
tearDown(() => container.destroy());
@ -42,8 +41,8 @@ void main() {
final startTime = DateTime.now().toUtc();
final response = await client.notifications.listNotifications();
expect(response.ocs.data, hasLength(1));
expect(response.ocs.data[0].notificationId, 1);
expect(response.ocs.data, hasLength(2));
expect(response.ocs.data[0].notificationId, 2);
expect(response.ocs.data[0].app, 'admin_notifications');
expect(response.ocs.data[0].user, 'admin');
expectDateInReasonableTimeRange(DateTime.parse(response.ocs.data[0].datetime), startTime);
@ -64,8 +63,8 @@ void main() {
await sendTestNotification();
final startTime = DateTime.now().toUtc();
final response = await client.notifications.getNotification(id: 1);
expect(response.ocs.data.notificationId, 1);
final response = await client.notifications.getNotification(id: 2);
expect(response.ocs.data.notificationId, 2);
expect(response.ocs.data.app, 'admin_notifications');
expect(response.ocs.data.user, 'admin');
expectDateInReasonableTimeRange(DateTime.parse(response.ocs.data.datetime), startTime);
@ -84,10 +83,10 @@ void main() {
test('Delete notification', () async {
await sendTestNotification();
await client.notifications.deleteNotification(id: 1);
await client.notifications.deleteNotification(id: 2);
final response = await client.notifications.listNotifications();
expect(response.ocs.data, hasLength(0));
expect(response.ocs.data, hasLength(1));
});
test('Delete all notifications', () async {
@ -111,8 +110,6 @@ void main() {
client = await getTestClient(
container,
username: 'admin',
// We need to use app passwords in order to register push devices
useAppPassword: true,
);
});
tearDown(() => container.destroy());

29
packages/nextcloud/test/provisioning_api_test.dart

@ -14,24 +14,41 @@ void main() {
late TestNextcloudClient client;
setUp(() async {
container = await getDockerContainer(image);
client = await getTestClient(container);
client = await getTestClient(
container,
username: 'admin',
);
});
tearDown(() => container.destroy());
group('Users', () {
test('Get current user', () async {
final user = await client.provisioningApi.getCurrentUser();
expect(user.ocs.data.id, 'user1');
expect(user.ocs.data.displayname, 'User One');
final user = await client.provisioningApi.users.getCurrentUser();
expect(user.ocs.data.id, 'admin');
expect(user.ocs.data.displayName, 'admin');
expect(user.ocs.data.displaynameScope, 'v2-federated');
expect(user.ocs.data.language, 'en');
});
test('Get user by username', () async {
final user = await client.provisioningApi.getUser(userId: 'user1');
final user = await client.provisioningApi.users.getUser(userId: 'user1');
expect(user.ocs.data.id, 'user1');
expect(user.ocs.data.displayname, 'User One');
expect(user.ocs.data.displaynameScope, 'v2-federated');
expect(user.ocs.data.displaynameScope, null);
expect(user.ocs.data.language, 'en');
});
});
group('Apps', () {
test('Get apps', () async {
final response = await client.provisioningApi.apps.getApps();
expect(response.ocs.data.apps, hasLength(39));
for (final id in response.ocs.data.apps) {
final app = await client.provisioningApi.apps.getAppInfo(app: id);
expect(app.ocs.data.id, isNotEmpty);
}
});
});
});
}

29
packages/nextcloud/test/settings_test.dart

@ -0,0 +1,29 @@
import 'dart:convert';
import 'package:test/test.dart';
import 'helper.dart';
Future main() async {
await run(await getDockerImage());
}
Future run(final DockerImage image) async {
group('settings', () {
late DockerContainer container;
late TestNextcloudClient client;
setUp(() async {
container = await getDockerContainer(image);
client = await getTestClient(
container,
username: 'admin',
);
});
tearDown(() => container.destroy());
test('Download log file', () async {
final response = utf8.decode((await client.settings.logSettings.download()).data);
expect(response, await container.nextcloudLogs());
});
});
}

1
packages/nextcloud/test/uppush_test.dart

@ -17,7 +17,6 @@ void main() {
client = await getTestClient(
container,
username: 'admin',
password: 'admin',
);
});
tearDown(() => container.destroy());

158
packages/nextcloud/test/user_status_test.dart

@ -21,7 +21,7 @@ void main() {
test('Find all predefined statuses', () async {
final expectedStatusIDs = ['meeting', 'commuting', 'remote-work', 'sick-leave', 'vacationing'];
final response = await client.userStatus.getPredefinedStatuses();
final response = await client.userStatus.predefinedStatus.findAll();
expect(response.ocs.data, hasLength(5));
final responseIDs = response.ocs.data.map((final status) => status.id);
expect(expectedStatusIDs.map(responseIDs.contains).contains(false), false);
@ -30,145 +30,145 @@ void main() {
expect(status.message, isNotNull);
}
final meeting = response.ocs.data.singleWhere((final s) => s.id == 'meeting').clearAt!.clearAt!;
final meeting = response.ocs.data.singleWhere((final s) => s.id == 'meeting').clearAt!;
expect(meeting.type, UserStatusClearAt_Type.period);
expect(meeting.time.$int, 3600);
final commuting = response.ocs.data.singleWhere((final s) => s.id == 'commuting').clearAt!.clearAt!;
final commuting = response.ocs.data.singleWhere((final s) => s.id == 'commuting').clearAt!;
expect(commuting.type, UserStatusClearAt_Type.period);
expect(commuting.time.$int, 1800);
final remoteWork = response.ocs.data.singleWhere((final s) => s.id == 'remote-work').clearAt!.clearAt!;
final remoteWork = response.ocs.data.singleWhere((final s) => s.id == 'remote-work').clearAt!;
expect(remoteWork.type, UserStatusClearAt_Type.endOf);
expect(remoteWork.time.clearAtTime0, UserStatusClearAt_Time0.day);
expect(remoteWork.time.clearAtTimeType, UserStatusClearAtTimeType.day);
final sickLeave = response.ocs.data.singleWhere((final s) => s.id == 'sick-leave').clearAt!.clearAt!;
final sickLeave = response.ocs.data.singleWhere((final s) => s.id == 'sick-leave').clearAt!;
expect(sickLeave.type, UserStatusClearAt_Type.endOf);
expect(sickLeave.time.clearAtTime0, UserStatusClearAt_Time0.day);
expect(sickLeave.time.clearAtTimeType, UserStatusClearAtTimeType.day);
final vacationing = response.ocs.data.singleWhere((final s) => s.id == 'vacationing').clearAt;
expect(vacationing, null);
});
test('Set status', () async {
final response = await client.userStatus.setStatus(statusType: UserStatusType.online);
expect(response.ocs.data.status!.publicStatus.userId, 'user1');
expect(response.ocs.data.status!.publicStatus.message, null);
expect(response.ocs.data.status!.status1.messageId, null);
expect(response.ocs.data.status!.status1.messageIsPredefined, false);
expect(response.ocs.data.status!.publicStatus.icon, null);
expect(response.ocs.data.status!.publicStatus.clearAt, null);
expect(response.ocs.data.status!.publicStatus.status, UserStatusType.online);
expect(response.ocs.data.status!.status1.statusIsUserDefined, true);
final response = await client.userStatus.userStatus.setStatus(statusType: 'online');
expect(response.ocs.data.public.userId, 'user1');
expect(response.ocs.data.public.message, null);
expect(response.ocs.data.private1.messageId, null);
expect(response.ocs.data.private1.messageIsPredefined, false);
expect(response.ocs.data.public.icon, null);
expect(response.ocs.data.public.clearAt, null);
expect(response.ocs.data.public.status, 'online');
expect(response.ocs.data.private1.statusIsUserDefined, true);
});
test('Get status', () async {
// There seems to be a bug in Nextcloud which makes getting the status fail before it has been set once.
// The error message from Nextcloud is "Could not create folder"
await client.userStatus.setStatus(statusType: UserStatusType.online);
final response = await client.userStatus.getStatus();
expect(response.ocs.data.status!.publicStatus.userId, 'user1');
expect(response.ocs.data.status!.publicStatus.message, null);
expect(response.ocs.data.status!.status1.messageId, null);
expect(response.ocs.data.status!.status1.messageIsPredefined, false);
expect(response.ocs.data.status!.publicStatus.icon, null);
expect(response.ocs.data.status!.publicStatus.clearAt, null);
expect(response.ocs.data.status!.publicStatus.status, UserStatusType.online);
expect(response.ocs.data.status!.status1.statusIsUserDefined, true);
await client.userStatus.userStatus.setStatus(statusType: 'online');
final response = await client.userStatus.userStatus.getStatus();
expect(response.ocs.data.public.userId, 'user1');
expect(response.ocs.data.public.message, null);
expect(response.ocs.data.private1.messageId, null);
expect(response.ocs.data.private1.messageIsPredefined, false);
expect(response.ocs.data.public.icon, null);
expect(response.ocs.data.public.clearAt, null);
expect(response.ocs.data.public.status, 'online');
expect(response.ocs.data.private1.statusIsUserDefined, true);
});
test('Find all statuses', () async {
var response = await client.userStatus.getPublicStatuses();
var response = await client.userStatus.statuses.findAll();
expect(response.ocs.data, hasLength(0));
await client.userStatus.setStatus(statusType: UserStatusType.online);
await client.userStatus.userStatus.setStatus(statusType: 'online');
response = await client.userStatus.getPublicStatuses();
response = await client.userStatus.statuses.findAll();
expect(response.ocs.data, hasLength(1));
expect(response.ocs.data[0].userId, 'user1');
expect(response.ocs.data[0].message, null);
expect(response.ocs.data[0].icon, null);
expect(response.ocs.data[0].clearAt, null);
expect(response.ocs.data[0].status, UserStatusType.online);
expect(response.ocs.data[0].status, 'online');
});
test('Find status', () async {
// Same as getting status
await client.userStatus.setStatus(statusType: UserStatusType.online);
final response = await client.userStatus.getPublicStatus(userId: 'user1');
expect(response.ocs.data.publicStatus!.userId, 'user1');
expect(response.ocs.data.publicStatus!.message, null);
expect(response.ocs.data.publicStatus!.icon, null);
expect(response.ocs.data.publicStatus!.clearAt, null);
expect(response.ocs.data.publicStatus!.status, UserStatusType.online);
await client.userStatus.userStatus.setStatus(statusType: 'online');
final response = await client.userStatus.statuses.find(userId: 'user1');
expect(response.ocs.data.userId, 'user1');
expect(response.ocs.data.message, null);
expect(response.ocs.data.icon, null);
expect(response.ocs.data.clearAt, null);
expect(response.ocs.data.status, 'online');
});
test('Set predefined message', () async {
final clearAt = DateTime.now().millisecondsSinceEpoch ~/ 1000 + 60;
final response = await client.userStatus.setPredefinedMessage(
final response = await client.userStatus.userStatus.setPredefinedMessage(
messageId: 'meeting',
clearAt: clearAt,
);
expect(response.ocs.data.status!.publicStatus.userId, 'user1');
expect(response.ocs.data.status!.publicStatus.message, null);
expect(response.ocs.data.status!.status1.messageId, 'meeting');
expect(response.ocs.data.status!.status1.messageIsPredefined, true);
expect(response.ocs.data.status!.publicStatus.icon, null);
expect(response.ocs.data.status!.publicStatus.clearAt!.$int, clearAt);
expect(response.ocs.data.status!.publicStatus.status, UserStatusType.offline);
expect(response.ocs.data.status!.status1.statusIsUserDefined, false);
expect(response.ocs.data.public.userId, 'user1');
expect(response.ocs.data.public.message, null);
expect(response.ocs.data.private1.messageId, 'meeting');
expect(response.ocs.data.private1.messageIsPredefined, true);
expect(response.ocs.data.public.icon, null);
expect(response.ocs.data.public.clearAt, clearAt);
expect(response.ocs.data.public.status, 'offline');
expect(response.ocs.data.private1.statusIsUserDefined, false);
});
test('Set custom message', () async {
final clearAt = DateTime.now().millisecondsSinceEpoch ~/ 1000 + 60;
final response = await client.userStatus.setCustomMessage(
final response = await client.userStatus.userStatus.setCustomMessage(
statusIcon: '😀',
message: 'bla',
clearAt: clearAt,
);
expect(response.ocs.data.status!.publicStatus.userId, 'user1');
expect(response.ocs.data.status!.publicStatus.message, 'bla');
expect(response.ocs.data.status!.status1.messageId, null);
expect(response.ocs.data.status!.status1.messageIsPredefined, false);
expect(response.ocs.data.status!.publicStatus.icon, '😀');
expect(response.ocs.data.status!.publicStatus.clearAt!.$int, clearAt);
expect(response.ocs.data.status!.publicStatus.status, UserStatusType.offline);
expect(response.ocs.data.status!.status1.statusIsUserDefined, false);
expect(response.ocs.data.public.userId, 'user1');
expect(response.ocs.data.public.message, 'bla');
expect(response.ocs.data.private1.messageId, null);
expect(response.ocs.data.private1.messageIsPredefined, false);
expect(response.ocs.data.public.icon, '😀');
expect(response.ocs.data.public.clearAt, clearAt);
expect(response.ocs.data.public.status, 'offline');
expect(response.ocs.data.private1.statusIsUserDefined, false);
});
test('Clear message', () async {
final clearAt = DateTime.now().millisecondsSinceEpoch ~/ 1000 + 60;
await client.userStatus.setCustomMessage(
await client.userStatus.userStatus.setCustomMessage(
statusIcon: '😀',
message: 'bla',
clearAt: clearAt,
);
await client.userStatus.clearMessage();
final response = await client.userStatus.getStatus();
expect(response.ocs.data.status!.publicStatus.userId, 'user1');
expect(response.ocs.data.status!.publicStatus.message, null);
expect(response.ocs.data.status!.status1.messageId, null);
expect(response.ocs.data.status!.status1.messageIsPredefined, false);
expect(response.ocs.data.status!.publicStatus.icon, null);
expect(response.ocs.data.status!.publicStatus.clearAt, null);
expect(response.ocs.data.status!.publicStatus.status, UserStatusType.offline);
expect(response.ocs.data.status!.status1.statusIsUserDefined, false);
await client.userStatus.userStatus.clearMessage();
final response = await client.userStatus.userStatus.getStatus();
expect(response.ocs.data.public.userId, 'user1');
expect(response.ocs.data.public.message, null);
expect(response.ocs.data.private1.messageId, null);
expect(response.ocs.data.private1.messageIsPredefined, false);
expect(response.ocs.data.public.icon, null);
expect(response.ocs.data.public.clearAt, null);
expect(response.ocs.data.public.status, 'offline');
expect(response.ocs.data.private1.statusIsUserDefined, false);
});
test('Heartbeat', () async {
final response = await client.userStatus.heartbeat(status: UserStatusType.online);
expect(response.ocs.data.status!.publicStatus.userId, 'user1');
expect(response.ocs.data.status!.publicStatus.message, null);
expect(response.ocs.data.status!.status1.messageId, null);
expect(response.ocs.data.status!.status1.messageIsPredefined, false);
expect(response.ocs.data.status!.publicStatus.icon, null);
expect(response.ocs.data.status!.publicStatus.clearAt, null);
expect(response.ocs.data.status!.publicStatus.status, UserStatusType.online);
expect(response.ocs.data.status!.status1.statusIsUserDefined, false);
final response = await client.userStatus.heartbeat.heartbeat(status: 'online');
expect(response.ocs.data.public.userId, 'user1');
expect(response.ocs.data.public.message, null);
expect(response.ocs.data.private1.messageId, null);
expect(response.ocs.data.private1.messageIsPredefined, false);
expect(response.ocs.data.public.icon, null);
expect(response.ocs.data.public.clearAt, null);
expect(response.ocs.data.public.status, 'online');
expect(response.ocs.data.private1.statusIsUserDefined, false);
});
});
}

Loading…
Cancel
Save