import 'package:equatable/equatable.dart'; import 'artist.dart'; /// Album entity class Album extends Equatable { final String id; final String title; final DateTime? releaseDate; final String? imageUrl; final int totalTracks; final String? genre; final String? artistId; final Artist? artist; final String? spotifyId; final String? youtubePlaylistId; final DateTime createdAt; final DateTime updatedAt; const Album({ required this.id, required this.title, this.releaseDate, this.imageUrl, this.totalTracks = 0, this.genre, this.artistId, this.artist, this.spotifyId, this.youtubePlaylistId, required this.createdAt, required this.updatedAt, }); /// Create Album from JSON factory Album.fromJson(Map json) { return Album( id: json['id'] as String, title: json['title'] as String, releaseDate: json['release_date'] != null ? DateTime.parse(json['release_date'] as String) : null, imageUrl: json['image_url'] as String?, totalTracks: json['total_tracks'] as int? ?? 0, genre: json['genre'] as String?, artistId: json['artist_id'] as String?, artist: json['artist'] != null ? Artist.fromJson(json['artist'] as Map) : null, spotifyId: json['spotify_id'] as String?, youtubePlaylistId: json['youtube_playlist_id'] as String?, createdAt: json['created_at'] != null ? DateTime.parse(json['created_at'] as String) : DateTime.now(), updatedAt: json['updated_at'] != null ? DateTime.parse(json['updated_at'] as String) : DateTime.now(), ); } @override List get props => [id, title, releaseDate, totalTracks]; }