mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
chore: add missing api properties on sync enums (#18916)
Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
parent
2da94439c7
commit
70b9a4c8f1
5 changed files with 37 additions and 271 deletions
78
mobile/openapi/lib/model/sync_album_user_v1.dart
generated
78
mobile/openapi/lib/model/sync_album_user_v1.dart
generated
|
|
@ -20,7 +20,7 @@ class SyncAlbumUserV1 {
|
|||
|
||||
String albumId;
|
||||
|
||||
SyncAlbumUserV1RoleEnum role;
|
||||
AlbumUserRole role;
|
||||
|
||||
String userId;
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ class SyncAlbumUserV1 {
|
|||
|
||||
return SyncAlbumUserV1(
|
||||
albumId: mapValueOfType<String>(json, r'albumId')!,
|
||||
role: SyncAlbumUserV1RoleEnum.fromJson(json[r'role'])!,
|
||||
role: AlbumUserRole.fromJson(json[r'role'])!,
|
||||
userId: mapValueOfType<String>(json, r'userId')!,
|
||||
);
|
||||
}
|
||||
|
|
@ -113,77 +113,3 @@ class SyncAlbumUserV1 {
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
class SyncAlbumUserV1RoleEnum {
|
||||
/// Instantiate a new enum with the provided [value].
|
||||
const SyncAlbumUserV1RoleEnum._(this.value);
|
||||
|
||||
/// The underlying value of this enum member.
|
||||
final String value;
|
||||
|
||||
@override
|
||||
String toString() => value;
|
||||
|
||||
String toJson() => value;
|
||||
|
||||
static const editor = SyncAlbumUserV1RoleEnum._(r'editor');
|
||||
static const viewer = SyncAlbumUserV1RoleEnum._(r'viewer');
|
||||
|
||||
/// List of all possible values in this [enum][SyncAlbumUserV1RoleEnum].
|
||||
static const values = <SyncAlbumUserV1RoleEnum>[
|
||||
editor,
|
||||
viewer,
|
||||
];
|
||||
|
||||
static SyncAlbumUserV1RoleEnum? fromJson(dynamic value) => SyncAlbumUserV1RoleEnumTypeTransformer().decode(value);
|
||||
|
||||
static List<SyncAlbumUserV1RoleEnum> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <SyncAlbumUserV1RoleEnum>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = SyncAlbumUserV1RoleEnum.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
}
|
||||
|
||||
/// Transformation class that can [encode] an instance of [SyncAlbumUserV1RoleEnum] to String,
|
||||
/// and [decode] dynamic data back to [SyncAlbumUserV1RoleEnum].
|
||||
class SyncAlbumUserV1RoleEnumTypeTransformer {
|
||||
factory SyncAlbumUserV1RoleEnumTypeTransformer() => _instance ??= const SyncAlbumUserV1RoleEnumTypeTransformer._();
|
||||
|
||||
const SyncAlbumUserV1RoleEnumTypeTransformer._();
|
||||
|
||||
String encode(SyncAlbumUserV1RoleEnum data) => data.value;
|
||||
|
||||
/// Decodes a [dynamic value][data] to a SyncAlbumUserV1RoleEnum.
|
||||
///
|
||||
/// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully,
|
||||
/// then null is returned. However, if [allowNull] is false and the [dynamic value][data]
|
||||
/// cannot be decoded successfully, then an [UnimplementedError] is thrown.
|
||||
///
|
||||
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
|
||||
/// and users are still using an old app with the old code.
|
||||
SyncAlbumUserV1RoleEnum? decode(dynamic data, {bool allowNull = true}) {
|
||||
if (data != null) {
|
||||
switch (data) {
|
||||
case r'editor': return SyncAlbumUserV1RoleEnum.editor;
|
||||
case r'viewer': return SyncAlbumUserV1RoleEnum.viewer;
|
||||
default:
|
||||
if (!allowNull) {
|
||||
throw ArgumentError('Unknown enum value to decode: $data');
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Singleton [SyncAlbumUserV1RoleEnumTypeTransformer] instance.
|
||||
static SyncAlbumUserV1RoleEnumTypeTransformer? _instance;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue