Skip to content

Commit

Permalink
adds some deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
hayribakici authored and rinukkusu committed Sep 18, 2023
1 parent 7eb8cf5 commit 45235db
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/src/endpoints/artists.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ class Artists extends EndpointPaging {

/// Returns the top tracks of an artist with its [artistId] inside a [country]
@Deprecated('Use [topTracks] instead')
Future<Iterable<Track>> getTopTracks(String artistId, Market country) async =>
topTracks(artistId, country);
Future<Iterable<Track>> getTopTracks(String artistId, String country) {
var contains = Market.values.asNameMap().containsKey(country);
assert(contains == true,
'The country code $country does not match with any Market enum value');
return topTracks(artistId, Market.values.asNameMap()[country]!);
}

/// Returns the top tracks of an artist with its [artistId] inside a [country]
Future<Iterable<Track>> topTracks(String artistId, Market country) async {
Expand Down
12 changes: 11 additions & 1 deletion lib/src/endpoints/browse.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@ class Browse extends EndpointPaging {
/// parameter if you want to narrow the list of returned new releases to those
/// relevant to a particular country. If omitted, the returned items will be
/// globally relevant.
Pages<AlbumSimple> getNewReleases({Market? country}) {
@Deprecated('Use [newReleases] instead')
Pages<AlbumSimple> getNewReleases({String? country}) =>
newReleases(country: Market.values.asNameMap()[country]);

/// Returns the new releases.
///
/// [country] - a country: an ISO 3166-1 alpha-2 country code. Provide this
/// parameter if you want to narrow the list of returned new releases to those
/// relevant to a particular country. If omitted, the returned items will be
/// globally relevant.
Pages<AlbumSimple> newReleases({Market? country}) {
var params = _buildQuery({'country': country?.name});

return _getPages(
Expand Down

0 comments on commit 45235db

Please sign in to comment.