mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-14 18:50:51 +01:00
Add getShares call.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
6e05dc7c40
commit
d5cdc18174
@ -0,0 +1,50 @@
|
|||||||
|
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.getShares] call.
|
||||||
|
*/
|
||||||
|
class SubsonicApiGetSharesTest : SubsonicAPIClientTest() {
|
||||||
|
@Test
|
||||||
|
fun `Should handle error response`() {
|
||||||
|
val response = checkErrorCallParsed(mockWebServerRule) {
|
||||||
|
client.api.getShares().execute()
|
||||||
|
}
|
||||||
|
|
||||||
|
response.shares `should equal` emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `Should handle ok response`() {
|
||||||
|
mockWebServerRule.enqueueResponse("get_shares_ok.json")
|
||||||
|
|
||||||
|
val response = client.api.getShares().execute()
|
||||||
|
|
||||||
|
assertResponseSuccessful(response)
|
||||||
|
response.body().shares.size `should equal to` 1
|
||||||
|
with(response.body().shares[0]) {
|
||||||
|
id `should equal to` 0
|
||||||
|
url `should equal to` "https://airsonic.egorr.by/ext/share/awdwo?jwt=eyJhbGciOiJIUzI1" +
|
||||||
|
"NiJ9.eyJwYXRoIjoiL2V4dC9zaGFyZS9hd2R3byIsImV4cCI6MTU0MTYyNjQzMX0.iy8dkt_ZZc8" +
|
||||||
|
"hJ692UxorHdHWFU2RB-fMCmCA4IJ_dTw"
|
||||||
|
username `should equal to` "admin"
|
||||||
|
created `should equal` parseDate("2017-11-07T21:33:51.748Z")
|
||||||
|
expires `should equal` parseDate("2018-11-07T21:33:51.748Z")
|
||||||
|
lastVisited `should equal` parseDate("2018-11-07T21:33:51.748Z")
|
||||||
|
visitCount `should equal to` 0
|
||||||
|
description `should equal to` "Awesome link!"
|
||||||
|
items.size `should equal to` 1
|
||||||
|
items[0] `should equal` MusicDirectoryChild(id = 4212, parent = 4186, isDir = false,
|
||||||
|
title = "Heaven Knows", album = "Going to Hell", artist = "The Pretty Reckless",
|
||||||
|
track = 3, year = 2014, genre = "Hard Rock", coverArt = "4186", size = 9025090,
|
||||||
|
contentType = "audio/mpeg", suffix = "mp3", duration = 225, bitRate = 320,
|
||||||
|
path = "The Pretty Reckless/Going to Hell/03 Heaven Knows.mp3", isVideo = false,
|
||||||
|
playCount = 2, discNumber = 1, created = parseDate("2016-10-23T21:30:40.000Z"),
|
||||||
|
albumId = 388, artistId = 238, type = "music")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
"subsonic-response" : {
|
||||||
|
"status" : "ok",
|
||||||
|
"version" : "1.15.0",
|
||||||
|
"shares" : {
|
||||||
|
"share" : [ {
|
||||||
|
"id" : "0",
|
||||||
|
"url" : "https://airsonic.egorr.by/ext/share/awdwo?jwt=eyJhbGciOiJIUzI1NiJ9.eyJwYXRoIjoiL2V4dC9zaGFyZS9hd2R3byIsImV4cCI6MTU0MTYyNjQzMX0.iy8dkt_ZZc8hJ692UxorHdHWFU2RB-fMCmCA4IJ_dTw",
|
||||||
|
"username" : "admin",
|
||||||
|
"created" : "2017-11-07T21:33:51.748Z",
|
||||||
|
"expires" : "2018-11-07T21:33:51.748Z",
|
||||||
|
"lastVisited" : "2018-11-07T21:33:51.748Z",
|
||||||
|
"description" : "Awesome link!",
|
||||||
|
"visitCount" : 0,
|
||||||
|
"entry" : [ {
|
||||||
|
"id" : "4212",
|
||||||
|
"parent" : "4186",
|
||||||
|
"isDir" : false,
|
||||||
|
"title" : "Heaven Knows",
|
||||||
|
"album" : "Going to Hell",
|
||||||
|
"artist" : "The Pretty Reckless",
|
||||||
|
"track" : 3,
|
||||||
|
"year" : 2014,
|
||||||
|
"genre" : "Hard Rock",
|
||||||
|
"coverArt" : "4186",
|
||||||
|
"size" : 9025090,
|
||||||
|
"contentType" : "audio/mpeg",
|
||||||
|
"suffix" : "mp3",
|
||||||
|
"duration" : 225,
|
||||||
|
"bitRate" : 320,
|
||||||
|
"path" : "The Pretty Reckless/Going to Hell/03 Heaven Knows.mp3",
|
||||||
|
"isVideo" : false,
|
||||||
|
"playCount" : 2,
|
||||||
|
"discNumber" : 1,
|
||||||
|
"created" : "2016-10-23T21:30:40.000Z",
|
||||||
|
"albumId" : "388",
|
||||||
|
"artistId" : "238",
|
||||||
|
"type" : "music"
|
||||||
|
} ]
|
||||||
|
} ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -23,6 +23,7 @@ import org.moire.ultrasonic.api.subsonic.response.MusicFoldersResponse
|
|||||||
import org.moire.ultrasonic.api.subsonic.response.SearchResponse
|
import org.moire.ultrasonic.api.subsonic.response.SearchResponse
|
||||||
import org.moire.ultrasonic.api.subsonic.response.SearchThreeResponse
|
import org.moire.ultrasonic.api.subsonic.response.SearchThreeResponse
|
||||||
import org.moire.ultrasonic.api.subsonic.response.SearchTwoResponse
|
import org.moire.ultrasonic.api.subsonic.response.SearchTwoResponse
|
||||||
|
import org.moire.ultrasonic.api.subsonic.response.SharesResponse
|
||||||
import org.moire.ultrasonic.api.subsonic.response.SubsonicResponse
|
import org.moire.ultrasonic.api.subsonic.response.SubsonicResponse
|
||||||
import retrofit2.Call
|
import retrofit2.Call
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
@ -188,4 +189,7 @@ interface SubsonicAPIDefinition {
|
|||||||
@Query("offset") offset: Int? = null,
|
@Query("offset") offset: Int? = null,
|
||||||
@Query("id") ids: List<String>? = null,
|
@Query("id") ids: List<String>? = null,
|
||||||
@Query("gain") gain: Float? = null): Call<JukeboxResponse>
|
@Query("gain") gain: Float? = null): Call<JukeboxResponse>
|
||||||
|
|
||||||
|
@GET("getShares.view")
|
||||||
|
fun getShares(): Call<SharesResponse>
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package org.moire.ultrasonic.api.subsonic.models
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
|
import java.util.Calendar
|
||||||
|
|
||||||
|
data class Share(
|
||||||
|
val id: Long = -1L,
|
||||||
|
val url: String = "",
|
||||||
|
val username: String = "",
|
||||||
|
val created: Calendar? = null,
|
||||||
|
val expires: Calendar? = null,
|
||||||
|
val visitCount: Int = 0,
|
||||||
|
val description: String = "",
|
||||||
|
val lastVisited: Calendar? = null,
|
||||||
|
@JsonProperty("entry") val items: List<MusicDirectoryChild> = emptyList())
|
@ -0,0 +1,17 @@
|
|||||||
|
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.Share
|
||||||
|
|
||||||
|
class SharesResponse(status: Status,
|
||||||
|
version: SubsonicAPIVersions,
|
||||||
|
error: SubsonicError?)
|
||||||
|
: SubsonicResponse(status, version, error) {
|
||||||
|
@JsonProperty("shares") private val wrappedShares = SharesWrapper()
|
||||||
|
|
||||||
|
val shares get() = wrappedShares.share
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class SharesWrapper(val share: List<Share> = emptyList())
|
Loading…
x
Reference in New Issue
Block a user