Skip to content

Commit d505982

Browse files
authored
Add Locale param (JohnnyCrazy#835)
* Add Locale * Add ArtistRequest, ArtistsRelatedArtistsRequest * Add ArtistRequest, ArtistsRelatedArtistsRequest * Add Locale
1 parent 2bfb7ba commit d505982

30 files changed

Lines changed: 361 additions & 1 deletion

‎SpotifyAPI.Web/Clients/ArtistsClient.cs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ public Task<FullArtist> Get(string artistId, CancellationToken cancel = default)
1616
return API.Get<FullArtist>(URLs.Artist(artistId), cancel);
1717
}
1818

19+
public Task<FullArtist> Get(string artistId, ArtistRequest request, CancellationToken cancel = default)
20+
{
21+
Ensure.ArgumentNotNullOrEmptyString(artistId, nameof(artistId));
22+
23+
return API.Get<FullArtist>(URLs.Artist(artistId), request.BuildQueryParams(), cancel);
24+
}
25+
1926
public Task<Paging<SimpleAlbum>> GetAlbums(string artistId, CancellationToken cancel = default)
2027
{
2128
Ensure.ArgumentNotNullOrEmptyString(artistId, nameof(artistId));
@@ -38,6 +45,13 @@ public Task<ArtistsRelatedArtistsResponse> GetRelatedArtists(string artistId, Ca
3845
return API.Get<ArtistsRelatedArtistsResponse>(URLs.ArtistRelatedArtists(artistId), cancel);
3946
}
4047

48+
public Task<ArtistsRelatedArtistsResponse> GetRelatedArtists(string artistId, ArtistsRelatedArtistsRequest request, CancellationToken cancel = default)
49+
{
50+
Ensure.ArgumentNotNullOrEmptyString(artistId, nameof(artistId));
51+
52+
return API.Get<ArtistsRelatedArtistsResponse>(URLs.ArtistRelatedArtists(artistId), request.BuildQueryParams(), cancel);
53+
}
54+
4155
public Task<ArtistsResponse> GetSeveral(ArtistsRequest request, CancellationToken cancel = default)
4256
{
4357
Ensure.ArgumentNotNull(request, nameof(request));

‎SpotifyAPI.Web/Clients/Interfaces/IArtistsClient.cs‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ public interface IArtistsClient
3131
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716")]
3232
Task<FullArtist> Get(string artistId, CancellationToken cancel = default);
3333

34+
/// <summary>
35+
/// Get Spotify catalog information for a single artist identified by their unique Spotify ID.
36+
/// </summary>
37+
/// <param name="artistId">The Spotify ID of the artist.</param>
38+
/// <param name="cancel">The cancellation-token to allow to cancel the request.</param>
39+
/// <remarks>
40+
/// https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-get-an-artist
41+
/// </remarks>
42+
/// <returns></returns>
43+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716")]
44+
Task<FullArtist> Get(string artistId, ArtistRequest request, CancellationToken cancel = default);
45+
3446
/// <summary>
3547
/// Get Spotify catalog information about an artist’s albums.
3648
/// Optional parameters can be specified in the query string to filter and sort the response.
@@ -81,5 +93,17 @@ public interface IArtistsClient
8193
/// </remarks>
8294
/// <returns></returns>
8395
Task<ArtistsRelatedArtistsResponse> GetRelatedArtists(string artistId, CancellationToken cancel = default);
96+
97+
/// <summary>
98+
/// Get Spotify catalog information about artists similar to a given artist.
99+
/// Similarity is based on analysis of the Spotify community’s listening history.
100+
/// </summary>
101+
/// <param name="artistId">The Spotify ID for the artist</param>
102+
/// <param name="cancel">The cancellation-token to allow to cancel the request.</param>
103+
/// <remarks>
104+
/// https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-get-an-artists-related-artists
105+
/// </remarks>
106+
/// <returns></returns>
107+
Task<ArtistsRelatedArtistsResponse> GetRelatedArtists(string artistId, ArtistsRelatedArtistsRequest request, CancellationToken cancel = default);
84108
}
85109
}

‎SpotifyAPI.Web/Models/Request/AlbumRequest.cs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,16 @@ public class AlbumRequest : RequestParams
88
/// <value></value>
99
[QueryParam("market")]
1010
public string? Market { get; set; }
11+
12+
/// <summary>
13+
/// The desired language, consisting of an ISO 639-1 language code and an ISO 3166-1 alpha-2 country code,
14+
/// joined by an underscore. For example: es_MX, meaning "Spanish (Mexico)".
15+
/// Provide this parameter if you want the category strings returned in a particular language.
16+
/// Note that, if locale is not supplied, or if the specified language is not available,
17+
/// the category strings returned will be in the Spotify default language (American English).
18+
/// </summary>
19+
/// <value></value>
20+
[QueryParam("locale")]
21+
public string? Locale { get; set; }
1122
}
1223
}

‎SpotifyAPI.Web/Models/Request/AlbumTracksRequest.cs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ public class AlbumTracksRequest : RequestParams
2424
/// <value></value>
2525
[QueryParam("offset")]
2626
public int? Offset { get; set; }
27+
28+
/// <summary>
29+
/// The desired language, consisting of an ISO 639-1 language code and an ISO 3166-1 alpha-2 country code,
30+
/// joined by an underscore. For example: es_MX, meaning "Spanish (Mexico)".
31+
/// Provide this parameter if you want the category strings returned in a particular language.
32+
/// Note that, if locale is not supplied, or if the specified language is not available,
33+
/// the category strings returned will be in the Spotify default language (American English).
34+
/// </summary>
35+
/// <value></value>
36+
[QueryParam("locale")]
37+
public string? Locale { get; set; }
2738
}
2839
}
2940

‎SpotifyAPI.Web/Models/Request/AlbumsRequest.cs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ public AlbumsRequest(IList<string> ids)
2929
/// <value></value>
3030
[QueryParam("market")]
3131
public string? Market { get; set; }
32+
33+
/// <summary>
34+
/// The desired language, consisting of an ISO 639-1 language code and an ISO 3166-1 alpha-2 country code,
35+
/// joined by an underscore. For example: es_MX, meaning "Spanish (Mexico)".
36+
/// Provide this parameter if you want the category strings returned in a particular language.
37+
/// Note that, if locale is not supplied, or if the specified language is not available,
38+
/// the category strings returned will be in the Spotify default language (American English).
39+
/// </summary>
40+
/// <value></value>
41+
[QueryParam("locale")]
42+
public string? Locale { get; set; }
3243
}
3344
}
3445

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Collections.Generic;
2+
3+
namespace SpotifyAPI.Web
4+
{
5+
public class ArtistRequest : RequestParams
6+
{
7+
/// <summary>
8+
/// The desired language, consisting of an ISO 639-1 language code and an ISO 3166-1 alpha-2 country code,
9+
/// joined by an underscore. For example: es_MX, meaning "Spanish (Mexico)".
10+
/// Provide this parameter if you want the category strings returned in a particular language.
11+
/// Note that, if locale is not supplied, or if the specified language is not available,
12+
/// the category strings returned will be in the Spotify default language (American English).
13+
/// </summary>
14+
/// <value></value>
15+
[QueryParam("locale")]
16+
public string? Locale { get; set; }
17+
}
18+
}
19+

‎SpotifyAPI.Web/Models/Request/ArtistsAlbumsRequest.cs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ public class ArtistsAlbumsRequest : RequestParams
2323
[QueryParam("market")]
2424
public string? Market { get; set; }
2525

26+
/// <summary>
27+
/// The desired language, consisting of an ISO 639-1 language code and an ISO 3166-1 alpha-2 country code,
28+
/// joined by an underscore. For example: es_MX, meaning "Spanish (Mexico)".
29+
/// Provide this parameter if you want the category strings returned in a particular language.
30+
/// Note that, if locale is not supplied, or if the specified language is not available,
31+
/// the category strings returned will be in the Spotify default language (American English).
32+
/// </summary>
33+
/// <value></value>
34+
[QueryParam("locale")]
35+
public string? Locale { get; set; }
36+
2637
/// <summary>
2738
/// The number of album objects to return. Default: 20. Minimum: 1. Maximum: 50. For example: limit=2
2839
/// </summary>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace SpotifyAPI.Web
2+
{
3+
public class ArtistsRelatedArtistsRequest : RequestParams
4+
{
5+
/// <summary>
6+
/// The desired language, consisting of an ISO 639-1 language code and an ISO 3166-1 alpha-2 country code,
7+
/// joined by an underscore. For example: es_MX, meaning "Spanish (Mexico)".
8+
/// Provide this parameter if you want the category strings returned in a particular language.
9+
/// Note that, if locale is not supplied, or if the specified language is not available,
10+
/// the category strings returned will be in the Spotify default language (American English).
11+
/// </summary>
12+
/// <value></value>
13+
[QueryParam("locale")]
14+
public string? Locale { get; set; }
15+
}
16+
}
17+

‎SpotifyAPI.Web/Models/Request/ArtistsRequest.cs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ public ArtistsRequest(IList<string> ids)
2121
/// <value></value>
2222
[QueryParam("ids")]
2323
public IList<string> Ids { get; }
24+
25+
/// <summary>
26+
/// The desired language, consisting of an ISO 639-1 language code and an ISO 3166-1 alpha-2 country code,
27+
/// joined by an underscore. For example: es_MX, meaning "Spanish (Mexico)".
28+
/// Provide this parameter if you want the category strings returned in a particular language.
29+
/// Note that, if locale is not supplied, or if the specified language is not available,
30+
/// the category strings returned will be in the Spotify default language (American English).
31+
/// </summary>
32+
/// <value></value>
33+
[QueryParam("locale")]
34+
public string? Locale { get; set; }
2435
}
2536
}
2637

‎SpotifyAPI.Web/Models/Request/ArtistsTopTracksRequest.cs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ public ArtistsTopTracksRequest(string market)
1919
/// <value></value>
2020
[QueryParam("market")]
2121
public string Market { get; }
22+
23+
/// <summary>
24+
/// The desired language, consisting of an ISO 639-1 language code and an ISO 3166-1 alpha-2 country code,
25+
/// joined by an underscore. For example: es_MX, meaning "Spanish (Mexico)".
26+
/// Provide this parameter if you want the category strings returned in a particular language.
27+
/// Note that, if locale is not supplied, or if the specified language is not available,
28+
/// the category strings returned will be in the Spotify default language (American English).
29+
/// </summary>
30+
/// <value></value>
31+
[QueryParam("locale")]
32+
public string? Locale { get; set; }
2233
}
2334
}
2435

0 commit comments

Comments
 (0)