36 lines
892 B
Dart
36 lines
892 B
Dart
/// Data model representing a sheet music document.
|
|
///
|
|
/// A [Sheet] contains metadata about a piece of sheet music,
|
|
/// including its title, composer information, and timestamps.
|
|
class Sheet {
|
|
final String uuid;
|
|
String name;
|
|
String composer;
|
|
DateTime updatedAt;
|
|
|
|
Sheet({
|
|
required this.uuid,
|
|
required this.name,
|
|
required this.composer,
|
|
required this.updatedAt,
|
|
});
|
|
|
|
/// Creates a [Sheet] from a JSON map returned by the API.
|
|
factory Sheet.fromJson(Map<String, dynamic> json) {
|
|
return Sheet(
|
|
uuid: json['uuid'],
|
|
name: json['title'],
|
|
composer: json['composer'],
|
|
updatedAt: DateTime.parse(json['updated_at']),
|
|
);
|
|
}
|
|
|
|
/// Converts this sheet to a JSON map for API requests.
|
|
Map<String, dynamic> toJson() => {
|
|
'uuid': uuid,
|
|
'title': name,
|
|
'composer': composer,
|
|
'updated_at': updatedAt.toIso8601String(),
|
|
};
|
|
}
|