ocarina2/lib/api/subsonic/artist.dart
2024-05-28 18:54:05 +02:00

42 lines
955 B
Dart

import 'package:json_annotation/json_annotation.dart';
import 'package:ocarina/api/subsonic/subsonic.dart';
part 'artist.g.dart';
@JsonSerializable()
/// Artist object from the Subsonic API
class Artist {
/// Artist object from the Subsonic API
const Artist(
this.id,
this.name,
this.albumCount,
this.coverArtId,
this.artistImageUrl,
);
/// Creates instance from the JSON response
factory Artist.fromJson(Map<String, dynamic> json) => _$ArtistFromJson(json);
Map<String, dynamic> toJson() => _$ArtistToJson(this);
/// ID of the artist
final String id;
/// Artist's name
final String name;
/// Number of albums
final int albumCount;
/// Cover art ID
@JsonKey(name: "coverArt")
final String coverArtId;
/// Artist image URL
final String artistImageUrl;
/// Returns the cover art URL formed from the [coverArtId]
String get coverArtUrl => SubsonicApiService().getCoverArtUrl(coverArtId);
}