Add getBookmarks() api call.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
b4e18f9bfb
commit
0cc0bbedaf
|
@ -0,0 +1,46 @@
|
||||||
|
package org.moire.ultrasonic.api.subsonic
|
||||||
|
|
||||||
|
import org.amshove.kluent.`should equal to`
|
||||||
|
import org.amshove.kluent.`should equal`
|
||||||
|
import org.junit.Test
|
||||||
|
import org.moire.ultrasonic.api.subsonic.models.MusicDirectoryChild
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integration test for [SubsonicAPIDefinition.getBookmarks] call.
|
||||||
|
*/
|
||||||
|
class SubsonicApiGetBookmarksTest : SubsonicAPIClientTest() {
|
||||||
|
@Test
|
||||||
|
fun `Should handle error response`() {
|
||||||
|
val response = checkErrorCallParsed(mockWebServerRule) {
|
||||||
|
client.api.getBookmarks().execute()
|
||||||
|
}
|
||||||
|
|
||||||
|
response.bookmarkList `should equal` emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `Should handle ok response`() {
|
||||||
|
mockWebServerRule.enqueueResponse("get_bookmarks_ok.json")
|
||||||
|
|
||||||
|
val response = client.api.getBookmarks().execute()
|
||||||
|
|
||||||
|
assertResponseSuccessful(response)
|
||||||
|
response.body().bookmarkList.size `should equal to` 1
|
||||||
|
with(response.body().bookmarkList[0]) {
|
||||||
|
position `should equal to` 107914
|
||||||
|
username `should equal to` "CaptainEurope"
|
||||||
|
comment `should equal to` "Look at this"
|
||||||
|
created `should equal` parseDate("2017-11-18T15:22:22.144Z")
|
||||||
|
changed `should equal` parseDate("2017-11-18T15:22:22.144Z")
|
||||||
|
entry `should equal` MusicDirectoryChild(id = 10349, parent = 10342,
|
||||||
|
isDir = false, title = "Amerika", album = "Home of the Strange",
|
||||||
|
artist = "Young the Giant", track = 1, year = 2016, genre = "Indie Rock",
|
||||||
|
coverArt = "10342", size = 9628673, contentType = "audio/mpeg",
|
||||||
|
suffix = "mp3", duration = 240, bitRate = 320,
|
||||||
|
path = "Young the Giant/Home of the Strange/01 Amerika.mp3",
|
||||||
|
isVideo = false, playCount = 2, discNumber = 1,
|
||||||
|
created = parseDate("2017-11-01T17:46:52.000Z"),
|
||||||
|
albumId = 984, artistId = 571, type = "music")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
{
|
||||||
|
"subsonic-response" : {
|
||||||
|
"status" : "ok",
|
||||||
|
"version" : "1.15.0",
|
||||||
|
"bookmarks" : {
|
||||||
|
"bookmark" : [ {
|
||||||
|
"position" : 107914,
|
||||||
|
"username" : "CaptainEurope",
|
||||||
|
"comment" : "Look at this",
|
||||||
|
"created" : "2017-11-18T15:22:22.144Z",
|
||||||
|
"changed" : "2017-11-18T15:22:22.144Z",
|
||||||
|
"entry" : {
|
||||||
|
"id" : "10349",
|
||||||
|
"parent" : "10342",
|
||||||
|
"isDir" : false,
|
||||||
|
"title" : "Amerika",
|
||||||
|
"album" : "Home of the Strange",
|
||||||
|
"artist" : "Young the Giant",
|
||||||
|
"track" : 1,
|
||||||
|
"year" : 2016,
|
||||||
|
"genre" : "Indie Rock",
|
||||||
|
"coverArt" : "10342",
|
||||||
|
"size" : 9628673,
|
||||||
|
"contentType" : "audio/mpeg",
|
||||||
|
"suffix" : "mp3",
|
||||||
|
"duration" : 240,
|
||||||
|
"bitRate" : 320,
|
||||||
|
"path" : "Young the Giant/Home of the Strange/01 Amerika.mp3",
|
||||||
|
"isVideo" : false,
|
||||||
|
"playCount" : 2,
|
||||||
|
"discNumber" : 1,
|
||||||
|
"created" : "2017-11-01T17:46:52.000Z",
|
||||||
|
"albumId" : "984",
|
||||||
|
"artistId" : "571",
|
||||||
|
"type" : "music"
|
||||||
|
}
|
||||||
|
} ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package org.moire.ultrasonic.api.subsonic
|
||||||
import okhttp3.ResponseBody
|
import okhttp3.ResponseBody
|
||||||
import org.moire.ultrasonic.api.subsonic.models.AlbumListType
|
import org.moire.ultrasonic.api.subsonic.models.AlbumListType
|
||||||
import org.moire.ultrasonic.api.subsonic.models.JukeboxAction
|
import org.moire.ultrasonic.api.subsonic.models.JukeboxAction
|
||||||
|
import org.moire.ultrasonic.api.subsonic.response.BookmarksResponse
|
||||||
import org.moire.ultrasonic.api.subsonic.response.ChatMessagesResponse
|
import org.moire.ultrasonic.api.subsonic.response.ChatMessagesResponse
|
||||||
import org.moire.ultrasonic.api.subsonic.response.GenresResponse
|
import org.moire.ultrasonic.api.subsonic.response.GenresResponse
|
||||||
import org.moire.ultrasonic.api.subsonic.response.GetAlbumList2Response
|
import org.moire.ultrasonic.api.subsonic.response.GetAlbumList2Response
|
||||||
|
@ -220,4 +221,7 @@ interface SubsonicAPIDefinition {
|
||||||
|
|
||||||
@GET("addChatMessage.view")
|
@GET("addChatMessage.view")
|
||||||
fun addChatMessage(@Query("message") message: String): Call<SubsonicResponse>
|
fun addChatMessage(@Query("message") message: String): Call<SubsonicResponse>
|
||||||
|
|
||||||
|
@GET("getBookmarks.view")
|
||||||
|
fun getBookmarks(): Call<BookmarksResponse>
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package org.moire.ultrasonic.api.subsonic.models
|
||||||
|
|
||||||
|
import java.util.Calendar
|
||||||
|
|
||||||
|
data class Bookmark(
|
||||||
|
val position: Long = 0,
|
||||||
|
val username: String = "",
|
||||||
|
val comment: String = "",
|
||||||
|
val created: Calendar? = null,
|
||||||
|
val changed: Calendar? = null,
|
||||||
|
val entry: MusicDirectoryChild = MusicDirectoryChild())
|
|
@ -0,0 +1,18 @@
|
||||||
|
package org.moire.ultrasonic.api.subsonic.response
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
|
import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
|
||||||
|
import org.moire.ultrasonic.api.subsonic.SubsonicError
|
||||||
|
import org.moire.ultrasonic.api.subsonic.models.Bookmark
|
||||||
|
|
||||||
|
class BookmarksResponse(
|
||||||
|
status: Status,
|
||||||
|
version: SubsonicAPIVersions,
|
||||||
|
error: SubsonicError?) : SubsonicResponse(status, version, error) {
|
||||||
|
@JsonProperty("bookmarks") private val bookmarksWrapper = BookmarkWrapper()
|
||||||
|
|
||||||
|
val bookmarkList: List<Bookmark> get() = bookmarksWrapper.bookmarkList
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class BookmarkWrapper(
|
||||||
|
@JsonProperty("bookmark") val bookmarkList: List<Bookmark> = emptyList())
|
Loading…
Reference in New Issue