38 lines
981 B
Dart
38 lines
981 B
Dart
class Session {
|
|
Session({
|
|
required this.sessionId,
|
|
required this.name,
|
|
required this.status,
|
|
this.projectId,
|
|
this.workingDirectory,
|
|
this.createdAtUtc,
|
|
this.updatedAtUtc,
|
|
});
|
|
|
|
final String sessionId;
|
|
final String name;
|
|
final String status;
|
|
final String? projectId;
|
|
final String? workingDirectory;
|
|
final DateTime? createdAtUtc;
|
|
final DateTime? updatedAtUtc;
|
|
|
|
factory Session.fromJson(Map<String, dynamic> json) => Session(
|
|
sessionId: json['sessionId'] as String,
|
|
name: json['name'] as String,
|
|
status: json['status'] as String,
|
|
projectId: json['projectId'] as String?,
|
|
workingDirectory: json['workingDirectory'] as String?,
|
|
createdAtUtc: _tryParseDateTime(json['createdAtUtc']),
|
|
updatedAtUtc: _tryParseDateTime(json['updatedAtUtc']),
|
|
);
|
|
|
|
static DateTime? _tryParseDateTime(dynamic value) {
|
|
if (value is! String || value.isEmpty) {
|
|
return null;
|
|
}
|
|
|
|
return DateTime.tryParse(value);
|
|
}
|
|
}
|