78 lines
1.9 KiB
Dart
78 lines
1.9 KiB
Dart
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||
|
|
|
||
|
|
part 'server.freezed.dart';
|
||
|
|
part 'server.g.dart';
|
||
|
|
|
||
|
|
@freezed
|
||
|
|
abstract class EmbyServer with _$EmbyServer {
|
||
|
|
const factory EmbyServer({
|
||
|
|
required String id,
|
||
|
|
required String name,
|
||
|
|
required String baseUrl,
|
||
|
|
required String createdAt,
|
||
|
|
required String updatedAt,
|
||
|
|
@JsonKey(includeIfNull: false) String? lastConnectedAt,
|
||
|
|
|
||
|
|
|
||
|
|
@JsonKey(
|
||
|
|
fromJson: _stringOrEmpty,
|
||
|
|
toJson: _emptyStringToNull,
|
||
|
|
includeIfNull: false,
|
||
|
|
)
|
||
|
|
@Default('')
|
||
|
|
String iconUrl,
|
||
|
|
|
||
|
|
|
||
|
|
@Default(false) bool paused,
|
||
|
|
}) = _EmbyServer;
|
||
|
|
|
||
|
|
factory EmbyServer.fromJson(Map<String, dynamic> json) =>
|
||
|
|
_$EmbyServerFromJson(json);
|
||
|
|
}
|
||
|
|
|
||
|
|
@freezed
|
||
|
|
abstract class EmbyServerSaveReq with _$EmbyServerSaveReq {
|
||
|
|
const factory EmbyServerSaveReq({
|
||
|
|
@JsonKey(includeIfNull: false) String? id,
|
||
|
|
required String name,
|
||
|
|
required String baseUrl,
|
||
|
|
|
||
|
|
|
||
|
|
@JsonKey(
|
||
|
|
fromJson: _stringOrEmpty,
|
||
|
|
toJson: _emptyStringToNull,
|
||
|
|
includeIfNull: false,
|
||
|
|
)
|
||
|
|
@Default('')
|
||
|
|
String iconUrl,
|
||
|
|
}) = _EmbyServerSaveReq;
|
||
|
|
|
||
|
|
factory EmbyServerSaveReq.fromJson(Map<String, dynamic> json) =>
|
||
|
|
_$EmbyServerSaveReqFromJson(json);
|
||
|
|
}
|
||
|
|
|
||
|
|
@freezed
|
||
|
|
abstract class EmbyServerProbeReq with _$EmbyServerProbeReq {
|
||
|
|
const factory EmbyServerProbeReq({required String baseUrl}) =
|
||
|
|
_EmbyServerProbeReq;
|
||
|
|
|
||
|
|
factory EmbyServerProbeReq.fromJson(Map<String, dynamic> json) =>
|
||
|
|
_$EmbyServerProbeReqFromJson(json);
|
||
|
|
}
|
||
|
|
|
||
|
|
@freezed
|
||
|
|
abstract class ProbePublicInfoRes with _$ProbePublicInfoRes {
|
||
|
|
const factory ProbePublicInfoRes({
|
||
|
|
required String serverName,
|
||
|
|
required String version,
|
||
|
|
required String productName,
|
||
|
|
}) = _ProbePublicInfoRes;
|
||
|
|
|
||
|
|
factory ProbePublicInfoRes.fromJson(Map<String, dynamic> json) =>
|
||
|
|
_$ProbePublicInfoResFromJson(json);
|
||
|
|
}
|
||
|
|
|
||
|
|
String _stringOrEmpty(Object? value) => value?.toString() ?? '';
|
||
|
|
|
||
|
|
String? _emptyStringToNull(String value) => value.isEmpty ? null : value;
|