Update api definition to use String type for ids.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2017-12-16 22:14:01 +01:00
parent 5bf5af2842
commit b2384a43ce
28 changed files with 131 additions and 148 deletions

View File

@ -9,7 +9,7 @@ class SubsonicApiCreateBookmarkTest : SubsonicAPIClientTest() {
@Test
fun `Should handle error response`() {
checkErrorCallParsed(mockWebServerRule) {
client.api.createBookmark(1, 1).execute()
client.api.createBookmark("1", 1).execute()
}
}
@ -17,14 +17,14 @@ class SubsonicApiCreateBookmarkTest : SubsonicAPIClientTest() {
fun `Should handle ok response`() {
mockWebServerRule.enqueueResponse("ping_ok.json")
val response = client.api.createBookmark(213, 123213L).execute()
val response = client.api.createBookmark("213", 123213L).execute()
assertResponseSuccessful(response)
}
@Test
fun `Should pass id in request params`() {
val id = 544
val id = "544"
mockWebServerRule.assertRequestParam(expectedParam = "id=$id") {
client.api.createBookmark(id = id, position = 123).execute()
@ -36,7 +36,7 @@ class SubsonicApiCreateBookmarkTest : SubsonicAPIClientTest() {
val position = 4412333L
mockWebServerRule.assertRequestParam(expectedParam = "position=$position") {
client.api.createBookmark(id = 12, position = position).execute()
client.api.createBookmark(id = "12", position = position).execute()
}
}
@ -45,7 +45,7 @@ class SubsonicApiCreateBookmarkTest : SubsonicAPIClientTest() {
val comment = "some-comment"
mockWebServerRule.assertRequestParam(expectedParam = "comment=$comment") {
client.api.createBookmark(id = 1, position = 1, comment = comment).execute()
client.api.createBookmark(id = "1", position = 1, comment = comment).execute()
}
}
}

View File

@ -24,7 +24,7 @@ class SubsonicApiCreatePlaylistTest : SubsonicAPIClientTest() {
@Test
fun `Should pass id param in request`() {
val id = 56L
val id = "56"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "playlistId=$id") {
@ -44,7 +44,7 @@ class SubsonicApiCreatePlaylistTest : SubsonicAPIClientTest() {
@Test
fun `Should pass song id param in request`() {
val songId = listOf(4410L, 852L)
val songId = listOf("4410", "852")
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "songId=${songId[0]}&songId=${songId[1]}") {

View File

@ -9,7 +9,7 @@ class SubsonicApiDeleteBookmarkTest : SubsonicAPIClientTest() {
@Test
fun `Should handle error response`() {
checkErrorCallParsed(mockWebServerRule) {
client.api.deleteBookmark(1).execute()
client.api.deleteBookmark("1").execute()
}
}
@ -17,14 +17,14 @@ class SubsonicApiDeleteBookmarkTest : SubsonicAPIClientTest() {
fun `Should handle ok response`() {
mockWebServerRule.enqueueResponse("ping_ok.json")
val response = client.api.deleteBookmark(1).execute()
val response = client.api.deleteBookmark("1").execute()
assertResponseSuccessful(response)
}
@Test
fun `Should pass id in request params`() {
val id = 233
val id = "233"
mockWebServerRule.assertRequestParam(expectedParam = "id=$id") {
client.api.deleteBookmark(id).execute()

View File

@ -9,7 +9,7 @@ class SubsonicApiDeletePlaylistTest : SubsonicAPIClientTest() {
@Test
fun `Should handle error response`() {
checkErrorCallParsed(mockWebServerRule) {
client.api.deletePlaylist(10).execute()
client.api.deletePlaylist("10").execute()
}
}
@ -17,14 +17,14 @@ class SubsonicApiDeletePlaylistTest : SubsonicAPIClientTest() {
fun `Should handle ok response`() {
mockWebServerRule.enqueueResponse("ping_ok.json")
val response = client.api.deletePlaylist(10).execute()
val response = client.api.deletePlaylist("10").execute()
assertResponseSuccessful(response)
}
@Test
fun `Should pass id param in request`() {
val id = 534L
val id = "534"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "id=$id") {

View File

@ -9,7 +9,7 @@ class SubsonicApiDeleteShareTest : SubsonicAPIClientTest() {
@Test
fun `Should handle error response`() {
checkErrorCallParsed(mockWebServerRule) {
client.api.deleteShare(123).execute()
client.api.deleteShare("123").execute()
}
}
@ -17,14 +17,14 @@ class SubsonicApiDeleteShareTest : SubsonicAPIClientTest() {
fun `Should handle ok response`() {
mockWebServerRule.enqueueResponse("ping_ok.json")
val response = client.api.deleteShare(12).execute()
val response = client.api.deleteShare("12").execute()
assertResponseSuccessful(response)
}
@Test
fun `Should pass id in request params`() {
val id = 224L
val id = "224"
mockWebServerRule.assertRequestParam(expectedParam = "id=$id") {
client.api.deleteShare(id).execute()

View File

@ -103,7 +103,7 @@ class SubsonicApiGetAlbumList2Test : SubsonicAPIClientTest() {
@Test
fun `Should pass music folder id in request param`() {
val musicFolderId = 9422L
val musicFolderId = "9422"
mockWebServerRule.assertRequestParam(responseResourceName = "get_album_list_2_ok.json",
expectedParam = "musicFolderId=$musicFolderId") {

View File

@ -99,7 +99,7 @@ class SubsonicApiGetAlbumListRequestTest : SubsonicAPIClientTest() {
@Test
fun `Should pass music folder id in request params`() {
val folderId = 545L
val folderId = "545"
mockWebServerRule.assertRequestParam(responseResourceName = "get_album_list_ok.json",
expectedParam = "musicFolderId=$folderId") {

View File

@ -14,7 +14,7 @@ class SubsonicApiGetAlbumTest : SubsonicAPIClientTest() {
@Test
fun `Should parse error responce`() {
val response = checkErrorCallParsed(mockWebServerRule) {
client.api.getAlbum(56L).execute()
client.api.getAlbum("56").execute()
}
response.album `should not be` null
@ -23,7 +23,7 @@ class SubsonicApiGetAlbumTest : SubsonicAPIClientTest() {
@Test
fun `Should add id to request params`() {
val id = 76L
val id = "76"
mockWebServerRule.assertRequestParam(responseResourceName = "get_album_ok.json",
expectedParam = "id=$id") {
@ -35,7 +35,7 @@ class SubsonicApiGetAlbumTest : SubsonicAPIClientTest() {
fun `Should parse ok response`() {
mockWebServerRule.enqueueResponse("get_album_ok.json")
val response = client.api.getAlbum(512L).execute()
val response = client.api.getAlbum("512").execute()
assertResponseSuccessful(response)
with(response.body().album) {

View File

@ -14,7 +14,7 @@ class SubsonicApiGetArtistTest : SubsonicAPIClientTest() {
@Test
fun `Should parse error call`() {
val response = checkErrorCallParsed(mockWebServerRule) {
client.api.getArtist(101L).execute()
client.api.getArtist("101").execute()
}
response.artist `should not be` null
@ -23,7 +23,7 @@ class SubsonicApiGetArtistTest : SubsonicAPIClientTest() {
@Test
fun `Should pass id param in request`() {
val id = 929L
val id = "929"
mockWebServerRule.assertRequestParam(responseResourceName = "get_artist_ok.json",
expectedParam = "id=$id") {
@ -35,7 +35,7 @@ class SubsonicApiGetArtistTest : SubsonicAPIClientTest() {
fun `Should parse ok response`() {
mockWebServerRule.enqueueResponse("get_artist_ok.json")
val response = client.api.getArtist(100L).execute()
val response = client.api.getArtist("100").execute()
assertResponseSuccessful(response)
with(response.body().artist) {

View File

@ -50,7 +50,7 @@ class SubsonicApiGetArtistsTest : SubsonicAPIClientTest() {
@Test
fun `Should pass param on query for get artists call`() {
mockWebServerRule.enqueueResponse("get_artists_ok.json")
val musicFolderId = 101L
val musicFolderId = "101"
mockWebServerRule.assertRequestParam(responseResourceName = "get_artists_ok.json",
expectedParam = "musicFolderId=$musicFolderId") {

View File

@ -42,7 +42,7 @@ class SubsonicApiGetIndexesTest : SubsonicAPIClientTest() {
@Test
fun `Should add music folder id as a query param for getIndexes api call`() {
val musicFolderId = 9L
val musicFolderId = "9"
mockWebServerRule.assertRequestParam(responseResourceName = "get_indexes_ok.json",
expectedParam = "musicFolderId=$musicFolderId") {

View File

@ -15,7 +15,7 @@ class SubsonicApiGetMusicDirectoryTest : SubsonicAPIClientTest() {
@Test
fun `Should parse getMusicDirectory error response`() {
val response = checkErrorCallParsed(mockWebServerRule) {
client.api.getMusicDirectory(1).execute()
client.api.getMusicDirectory("1").execute()
}
response.musicDirectory `should not be` null
@ -24,7 +24,7 @@ class SubsonicApiGetMusicDirectoryTest : SubsonicAPIClientTest() {
@Test
fun `GetMusicDirectory should add directory id to query params`() {
val directoryId = 124L
val directoryId = "124"
mockWebServerRule.assertRequestParam(responseResourceName = "get_music_directory_ok.json",
expectedParam = "id=$directoryId") {
@ -36,7 +36,7 @@ class SubsonicApiGetMusicDirectoryTest : SubsonicAPIClientTest() {
fun `Should parse get music directory ok response`() {
mockWebServerRule.enqueueResponse("get_music_directory_ok.json")
val response = client.api.getMusicDirectory(1).execute()
val response = client.api.getMusicDirectory("1").execute()
assertResponseSuccessful(response)

View File

@ -14,7 +14,7 @@ class SubsonicApiGetPlaylistTest : SubsonicAPIClientTest() {
@Test
fun `Should parse error response`() {
val response = checkErrorCallParsed(mockWebServerRule) {
client.api.getPlaylist(10).execute()
client.api.getPlaylist("10").execute()
}
response.playlist `should not be` null
@ -25,7 +25,7 @@ class SubsonicApiGetPlaylistTest : SubsonicAPIClientTest() {
fun `Should parse ok response`() {
mockWebServerRule.enqueueResponse("get_playlist_ok.json")
val response = client.api.getPlaylist(4).execute()
val response = client.api.getPlaylist("4").execute()
assertResponseSuccessful(response)
with(response.body().playlist) {
@ -53,7 +53,7 @@ class SubsonicApiGetPlaylistTest : SubsonicAPIClientTest() {
@Test
fun `Should pass id as request param`() {
val playlistId = 453L
val playlistId = "453"
mockWebServerRule.assertRequestParam(responseResourceName = "get_playlist_ok.json",
expectedParam = "id=$playlistId") {

View File

@ -72,7 +72,7 @@ class SubsonicApiGetPodcastsTest : SubsonicAPIClientTest() {
@Test
fun `Should pass id in request param`() {
val id = 249L
val id = "249"
mockWebServerRule.assertRequestParam(responseResourceName = "get_podcasts_ok.json",
expectedParam = "id=$id") {

View File

@ -80,7 +80,7 @@ class SubsonicApiGetRandomSongsTest : SubsonicAPIClientTest() {
@Test
fun `Should pass music folder id in request param`() {
val musicFolderId = 4919L
val musicFolderId = "4919"
mockWebServerRule.assertRequestParam(responseResourceName = "get_random_songs_ok.json",
expectedParam = "musicFolderId=$musicFolderId") {

View File

@ -73,7 +73,7 @@ class SubsonicApiGetSongsByGenreTest : SubsonicAPIClientTest() {
@Test
fun `Should pass music folder id in request param`() {
val musicFolderId = 1010L
val musicFolderId = "1010"
mockWebServerRule.assertRequestParam(expectedParam = "musicFolderId=$musicFolderId") {
client.api.getSongsByGenre("Trance", musicFolderId = musicFolderId).execute()

View File

@ -38,7 +38,7 @@ class SubsonicApiGetStarred2Test : SubsonicAPIClientTest() {
@Test
fun `Should pass music folder id in request param`() {
val musicFolderId = 441L
val musicFolderId = "441"
mockWebServerRule.assertRequestParam(responseResourceName = "get_starred_2_ok.json",
expectedParam = "musicFolderId=$musicFolderId") {

View File

@ -37,7 +37,7 @@ class SubsonicApiGetStarredTest : SubsonicAPIClientTest() {
@Test
fun `Should pass music folder id in request param`() {
val musicFolderId = 441L
val musicFolderId = "441"
mockWebServerRule.assertRequestParam(responseResourceName = "get_starred_ok.json",
expectedParam = "musicFolderId=$musicFolderId") {

View File

@ -113,7 +113,7 @@ class SubsonicApiSearchThreeTest : SubsonicAPIClientTest() {
@Test
fun `Should pass music folder id as request param`() {
val musicFolderId = 43L
val musicFolderId = "43"
mockWebServerRule.assertRequestParam(responseResourceName = "search3_ok.json",
expectedParam = "musicFolderId=$musicFolderId") {

View File

@ -113,7 +113,7 @@ class SubsonicApiSearchTwoTest : SubsonicAPIClientTest() {
@Test
fun `Should pass music folder id in request param`() {
val musicFolderId = 565L
val musicFolderId = "565"
mockWebServerRule.assertRequestParam(responseResourceName = "search2_ok.json",
expectedParam = "musicFolderId=$musicFolderId") {

View File

@ -27,7 +27,7 @@ class SubsonicApiStarTest : SubsonicAPIClientTest() {
@Test
fun `Should pass id param`() {
val id = 110L
val id = "110"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "id=$id") {
@ -37,7 +37,7 @@ class SubsonicApiStarTest : SubsonicAPIClientTest() {
@Test
fun `Should pass artist id param`() {
val artistId = 123L
val artistId = "123"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "artistId=$artistId") {
@ -47,7 +47,7 @@ class SubsonicApiStarTest : SubsonicAPIClientTest() {
@Test
fun `Should pass album id param`() {
val albumId = 1001L
val albumId = "1001"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "albumId=$albumId") {

View File

@ -27,7 +27,7 @@ class SubsonicApiUnstarTest : SubsonicAPIClientTest() {
@Test
fun `Should pass id param`() {
val id = 545L
val id = "545"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "id=$id") {
@ -37,7 +37,7 @@ class SubsonicApiUnstarTest : SubsonicAPIClientTest() {
@Test
fun `Should pass artistId param`() {
val artistId = 644L
val artistId = "644"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "artistId=$artistId") {
@ -47,7 +47,7 @@ class SubsonicApiUnstarTest : SubsonicAPIClientTest() {
@Test
fun `Should pass albumId param`() {
val albumId = 3344L
val albumId = "3344"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "albumId=$albumId") {

View File

@ -9,7 +9,7 @@ class SubsonicApiUpdatePlaylistTest : SubsonicAPIClientTest() {
@Test
fun `Should handle error response`() {
checkErrorCallParsed(mockWebServerRule) {
client.api.updatePlaylist(10).execute()
client.api.updatePlaylist("10").execute()
}
}
@ -17,14 +17,14 @@ class SubsonicApiUpdatePlaylistTest : SubsonicAPIClientTest() {
fun `Should handle ok response`() {
mockWebServerRule.enqueueResponse("ping_ok.json")
val response = client.api.updatePlaylist(15).execute()
val response = client.api.updatePlaylist("15").execute()
assertResponseSuccessful(response)
}
@Test
fun `Should pass playlist id param in request`() {
val id = 5453L
val id = "5453"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "playlistId=$id") {
@ -38,7 +38,7 @@ class SubsonicApiUpdatePlaylistTest : SubsonicAPIClientTest() {
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "name=$name") {
client.api.updatePlaylist(22, name = name).execute()
client.api.updatePlaylist("22", name = name).execute()
}
}
@ -48,7 +48,7 @@ class SubsonicApiUpdatePlaylistTest : SubsonicAPIClientTest() {
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "comment=$comment") {
client.api.updatePlaylist(42, comment = comment).execute()
client.api.updatePlaylist("42", comment = comment).execute()
}
}
@ -58,17 +58,17 @@ class SubsonicApiUpdatePlaylistTest : SubsonicAPIClientTest() {
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "public=$public") {
client.api.updatePlaylist(53, public = public).execute()
client.api.updatePlaylist("53", public = public).execute()
}
}
@Test
fun `Should pass song ids to update in request`() {
val songIds = listOf(45L, 81L)
val songIds = listOf("45", "81")
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "songIdToAdd=${songIds[0]}&songIdToAdd=${songIds[1]}") {
client.api.updatePlaylist(25, songIdsToAdd = songIds).execute()
client.api.updatePlaylist("25", songIdsToAdd = songIds).execute()
}
}
@ -79,7 +79,7 @@ class SubsonicApiUpdatePlaylistTest : SubsonicAPIClientTest() {
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "songIndexToRemove=${songIndexesToRemove[0]}&" +
"songIndexToRemove=${songIndexesToRemove[1]}") {
client.api.updatePlaylist(49, songIndexesToRemove = songIndexesToRemove).execute()
client.api.updatePlaylist("49", songIndexesToRemove = songIndexesToRemove).execute()
}
}
}

View File

@ -9,7 +9,7 @@ class SubsonicApiUpdateShareTest : SubsonicAPIClientTest() {
@Test
fun `Should handle error response`() {
checkErrorCallParsed(mockWebServerRule) {
client.api.updateShare(11).execute()
client.api.updateShare("11").execute()
}
}
@ -17,14 +17,14 @@ class SubsonicApiUpdateShareTest : SubsonicAPIClientTest() {
fun `Should handle ok response`() {
mockWebServerRule.enqueueResponse("ping_ok.json")
val response = client.api.updateShare(12).execute()
val response = client.api.updateShare("12").execute()
assertResponseSuccessful(response)
}
@Test
fun `Should pass id in request params`() {
val id = 4432L
val id = "4432"
mockWebServerRule.assertRequestParam(expectedParam = "id=$id") {
client.api.updateShare(id = id).execute()
@ -36,7 +36,7 @@ class SubsonicApiUpdateShareTest : SubsonicAPIClientTest() {
val description = "some-description"
mockWebServerRule.assertRequestParam(expectedParam = "description=$description") {
client.api.updateShare(123, description = description).execute()
client.api.updateShare("123", description = description).execute()
}
}
@ -45,7 +45,7 @@ class SubsonicApiUpdateShareTest : SubsonicAPIClientTest() {
val expires = 223123123L
mockWebServerRule.assertRequestParam(expectedParam = "expires=$expires") {
client.api.updateShare(12, expires = expires).execute()
client.api.updateShare("12", expires = expires).execute()
}
}
}

View File

@ -45,27 +45,27 @@ import retrofit2.Call
internal class ApiVersionCheckWrapper(
val api: SubsonicAPIDefinition,
var currentApiVersion: SubsonicAPIVersions) : SubsonicAPIDefinition by api {
override fun getArtists(musicFolderId: Long?): Call<GetArtistsResponse> {
override fun getArtists(musicFolderId: String?): Call<GetArtistsResponse> {
checkVersion(V1_8_0)
return api.getArtists(musicFolderId)
}
override fun star(id: Long?, albumId: Long?, artistId: Long?): Call<SubsonicResponse> {
override fun star(id: String?, albumId: String?, artistId: String?): Call<SubsonicResponse> {
checkVersion(V1_8_0)
return api.star(id, albumId, artistId)
}
override fun unstar(id: Long?, albumId: Long?, artistId: Long?): Call<SubsonicResponse> {
override fun unstar(id: String?, albumId: String?, artistId: String?): Call<SubsonicResponse> {
checkVersion(V1_8_0)
return api.unstar(id, albumId, artistId)
}
override fun getArtist(id: Long): Call<GetArtistResponse> {
override fun getArtist(id: String): Call<GetArtistResponse> {
checkVersion(V1_8_0)
return api.getArtist(id)
}
override fun getAlbum(id: Long): Call<GetAlbumResponse> {
override fun getAlbum(id: String): Call<GetAlbumResponse> {
checkVersion(V1_8_0)
return api.getAlbum(id)
}
@ -76,7 +76,7 @@ internal class ApiVersionCheckWrapper(
albumCount: Int?,
albumOffset: Int?,
songCount: Int?,
musicFolderId: Long?): Call<SearchTwoResponse> {
musicFolderId: String?): Call<SearchTwoResponse> {
checkVersion(V1_4_0)
checkParamVersion(musicFolderId, V1_12_0)
return api.search2(query, artistCount, artistOffset, albumCount, albumOffset, songCount,
@ -89,7 +89,7 @@ internal class ApiVersionCheckWrapper(
albumCount: Int?,
albumOffset: Int?,
songCount: Int?,
musicFolderId: Long?): Call<SearchThreeResponse> {
musicFolderId: String?): Call<SearchThreeResponse> {
checkVersion(V1_8_0)
checkParamVersion(musicFolderId, V1_12_0)
return api.search3(query, artistCount, artistOffset, albumCount, albumOffset,
@ -101,29 +101,29 @@ internal class ApiVersionCheckWrapper(
return api.getPlaylists(username)
}
override fun createPlaylist(id: Long?,
override fun createPlaylist(id: String?,
name: String?,
songIds: List<Long>?): Call<SubsonicResponse> {
songIds: List<String>?): Call<SubsonicResponse> {
checkVersion(V1_2_0)
return api.createPlaylist(id, name, songIds)
}
override fun deletePlaylist(id: Long): Call<SubsonicResponse> {
override fun deletePlaylist(id: String): Call<SubsonicResponse> {
checkVersion(V1_2_0)
return api.deletePlaylist(id)
}
override fun updatePlaylist(id: Long,
override fun updatePlaylist(id: String,
name: String?,
comment: String?,
public: Boolean?,
songIdsToAdd: List<Long>?,
songIdsToAdd: List<String>?,
songIndexesToRemove: List<Int>?): Call<SubsonicResponse> {
checkVersion(V1_8_0)
return api.updatePlaylist(id, name, comment, public, songIdsToAdd, songIndexesToRemove)
}
override fun getPodcasts(includeEpisodes: Boolean?, id: Long?): Call<GetPodcastsResponse> {
override fun getPodcasts(includeEpisodes: Boolean?, id: String?): Call<GetPodcastsResponse> {
checkVersion(V1_6_0)
checkParamVersion(includeEpisodes, V1_9_0)
checkParamVersion(id, V1_9_0)
@ -147,7 +147,7 @@ internal class ApiVersionCheckWrapper(
fromYear: Int?,
toYear: Int?,
genre: String?,
musicFolderId: Long?): Call<GetAlbumListResponse> {
musicFolderId: String?): Call<GetAlbumListResponse> {
checkVersion(V1_2_0)
checkParamVersion(musicFolderId, V1_11_0)
return api.getAlbumList(type, size, offset, fromYear, toYear, genre, musicFolderId)
@ -159,7 +159,7 @@ internal class ApiVersionCheckWrapper(
fromYear: Int?,
toYear: Int?,
genre: String?,
musicFolderId: Long?): Call<GetAlbumList2Response> {
musicFolderId: String?): Call<GetAlbumList2Response> {
checkVersion(V1_8_0)
checkParamVersion(musicFolderId, V1_12_0)
return api.getAlbumList2(type, size, offset, fromYear, toYear, genre, musicFolderId)
@ -169,18 +169,18 @@ internal class ApiVersionCheckWrapper(
genre: String?,
fromYear: Int?,
toYear: Int?,
musicFolderId: Long?): Call<GetRandomSongsResponse> {
musicFolderId: String?): Call<GetRandomSongsResponse> {
checkVersion(V1_2_0)
return api.getRandomSongs(size, genre, fromYear, toYear, musicFolderId)
}
override fun getStarred(musicFolderId: Long?): Call<GetStarredResponse> {
override fun getStarred(musicFolderId: String?): Call<GetStarredResponse> {
checkVersion(V1_8_0)
checkParamVersion(musicFolderId, V1_12_0)
return api.getStarred(musicFolderId)
}
override fun getStarred2(musicFolderId: Long?): Call<GetStarredTwoResponse> {
override fun getStarred2(musicFolderId: String?): Call<GetStarredTwoResponse> {
checkVersion(V1_8_0)
checkParamVersion(musicFolderId, V1_12_0)
return api.getStarred2(musicFolderId)
@ -225,12 +225,12 @@ internal class ApiVersionCheckWrapper(
return api.createShare(idsToShare, description, expires)
}
override fun deleteShare(id: Long): Call<SubsonicResponse> {
override fun deleteShare(id: String): Call<SubsonicResponse> {
checkVersion(V1_6_0)
return api.deleteShare(id)
}
override fun updateShare(id: Long,
override fun updateShare(id: String,
description: String?,
expires: Long?): Call<SubsonicResponse> {
checkVersion(V1_6_0)
@ -245,7 +245,7 @@ internal class ApiVersionCheckWrapper(
override fun getSongsByGenre(genre: String,
count: Int,
offset: Int,
musicFolderId: Long?): Call<GetSongsByGenreResponse> {
musicFolderId: String?): Call<GetSongsByGenreResponse> {
checkVersion(V1_9_0)
checkParamVersion(musicFolderId, V1_12_0)
return api.getSongsByGenre(genre, count, offset, musicFolderId)
@ -271,12 +271,12 @@ internal class ApiVersionCheckWrapper(
return api.getBookmarks()
}
override fun createBookmark(id: Int, position: Long, comment: String?): Call<SubsonicResponse> {
override fun createBookmark(id: String, position: Long, comment: String?): Call<SubsonicResponse> {
checkVersion(V1_9_0)
return api.createBookmark(id, position, comment)
}
override fun deleteBookmark(id: Int): Call<SubsonicResponse> {
override fun deleteBookmark(id: String): Call<SubsonicResponse> {
checkVersion(V1_9_0)
return api.deleteBookmark(id)
}

View File

@ -54,30 +54,30 @@ interface SubsonicAPIDefinition {
fun getMusicFolders(): Call<MusicFoldersResponse>
@GET("getIndexes.view")
fun getIndexes(@Query("musicFolderId") musicFolderId: Long?,
fun getIndexes(@Query("musicFolderId") musicFolderId: String?,
@Query("ifModifiedSince") ifModifiedSince: Long?): Call<GetIndexesResponse>
@GET("getMusicDirectory.view")
fun getMusicDirectory(@Query("id") id: Long): Call<GetMusicDirectoryResponse>
fun getMusicDirectory(@Query("id") id: String): Call<GetMusicDirectoryResponse>
@GET("getArtists.view")
fun getArtists(@Query("musicFolderId") musicFolderId: Long?): Call<GetArtistsResponse>
fun getArtists(@Query("musicFolderId") musicFolderId: String?): Call<GetArtistsResponse>
@GET("star.view")
fun star(@Query("id") id: Long? = null,
@Query("albumId") albumId: Long? = null,
@Query("artistId") artistId: Long? = null): Call<SubsonicResponse>
fun star(@Query("id") id: String? = null,
@Query("albumId") albumId: String? = null,
@Query("artistId") artistId: String? = null): Call<SubsonicResponse>
@GET("unstar.view")
fun unstar(@Query("id") id: Long? = null,
@Query("albumId") albumId: Long? = null,
@Query("artistId") artistId: Long? = null): Call<SubsonicResponse>
fun unstar(@Query("id") id: String? = null,
@Query("albumId") albumId: String? = null,
@Query("artistId") artistId: String? = null): Call<SubsonicResponse>
@GET("getArtist.view")
fun getArtist(@Query("id") id: Long): Call<GetArtistResponse>
fun getArtist(@Query("id") id: String): Call<GetArtistResponse>
@GET("getAlbum.view")
fun getAlbum(@Query("id") id: Long): Call<GetAlbumResponse>
fun getAlbum(@Query("id") id: String): Call<GetAlbumResponse>
@GET("search.view")
fun search(@Query("artist") artist: String? = null,
@ -95,7 +95,7 @@ interface SubsonicAPIDefinition {
@Query("albumCount") albumCount: Int? = null,
@Query("albumOffset") albumOffset: Int? = null,
@Query("songCount") songCount: Int? = null,
@Query("musicFolderId") musicFolderId: Long? = null): Call<SearchTwoResponse>
@Query("musicFolderId") musicFolderId: String? = null): Call<SearchTwoResponse>
@GET("search3.view")
fun search3(@Query("query") query: String,
@ -104,34 +104,34 @@ interface SubsonicAPIDefinition {
@Query("albumCount") albumCount: Int? = null,
@Query("albumOffset") albumOffset: Int? = null,
@Query("songCount") songCount: Int? = null,
@Query("musicFolderId") musicFolderId: Long? = null): Call<SearchThreeResponse>
@Query("musicFolderId") musicFolderId: String? = null): Call<SearchThreeResponse>
@GET("getPlaylist.view")
fun getPlaylist(@Query("id") id: Long): Call<GetPlaylistResponse>
fun getPlaylist(@Query("id") id: String): Call<GetPlaylistResponse>
@GET("getPlaylists.view")
fun getPlaylists(@Query("username") username: String? = null): Call<GetPlaylistsResponse>
@GET("createPlaylist.view")
fun createPlaylist(@Query("playlistId") id: Long? = null,
fun createPlaylist(@Query("playlistId") id: String? = null,
@Query("name") name: String? = null,
@Query("songId") songIds: List<Long>? = null): Call<SubsonicResponse>
@Query("songId") songIds: List<String>? = null): Call<SubsonicResponse>
@GET("deletePlaylist.view")
fun deletePlaylist(@Query("id") id: Long): Call<SubsonicResponse>
fun deletePlaylist(@Query("id") id: String): Call<SubsonicResponse>
@GET("updatePlaylist.view")
fun updatePlaylist(
@Query("playlistId") id: Long,
@Query("playlistId") id: String,
@Query("name") name: String? = null,
@Query("comment") comment: String? = null,
@Query("public") public: Boolean? = null,
@Query("songIdToAdd") songIdsToAdd: List<Long>? = null,
@Query("songIdToAdd") songIdsToAdd: List<String>? = null,
@Query("songIndexToRemove") songIndexesToRemove: List<Int>? = null): Call<SubsonicResponse>
@GET("getPodcasts.view")
fun getPodcasts(@Query("includeEpisodes") includeEpisodes: Boolean? = null,
@Query("id") id: Long? = null): Call<GetPodcastsResponse>
@Query("id") id: String? = null): Call<GetPodcastsResponse>
@GET("getLyrics.view")
fun getLyrics(@Query("artist") artist: String? = null,
@ -149,7 +149,7 @@ interface SubsonicAPIDefinition {
@Query("fromYear") fromYear: Int? = null,
@Query("toYear") toYear: Int? = null,
@Query("genre") genre: String? = null,
@Query("musicFolderId") musicFolderId: Long? = null): Call<GetAlbumListResponse>
@Query("musicFolderId") musicFolderId: String? = null): Call<GetAlbumListResponse>
@GET("getAlbumList2.view")
fun getAlbumList2(@Query("type") type: AlbumListType,
@ -158,20 +158,20 @@ interface SubsonicAPIDefinition {
@Query("fromYear") fromYear: Int? = null,
@Query("toYear") toYear: Int? = null,
@Query("genre") genre: String? = null,
@Query("musicFolderId") musicFolderId: Long? = null): Call<GetAlbumList2Response>
@Query("musicFolderId") musicFolderId: String? = null): Call<GetAlbumList2Response>
@GET("getRandomSongs.view")
fun getRandomSongs(@Query("size") size: Int? = null,
@Query("genre") genre: String? = null,
@Query("fromYear") fromYear: Int? = null,
@Query("toYear") toYear: Int? = null,
@Query("musicFolderId") musicFolderId: Long? = null): Call<GetRandomSongsResponse>
@Query("musicFolderId") musicFolderId: String? = null): Call<GetRandomSongsResponse>
@GET("getStarred.view")
fun getStarred(@Query("musicFolderId") musicFolderId: Long? = null): Call<GetStarredResponse>
fun getStarred(@Query("musicFolderId") musicFolderId: String? = null): Call<GetStarredResponse>
@GET("getStarred2.view")
fun getStarred2(@Query("musicFolderId") musicFolderId: Long? = null): Call<GetStarredTwoResponse>
fun getStarred2(@Query("musicFolderId") musicFolderId: String? = null): Call<GetStarredTwoResponse>
@Streaming
@GET("getCoverArt.view")
@ -205,10 +205,10 @@ interface SubsonicAPIDefinition {
@Query("expires") expires: Long? = null): Call<SharesResponse>
@GET("deleteShare.view")
fun deleteShare(@Query("id") id: Long): Call<SubsonicResponse>
fun deleteShare(@Query("id") id: String): Call<SubsonicResponse>
@GET("updateShare.view")
fun updateShare(@Query("id") id: Long,
fun updateShare(@Query("id") id: String,
@Query("description") description: String? = null,
@Query("expires") expires: Long? = null): Call<SubsonicResponse>
@ -220,7 +220,7 @@ interface SubsonicAPIDefinition {
@Query("genre") genre: String,
@Query("count") count: Int = 10,
@Query("offset") offset: Int = 0,
@Query("musicFolderId") musicFolderId: Long? = null): Call<GetSongsByGenreResponse>
@Query("musicFolderId") musicFolderId: String? = null): Call<GetSongsByGenreResponse>
@GET("getUser.view")
fun getUser(@Query("username") username: String): Call<GetUserResponse>
@ -236,12 +236,12 @@ interface SubsonicAPIDefinition {
@GET("createBookmark.view")
fun createBookmark(
@Query("id") id: Int,
@Query("id") id: String,
@Query("position") position: Long,
@Query("comment") comment: String? = null): Call<SubsonicResponse>
@GET("deleteBookmark.view")
fun deleteBookmark(@Query("id") id: Int): Call<SubsonicResponse>
fun deleteBookmark(@Query("id") id: String): Call<SubsonicResponse>
@GET("getVideos.view")
fun getVideos(): Call<VideosResponse>

View File

@ -37,10 +37,10 @@ class ApiVersionCheckWrapperTest {
wrapper.getAlbumList(BY_GENRE)
val throwCall = { wrapper.getAlbumList(BY_GENRE, musicFolderId = 12L) }
val throwCall = { wrapper.getAlbumList(BY_GENRE, musicFolderId = "12") }
throwCall `should throw` ApiNotSupportedException::class
verify(apiMock).getAlbumList(BY_GENRE)
verify(apiMock, never()).getAlbumList(BY_GENRE, musicFolderId = 12L)
verify(apiMock, never()).getAlbumList(BY_GENRE, musicFolderId = "12")
}
}

View File

@ -188,7 +188,7 @@ public class RESTMusicService implements MusicService {
updateProgressListener(progressListener, R.string.parser_reading);
Response<GetIndexesResponse> response = subsonicAPIClient.getApi()
.getIndexes(musicFolderId == null ? null : Long.valueOf(musicFolderId), null).execute();
.getIndexes(musicFolderId, null).execute();
checkResponseSuccessful(response);
Indexes indexes = APIIndexesConverter.toDomainEntity(response.body().getIndexes());
@ -251,13 +251,9 @@ public class RESTMusicService implements MusicService {
String artistId,
Context context,
ProgressListener progressListener) throws Exception {
Long apiId = id == null ? null : Long.valueOf(id);
Long apiAlbumId = albumId == null ? null : Long.valueOf(albumId);
Long apiArtistId = artistId == null ? null : Long.valueOf(artistId);
updateProgressListener(progressListener, R.string.parser_reading);
Response<SubsonicResponse> response = subsonicAPIClient.getApi()
.star(apiId, apiAlbumId, apiArtistId).execute();
.star(id, albumId, artistId).execute();
checkResponseSuccessful(response);
}
@ -267,13 +263,9 @@ public class RESTMusicService implements MusicService {
String artistId,
Context context,
ProgressListener progressListener) throws Exception {
Long apiId = id == null ? null : Long.valueOf(id);
Long apiAlbumId = albumId == null ? null : Long.valueOf(albumId);
Long apiArtistId = artistId == null ? null : Long.valueOf(artistId);
updateProgressListener(progressListener, R.string.parser_reading);
Response<SubsonicResponse> response = subsonicAPIClient.getApi()
.unstar(apiId, apiAlbumId, apiArtistId).execute();
.unstar(id, albumId, artistId).execute();
checkResponseSuccessful(response);
}
@ -289,7 +281,7 @@ public class RESTMusicService implements MusicService {
updateProgressListener(progressListener, R.string.parser_reading);
Response<GetMusicDirectoryResponse> response = subsonicAPIClient.getApi()
.getMusicDirectory(Long.valueOf(id)).execute();
.getMusicDirectory(id).execute();
checkResponseSuccessful(response);
return APIMusicDirectoryConverter.toDomainEntity(response.body().getMusicDirectory());
@ -306,8 +298,7 @@ public class RESTMusicService implements MusicService {
}
updateProgressListener(progressListener, R.string.parser_reading);
Response<GetArtistResponse> response = subsonicAPIClient.getApi()
.getArtist(Long.valueOf(id)).execute();
Response<GetArtistResponse> response = subsonicAPIClient.getApi().getArtist(id).execute();
checkResponseSuccessful(response);
return APIArtistConverter.toMusicDirectoryDomainEntity(response.body().getArtist());
@ -324,8 +315,7 @@ public class RESTMusicService implements MusicService {
}
updateProgressListener(progressListener, R.string.parser_reading);
Response<GetAlbumResponse> response = subsonicAPIClient.getApi()
.getAlbum(Long.valueOf(id)).execute();
Response<GetAlbumResponse> response = subsonicAPIClient.getApi().getAlbum(id).execute();
checkResponseSuccessful(response);
return APIAlbumConverter.toMusicDirectoryDomainEntity(response.body().getAlbum());
@ -406,7 +396,7 @@ public class RESTMusicService implements MusicService {
updateProgressListener(progressListener, R.string.parser_reading);
Response<GetPlaylistResponse> response = subsonicAPIClient.getApi()
.getPlaylist(Long.valueOf(id)).execute();
.getPlaylist(id).execute();
checkResponseSuccessful(response);
MusicDirectory playlist = APIPlaylistConverter
@ -459,17 +449,16 @@ public class RESTMusicService implements MusicService {
List<MusicDirectory.Entry> entries,
Context context,
ProgressListener progressListener) throws Exception {
Long pId = id == null ? null : Long.valueOf(id);
List<Long> pSongIds = new ArrayList<>(entries.size());
List<String> pSongIds = new ArrayList<>(entries.size());
for (MusicDirectory.Entry entry : entries) {
if (entry.getId() != null) {
pSongIds.add(Long.valueOf(entry.getId()));
pSongIds.add(entry.getId());
}
}
updateProgressListener(progressListener, R.string.parser_reading);
Response<SubsonicResponse> response = subsonicAPIClient.getApi()
.createPlaylist(pId, name, pSongIds).execute();
.createPlaylist(id, name, pSongIds).execute();
checkResponseSuccessful(response);
}
@ -477,11 +466,9 @@ public class RESTMusicService implements MusicService {
public void deletePlaylist(String id,
Context context,
ProgressListener progressListener) throws Exception {
Long pId = id == null ? null : Long.valueOf(id);
updateProgressListener(progressListener, R.string.parser_reading);
Response<SubsonicResponse> response = subsonicAPIClient.getApi()
.deletePlaylist(pId).execute();
.deletePlaylist(id).execute();
checkResponseSuccessful(response);
}
@ -494,7 +481,7 @@ public class RESTMusicService implements MusicService {
ProgressListener progressListener) throws Exception {
updateProgressListener(progressListener, R.string.parser_reading);
Response<SubsonicResponse> response = subsonicAPIClient.getApi()
.updatePlaylist(Long.valueOf(id), name, comment, pub, null, null).execute();
.updatePlaylist(id, name, comment, pub, null, null).execute();
checkResponseSuccessful(response);
}
@ -521,7 +508,7 @@ public class RESTMusicService implements MusicService {
updateProgressListener(progressListener, R.string.parser_reading);
Response<GetPodcastsResponse> response = subsonicAPIClient.getApi()
.getPodcasts(true, Long.valueOf(podcastChannelId)).execute();
.getPodcasts(true, podcastChannelId).execute();
checkResponseSuccessful(response);
List<MusicDirectoryChild> podcastEntries = response.body().getPodcastChannels().get(0)
@ -947,10 +934,9 @@ public class RESTMusicService implements MusicService {
if (id == null) {
throw new IllegalArgumentException("Item id should not be null");
}
Integer itemId = Integer.valueOf(id);
updateProgressListener(progressListener, R.string.parser_reading);
Response<SubsonicResponse> response = subsonicAPIClient.getApi()
.createBookmark(itemId, position, null).execute();
.createBookmark(id, position, null).execute();
checkResponseSuccessful(response);
}
@ -965,7 +951,7 @@ public class RESTMusicService implements MusicService {
updateProgressListener(progressListener, R.string.parser_reading);
Response<SubsonicResponse> response = subsonicAPIClient.getApi()
.deleteBookmark(itemId).execute();
.deleteBookmark(id).execute();
checkResponseSuccessful(response);
}
@ -1008,8 +994,7 @@ public class RESTMusicService implements MusicService {
Long shareId = Long.valueOf(id);
updateProgressListener(progressListener, R.string.parser_reading);
Response<SubsonicResponse> response = subsonicAPIClient.getApi()
.deleteShare(shareId).execute();
Response<SubsonicResponse> response = subsonicAPIClient.getApi().deleteShare(id).execute();
checkResponseSuccessful(response);
}
@ -1027,11 +1012,9 @@ public class RESTMusicService implements MusicService {
expires = null;
}
Long shareId = Long.valueOf(id);
updateProgressListener(progressListener, R.string.parser_reading);
Response<SubsonicResponse> response = subsonicAPIClient.getApi()
.updateShare(shareId, description, expires).execute();
.updateShare(id, description, expires).execute();
checkResponseSuccessful(response);
}