Skip to content

Commit 1657a4e

Browse files
authored
Merge pull request #47 from adamint/documentation
Documentation
2 parents b6a6e29 + c055391 commit 1657a4e

26 files changed

+972
-256
lines changed

build.gradle

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
buildscript {
22
ext.kotlin_version = '1.3.11'
3+
ext.dokka_version = '0.9.17'
4+
35
repositories { jcenter() }
46

57
dependencies {
68
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
9+
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
710
}
811
}
912

@@ -16,6 +19,7 @@ plugins {
1619
}
1720

1821
apply plugin: 'kotlin'
22+
apply plugin: 'org.jetbrains.dokka'
1923

2024
group 'com.adamratzman'
2125
version '2.1.0'
@@ -52,14 +56,28 @@ dependencies {
5256

5357
}
5458

59+
dokka {
60+
outputFormat = 'gfm'
61+
outputDirectory = 'docs/md'
62+
63+
jdkVersion = 8
64+
includeNonPublic = false
65+
impliedPlatforms = ["JVM"]
66+
67+
linkMapping {
68+
dir = "src/main/kotlin"
69+
url = "https://github.com/adamint/spotify-web-api-kotlin/tree/master/src/main/kotlin"
70+
suffix = "#L"
71+
}
72+
}
73+
5574
spotless {
5675
kotlin {
5776
ktlint()
5877
licenseHeader '/* Created by Adam Ratzman (2018) */' // License header
5978
}
6079
}
6180

62-
6381
test {
6482
systemProperties project.properties.subMap(
6583
["clientId", "clientSecret", "spotifyTokenString", "spotifyRedirectUri"]

src/main/kotlin/com/adamratzman/spotify/endpoints/client/ClientFollowingAPI.kt

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import com.adamratzman.spotify.utils.ArtistURI
1111
import com.adamratzman.spotify.utils.CursorBasedPagingObject
1212
import com.adamratzman.spotify.utils.EndpointBuilder
1313
import com.adamratzman.spotify.utils.PlaylistURI
14-
import com.adamratzman.spotify.utils.SpotifyPublicUser
1514
import com.adamratzman.spotify.utils.UserURI
1615
import com.adamratzman.spotify.utils.encode
1716
import com.adamratzman.spotify.utils.toArray
@@ -25,9 +24,9 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
2524
/**
2625
* Check to see if the current user is following another Spotify users.
2726
*
28-
* @param user Spotify ID to check.
27+
* @param user user id or uri to check.
2928
*
30-
* @throws BadRequestException if [userId] is a non-existing id
29+
* @throws BadRequestException if [user] is a non-existing id
3130
*/
3231
fun isFollowingUser(user: String): SpotifyRestAction<Boolean> {
3332
return toAction(Supplier {
@@ -38,8 +37,8 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
3837
/**
3938
* Check to see if the logged-in Spotify user is following the specified playlist.
4039
*
41-
* @param playlistOwner Spotify ID of the creator of the playlist
42-
* @param playlistId Spotify playlist ID
40+
* @param playlistOwner id or uri of the creator of the playlist
41+
* @param playlistId playlist id or uri
4342
*
4443
* @return booleans representing whether the user follows the playlist. User IDs **not** found will return false
4544
*
@@ -60,7 +59,7 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
6059
*
6160
* @param users List of the user Spotify IDs to check. Max 50
6261
*
63-
* @throws BadRequestException if [userIds] contains a non-existing id
62+
* @throws BadRequestException if [users] contains a non-existing id
6463
*/
6564
fun isFollowingUsers(vararg users: String): SpotifyRestAction<List<Boolean>> {
6665
return toAction(Supplier {
@@ -74,9 +73,9 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
7473
/**
7574
* Check to see if the current user is following a Spotify artist.
7675
*
77-
* @param artistId Spotify ID to check.
76+
* @param artist artist id to check.
7877
*
79-
* @throws BadRequestException if [artistId] is a non-existing id
78+
* @throws BadRequestException if [artist] is a non-existing id
8079
*/
8180
fun isFollowingArtist(artist: String): SpotifyRestAction<Boolean> {
8281
return toAction(Supplier {
@@ -87,9 +86,9 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
8786
/**
8887
* Check to see if the current user is following one or more artists.
8988
*
90-
* @param artistIds List of the artist Spotify IDs to check. Max 50
89+
* @param artists List of the artist ids or uris to check. Max 50
9190
*
92-
* @throws BadRequestException if [artistIds] contains a non-existing id
91+
* @throws BadRequestException if [artists] contains a non-existing id
9392
*/
9493
fun isFollowingArtists(vararg artists: String): SpotifyRestAction<List<Boolean>> {
9594
return toAction(Supplier {
@@ -120,9 +119,6 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
120119
})
121120
}
122121

123-
fun getFollowedUsers(): SpotifyRestAction<List<SpotifyPublicUser>> =
124-
throw NotImplementedError("Though Spotify will implement this in the future, it is not currently supported.")
125-
126122
/**
127123
* Add the current user as a follower of another user
128124
*
@@ -178,7 +174,7 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
178174
/**
179175
* Add the current user as a follower of a playlist.
180176
*
181-
* @param playlist The Spotify ID of the playlist. Any playlist can be followed, regardless of its
177+
* @param playlist the spotify id or uri of the playlist. Any playlist can be followed, regardless of its
182178
* public/private status, as long as you know its playlist ID.
183179
* @param followPublicly Defaults to true. If true the playlist will be included in user’s public playlists,
184180
* if false it will remain private. To be able to follow playlists privately, the user must have granted the playlist-modify-private scope.
@@ -200,7 +196,7 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
200196
*
201197
* @param user The user to be unfollowed from
202198
*
203-
* @throws BadRequestException if [userId] is not found
199+
* @throws BadRequestException if [user] is not found
204200
*/
205201
fun unfollowUser(user: String): SpotifyRestAction<Unit> {
206202
return toAction(Supplier {
@@ -228,7 +224,7 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
228224
/**
229225
* Remove the current user as a follower of an artist
230226
*
231-
* @param artistId The artist to be unfollowed from
227+
* @param artist The artist to be unfollowed from
232228
*
233229
* @throws BadRequestException if an invalid id is provided
234230
*/
@@ -241,7 +237,7 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
241237
/**
242238
* Remove the current user as a follower of artists
243239
*
244-
* @param artistIds The artists to be unfollowed from
240+
* @param artists The artists to be unfollowed from
245241
*
246242
* @throws BadRequestException if an invalid id is provided
247243
*/
@@ -258,7 +254,7 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
258254
/**
259255
* Remove the current user as a follower of a playlist.
260256
*
261-
* @param playlistId The Spotify ID of the playlist that is to be no longer followed.
257+
* @param playlist the spotify id or uri of the playlist that is to be no longer followed.
262258
*
263259
* @throws BadRequestException if the playlist is not found
264260
*/

src/main/kotlin/com/adamratzman/spotify/endpoints/client/ClientLibraryAPI.kt

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ class ClientLibraryAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
2424
/**
2525
* Get a list of the songs saved in the current Spotify user’s ‘Your Music’ library.
2626
*
27+
* @param limit The number of objects to return. Default: 20. Minimum: 1. Maximum: 50.
28+
* @param offset The index of the first item to return. Default: 0. Use with limit to get the next set of items
29+
* @param market Provide this parameter if you want the list of returned items to be relevant to a particular country.
30+
* If omitted, the returned items will be relevant to all countries.
31+
*
2732
* @return Paging Object of [SavedTrack] ordered by position in library
2833
*/
2934
fun getSavedTracks(
@@ -42,6 +47,11 @@ class ClientLibraryAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
4247
/**
4348
* Get a list of the albums saved in the current Spotify user’s ‘Your Music’ library.
4449
*
50+
* @param limit The number of objects to return. Default: 20. Minimum: 1. Maximum: 50.
51+
* @param offset The index of the first item to return. Default: 0. Use with limit to get the next set of items
52+
* @param market Provide this parameter if you want the list of returned items to be relevant to a particular country.
53+
* If omitted, the returned items will be relevant to all countries.
54+
*
4555
* @return Paging Object of [SavedAlbum] ordered by position in library
4656
*/
4757
fun getSavedAlbums(
@@ -60,7 +70,10 @@ class ClientLibraryAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
6070
/**
6171
* Check if the [LibraryType] with id [id] is already saved in the current Spotify user’s ‘Your Music’ library.
6272
*
63-
* @throws BadRequestException if [track] is not found
73+
* @param type the type of object (album or track)
74+
* @param id the spotify id or uri of the object
75+
*
76+
* @throws BadRequestException if [id] is not found
6477
*/
6578
fun contains(type: LibraryType, id: String): SpotifyRestAction<Boolean> {
6679
return toAction(Supplier {
@@ -71,6 +84,9 @@ class ClientLibraryAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
7184
/**
7285
* Check if one or more of [LibraryType] is already saved in the current Spotify user’s ‘Your Music’ library.
7386
*
87+
* @param type the type of objects (album or track)
88+
* @param ids the spotify ids or uris of the objects
89+
*
7490
* @throws BadRequestException if any of the provided ids is invalid
7591
*/
7692
fun contains(type: LibraryType, vararg ids: String): SpotifyRestAction<List<Boolean>> {
@@ -85,6 +101,9 @@ class ClientLibraryAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
85101
/**
86102
* Save one of [LibraryType] to the current user’s ‘Your Music’ library.
87103
*
104+
* @param type the type of object (album or track)
105+
* @param id the spotify id or uri of the object
106+
*
88107
* @throws BadRequestException if the id is invalid
89108
*/
90109
fun add(type: LibraryType, id: String): SpotifyRestAction<Unit> {
@@ -96,6 +115,9 @@ class ClientLibraryAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
96115
/**
97116
* Save one or more of [LibraryType] to the current user’s ‘Your Music’ library.
98117
*
118+
* @param type the type of objects to check against (album or track)
119+
* @param ids the spotify ids or uris of the objects
120+
*
99121
* @throws BadRequestException if any of the provided ids is invalid
100122
*/
101123
fun add(type: LibraryType, vararg ids: String): SpotifyRestAction<Unit> {
@@ -108,6 +130,9 @@ class ClientLibraryAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
108130
/**
109131
* Remove one of [LibraryType] (track or album) from the current user’s ‘Your Music’ library.
110132
*
133+
* @param type the type of object to check against (album or track)
134+
* @param id the spotify id or uri of the object
135+
*
111136
* @throws BadRequestException if any of the provided ids is invalid
112137
*/
113138
fun remove(type: LibraryType, id: String): SpotifyRestAction<Unit> {
@@ -119,6 +144,9 @@ class ClientLibraryAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
119144
/**
120145
* Remove one or more of the [LibraryType] (tracks or albums) from the current user’s ‘Your Music’ library.
121146
*
147+
* @param type the type of objects to check against (album or track)
148+
* @param ids the spotify ids or uris of the objects
149+
*
122150
* @throws BadRequestException if any of the provided ids is invalid
123151
*/
124152
fun remove(type: LibraryType, vararg ids: String): SpotifyRestAction<Unit> {
@@ -129,6 +157,12 @@ class ClientLibraryAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
129157
}
130158
}
131159

160+
/**
161+
* Type of object in a user's Spotify library
162+
*
163+
* @param value Spotify id for the type
164+
* @param id how to transform an id (or uri) input into its Spotify id
165+
*/
132166
enum class LibraryType(private val value: String, internal val id: (String) -> String) {
133167
TRACK("tracks", { TrackURI(it).id }), ALBUM("albums", { AlbumURI(it).id });
134168

src/main/kotlin/com/adamratzman/spotify/endpoints/client/ClientPersonalizationAPI.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ import java.util.function.Supplier
1515
* Endpoints for retrieving information about the user’s listening habits.
1616
*/
1717
class ClientPersonalizationAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
18+
/**
19+
* The time frame for which attribute affinities are computed.
20+
*
21+
* @param id the Spotify id of the time frame
22+
*/
1823
enum class TimeRange(val id: String) {
1924
LONG_TERM("long_term"), MEDIUM_TERM("medium_term"), SHORT_TERM("short_term");
2025

@@ -31,6 +36,10 @@ class ClientPersonalizationAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
3136
* for each user. In the future, it is likely that this restriction will be relaxed. This data is typically updated
3237
* once each day for each user.
3338
*
39+
* @param limit The number of objects to return. Default: 20. Minimum: 1. Maximum: 50.
40+
* @param offset The index of the first item to return. Default: 0. Use with limit to get the next set of items
41+
* @param timeRange the time range to which to compute this. The default is [TimeRange.MEDIUM_TERM]
42+
*
3443
* @return [PagingObject] of full [Artist] objects sorted by affinity
3544
*/
3645
fun getTopArtists(
@@ -57,6 +66,10 @@ class ClientPersonalizationAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
5766
* for each user. In the future, it is likely that this restriction will be relaxed. This data is typically updated
5867
* once each day for each user.
5968
*
69+
* @param limit The number of objects to return. Default: 20. Minimum: 1. Maximum: 50.
70+
* @param offset The index of the first item to return. Default: 0. Use with limit to get the next set of items
71+
* @param timeRange the time range to which to compute this. The default is [TimeRange.MEDIUM_TERM]
72+
*
6073
* @return [PagingObject] of full [Track] objects sorted by affinity
6174
*/
6275
fun getTopTracks(

0 commit comments

Comments
 (0)