From 45235dbd95684287136c046e60c3e504fbf25f06 Mon Sep 17 00:00:00 2001 From: Hayri Bakici Date: Mon, 8 May 2023 19:16:15 +0200 Subject: [PATCH] adds some deprecations --- lib/src/endpoints/artists.dart | 8 ++++++-- lib/src/endpoints/browse.dart | 12 +++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/src/endpoints/artists.dart b/lib/src/endpoints/artists.dart index 129e56c..aebd102 100644 --- a/lib/src/endpoints/artists.dart +++ b/lib/src/endpoints/artists.dart @@ -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> getTopTracks(String artistId, Market country) async => - topTracks(artistId, country); + Future> 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> topTracks(String artistId, Market country) async { diff --git a/lib/src/endpoints/browse.dart b/lib/src/endpoints/browse.dart index 2747185..f0d13a3 100644 --- a/lib/src/endpoints/browse.dart +++ b/lib/src/endpoints/browse.dart @@ -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 getNewReleases({Market? country}) { + @Deprecated('Use [newReleases] instead') + Pages 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 newReleases({Market? country}) { var params = _buildQuery({'country': country?.name}); return _getPages(