Add getUser api call.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
69f68460de
commit
6b74a3e563
|
@ -0,0 +1,57 @@
|
||||||
|
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.User
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integration test for [SubsonicAPIDefinition.getUser] call.
|
||||||
|
*/
|
||||||
|
class SubsonicApiGetUserTest : SubsonicAPIClientTest() {
|
||||||
|
@Test
|
||||||
|
fun `Should handle error response`() {
|
||||||
|
val response = checkErrorCallParsed(mockWebServerRule) {
|
||||||
|
client.api.getUser("some").execute()
|
||||||
|
}
|
||||||
|
|
||||||
|
response.user `should equal` User()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `Should handle ok response`() {
|
||||||
|
mockWebServerRule.enqueueResponse("get_user_ok.json")
|
||||||
|
|
||||||
|
val response = client.api.getUser("some").execute()
|
||||||
|
|
||||||
|
assertResponseSuccessful(response)
|
||||||
|
with(response.body().user) {
|
||||||
|
username `should equal to` "GodOfUniverse"
|
||||||
|
email `should equal to` "some.mail@example.com"
|
||||||
|
scrobblingEnabled `should equal to` false
|
||||||
|
adminRole `should equal to` true
|
||||||
|
settingsRole `should equal to` true
|
||||||
|
downloadRole `should equal to` true
|
||||||
|
uploadRole `should equal to` true
|
||||||
|
playlistRole `should equal to` true
|
||||||
|
coverArtRole `should equal to` true
|
||||||
|
commentRole `should equal to` true
|
||||||
|
podcastRole `should equal to` true
|
||||||
|
streamRole `should equal to` true
|
||||||
|
jukeboxRole `should equal to` true
|
||||||
|
shareRole `should equal to` true
|
||||||
|
videoConverstionRole `should equal to` false
|
||||||
|
folderList.size `should equal to` 1
|
||||||
|
folderList[0] `should equal to` 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `Should pass username in request param`() {
|
||||||
|
val username = "Mighty"
|
||||||
|
|
||||||
|
mockWebServerRule.assertRequestParam(expectedParam = "username=$username") {
|
||||||
|
client.api.getUser(username).execute()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"subsonic-response" : {
|
||||||
|
"status" : "ok",
|
||||||
|
"version" : "1.15.0",
|
||||||
|
"user" : {
|
||||||
|
"username" : "GodOfUniverse",
|
||||||
|
"email" : "some.mail@example.com",
|
||||||
|
"scrobblingEnabled" : false,
|
||||||
|
"adminRole" : true,
|
||||||
|
"settingsRole" : true,
|
||||||
|
"downloadRole" : true,
|
||||||
|
"uploadRole" : true,
|
||||||
|
"playlistRole" : true,
|
||||||
|
"coverArtRole" : true,
|
||||||
|
"commentRole" : true,
|
||||||
|
"podcastRole" : true,
|
||||||
|
"streamRole" : true,
|
||||||
|
"jukeboxRole" : true,
|
||||||
|
"shareRole" : true,
|
||||||
|
"videoConversionRole" : false,
|
||||||
|
"folder" : [ 0 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,6 +19,7 @@ import org.moire.ultrasonic.api.subsonic.response.GetRandomSongsResponse
|
||||||
import org.moire.ultrasonic.api.subsonic.response.GetSongsByGenreResponse
|
import org.moire.ultrasonic.api.subsonic.response.GetSongsByGenreResponse
|
||||||
import org.moire.ultrasonic.api.subsonic.response.GetStarredResponse
|
import org.moire.ultrasonic.api.subsonic.response.GetStarredResponse
|
||||||
import org.moire.ultrasonic.api.subsonic.response.GetStarredTwoResponse
|
import org.moire.ultrasonic.api.subsonic.response.GetStarredTwoResponse
|
||||||
|
import org.moire.ultrasonic.api.subsonic.response.GetUserResponse
|
||||||
import org.moire.ultrasonic.api.subsonic.response.JukeboxResponse
|
import org.moire.ultrasonic.api.subsonic.response.JukeboxResponse
|
||||||
import org.moire.ultrasonic.api.subsonic.response.LicenseResponse
|
import org.moire.ultrasonic.api.subsonic.response.LicenseResponse
|
||||||
import org.moire.ultrasonic.api.subsonic.response.MusicFoldersResponse
|
import org.moire.ultrasonic.api.subsonic.response.MusicFoldersResponse
|
||||||
|
@ -209,4 +210,8 @@ interface SubsonicAPIDefinition {
|
||||||
@Query("count") count: Int = 10,
|
@Query("count") count: Int = 10,
|
||||||
@Query("offset") offset: Int = 0,
|
@Query("offset") offset: Int = 0,
|
||||||
@Query("musicFolderId") musicFolderId: Long? = null): Call<GetSongsByGenreResponse>
|
@Query("musicFolderId") musicFolderId: Long? = null): Call<GetSongsByGenreResponse>
|
||||||
|
|
||||||
|
@GET("getUser.view")
|
||||||
|
fun getUser(
|
||||||
|
@Query("username") username: String): Call<GetUserResponse>
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package org.moire.ultrasonic.api.subsonic.models
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
|
|
||||||
|
data class User(
|
||||||
|
val username: String = "",
|
||||||
|
val email: String = "",
|
||||||
|
val scrobblingEnabled: Boolean = false,
|
||||||
|
val adminRole: Boolean = false,
|
||||||
|
val settingsRole: Boolean = false,
|
||||||
|
val downloadRole: Boolean = false,
|
||||||
|
val uploadRole: Boolean = false,
|
||||||
|
val playlistRole: Boolean = false,
|
||||||
|
val coverArtRole: Boolean = false,
|
||||||
|
val commentRole: Boolean = false,
|
||||||
|
val podcastRole: Boolean = false,
|
||||||
|
val streamRole: Boolean = false,
|
||||||
|
val jukeboxRole: Boolean = false,
|
||||||
|
val shareRole: Boolean = false,
|
||||||
|
val videoConverstionRole: Boolean = false,
|
||||||
|
@JsonProperty("folder") val folderList: List<Int> = emptyList())
|
|
@ -0,0 +1,11 @@
|
||||||
|
package org.moire.ultrasonic.api.subsonic.response
|
||||||
|
|
||||||
|
import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
|
||||||
|
import org.moire.ultrasonic.api.subsonic.SubsonicError
|
||||||
|
import org.moire.ultrasonic.api.subsonic.models.User
|
||||||
|
|
||||||
|
class GetUserResponse(
|
||||||
|
status: Status,
|
||||||
|
version: SubsonicAPIVersions,
|
||||||
|
error: SubsonicError?,
|
||||||
|
val user: User = User()) : SubsonicResponse(status, version, error)
|
Loading…
Reference in New Issue