You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
1.8 KiB
80 lines
1.8 KiB
/// Represents a media server configuration.
|
|
class MediaServerConfig {
|
|
/// Unique identifier for this server configuration.
|
|
final String id;
|
|
|
|
/// Server type: 'immich' or 'blossom'.
|
|
final String type;
|
|
|
|
/// Base URL for the server.
|
|
final String baseUrl;
|
|
|
|
/// API key (for Immich only).
|
|
final String? apiKey;
|
|
|
|
/// Whether this is the default server.
|
|
final bool isDefault;
|
|
|
|
/// Display name for this server (optional).
|
|
final String? name;
|
|
|
|
/// Creates a [MediaServerConfig].
|
|
MediaServerConfig({
|
|
required this.id,
|
|
required this.type,
|
|
required this.baseUrl,
|
|
this.apiKey,
|
|
this.isDefault = false,
|
|
this.name,
|
|
});
|
|
|
|
/// Creates a [MediaServerConfig] from a JSON map.
|
|
factory MediaServerConfig.fromJson(Map<String, dynamic> json) {
|
|
return MediaServerConfig(
|
|
id: json['id'] as String,
|
|
type: json['type'] as String,
|
|
baseUrl: json['baseUrl'] as String,
|
|
apiKey: json['apiKey'] as String?,
|
|
isDefault: json['isDefault'] as bool? ?? false,
|
|
name: json['name'] as String?,
|
|
);
|
|
}
|
|
|
|
/// Converts [MediaServerConfig] to JSON.
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'type': type,
|
|
'baseUrl': baseUrl,
|
|
'apiKey': apiKey,
|
|
'isDefault': isDefault,
|
|
'name': name,
|
|
};
|
|
}
|
|
|
|
/// Creates a copy with updated fields.
|
|
MediaServerConfig copyWith({
|
|
String? id,
|
|
String? type,
|
|
String? baseUrl,
|
|
String? apiKey,
|
|
bool? isDefault,
|
|
String? name,
|
|
}) {
|
|
return MediaServerConfig(
|
|
id: id ?? this.id,
|
|
type: type ?? this.type,
|
|
baseUrl: baseUrl ?? this.baseUrl,
|
|
apiKey: apiKey ?? this.apiKey,
|
|
isDefault: isDefault ?? this.isDefault,
|
|
name: name ?? this.name,
|
|
);
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return 'MediaServerConfig(id: $id, type: $type, baseUrl: $baseUrl, isDefault: $isDefault)';
|
|
}
|
|
}
|
|
|