Update Ktlint to 0.20.0 version.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2018-03-24 19:47:55 +01:00
parent 46922d98ae
commit eb09e9b417
77 changed files with 722 additions and 583 deletions

View File

@ -8,7 +8,7 @@ ext.versions = [
gradle : '4.5.1',
androidTools : "3.0.1",
ktlint : "0.15.1",
ktlint : "0.20.0",
ktlintGradle : "3.2.0",
detekt : "1.0.0.RC6-4",
jacoco : "0.7.9",

View File

@ -26,7 +26,8 @@ class MusicDirectory {
@JvmOverloads
fun getChildren(
includeDirs: Boolean = true,
includeFiles: Boolean = true): List<Entry> {
includeFiles: Boolean = true
): List<Entry> {
if (includeDirs && includeFiles) {
return children
}

View File

@ -57,8 +57,10 @@ fun parseDate(dateAsString: String): Calendar {
return result
}
fun <T : SubsonicResponse> checkErrorCallParsed(mockWebServerRule: MockWebServerRule,
apiRequest: () -> Response<T>): T {
fun <T : SubsonicResponse> checkErrorCallParsed(
mockWebServerRule: MockWebServerRule,
apiRequest: () -> Response<T>
): T {
mockWebServerRule.enqueueResponse("request_data_not_found_error_response.json")
val response = apiRequest()
@ -77,9 +79,11 @@ fun SubsonicResponse.assertBaseResponseOk() {
error `should be` null
}
fun MockWebServerRule.assertRequestParam(responseResourceName: String = "ping_ok.json",
fun MockWebServerRule.assertRequestParam(
responseResourceName: String = "ping_ok.json",
expectedParam: String,
apiRequest: () -> Response<out Any>) {
apiRequest: () -> Response<out Any>
) {
this.enqueueResponse(responseResourceName)
apiRequest()

View File

@ -37,9 +37,11 @@ class SubsonicApiSSLTest {
mockWebServer.shutdown()
}
private fun createSSLContext(certificatePemStream: InputStream,
private fun createSSLContext(
certificatePemStream: InputStream,
certificatePkcs12Stream: InputStream,
password: String): SSLContext {
password: String
): SSLContext {
var cert: X509Certificate? = null
val trustStore = KeyStore.getInstance(KeyStore.getDefaultType())
trustStore.load(null)

View File

@ -7,5 +7,5 @@ import java.io.IOException
* by current server api version.
*/
class ApiNotSupportedException(
serverApiVersion: SubsonicAPIVersions)
: IOException("Server api $serverApiVersion does not support this call")
serverApiVersion: SubsonicAPIVersions
) : IOException("Server api $serverApiVersion does not support this call")

View File

@ -44,7 +44,8 @@ import retrofit2.Call
*/
internal class ApiVersionCheckWrapper(
val api: SubsonicAPIDefinition,
var currentApiVersion: SubsonicAPIVersions) : SubsonicAPIDefinition by api {
var currentApiVersion: SubsonicAPIVersions
) : SubsonicAPIDefinition by api {
override fun getArtists(musicFolderId: String?): Call<GetArtistsResponse> {
checkVersion(V1_8_0)
return api.getArtists(musicFolderId)
@ -70,26 +71,30 @@ internal class ApiVersionCheckWrapper(
return api.getAlbum(id)
}
override fun search2(query: String,
override fun search2(
query: String,
artistCount: Int?,
artistOffset: Int?,
albumCount: Int?,
albumOffset: Int?,
songCount: Int?,
musicFolderId: String?): Call<SearchTwoResponse> {
musicFolderId: String?
): Call<SearchTwoResponse> {
checkVersion(V1_4_0)
checkParamVersion(musicFolderId, V1_12_0)
return api.search2(query, artistCount, artistOffset, albumCount, albumOffset, songCount,
musicFolderId)
}
override fun search3(query: String,
override fun search3(
query: String,
artistCount: Int?,
artistOffset: Int?,
albumCount: Int?,
albumOffset: Int?,
songCount: Int?,
musicFolderId: String?): Call<SearchThreeResponse> {
musicFolderId: String?
): Call<SearchThreeResponse> {
checkVersion(V1_8_0)
checkParamVersion(musicFolderId, V1_12_0)
return api.search3(query, artistCount, artistOffset, albumCount, albumOffset,
@ -101,9 +106,11 @@ internal class ApiVersionCheckWrapper(
return api.getPlaylists(username)
}
override fun createPlaylist(id: String?,
override fun createPlaylist(
id: String?,
name: String?,
songIds: List<String>?): Call<SubsonicResponse> {
songIds: List<String>?
): Call<SubsonicResponse> {
checkVersion(V1_2_0)
return api.createPlaylist(id, name, songIds)
}
@ -113,12 +120,14 @@ internal class ApiVersionCheckWrapper(
return api.deletePlaylist(id)
}
override fun updatePlaylist(id: String,
override fun updatePlaylist(
id: String,
name: String?,
comment: String?,
public: Boolean?,
songIdsToAdd: List<String>?,
songIndexesToRemove: List<Int>?): Call<SubsonicResponse> {
songIndexesToRemove: List<Int>?
): Call<SubsonicResponse> {
checkVersion(V1_8_0)
return api.updatePlaylist(id, name, comment, public, songIdsToAdd, songIndexesToRemove)
}
@ -141,35 +150,41 @@ internal class ApiVersionCheckWrapper(
return api.scrobble(id, time, submission)
}
override fun getAlbumList(type: AlbumListType,
override fun getAlbumList(
type: AlbumListType,
size: Int?,
offset: Int?,
fromYear: Int?,
toYear: Int?,
genre: String?,
musicFolderId: String?): 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)
}
override fun getAlbumList2(type: AlbumListType,
override fun getAlbumList2(
type: AlbumListType,
size: Int?,
offset: Int?,
fromYear: Int?,
toYear: Int?,
genre: String?,
musicFolderId: String?): 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)
}
override fun getRandomSongs(size: Int?,
override fun getRandomSongs(
size: Int?,
genre: String?,
fromYear: Int?,
toYear: Int?,
musicFolderId: String?): Call<GetRandomSongsResponse> {
musicFolderId: String?
): Call<GetRandomSongsResponse> {
checkVersion(V1_2_0)
return api.getRandomSongs(size, genre, fromYear, toYear, musicFolderId)
}
@ -186,14 +201,16 @@ internal class ApiVersionCheckWrapper(
return api.getStarred2(musicFolderId)
}
override fun stream(id: String,
override fun stream(
id: String,
maxBitRate: Int?,
format: String?,
timeOffset: Int?,
videoSize: String?,
estimateContentLength: Boolean?,
converted: Boolean?,
offset: Long?): Call<ResponseBody> {
offset: Long?
): Call<ResponseBody> {
checkParamVersion(maxBitRate, V1_2_0)
checkParamVersion(format, V1_6_0)
checkParamVersion(videoSize, V1_6_0)
@ -203,11 +220,13 @@ internal class ApiVersionCheckWrapper(
estimateContentLength, converted)
}
override fun jukeboxControl(action: JukeboxAction,
override fun jukeboxControl(
action: JukeboxAction,
index: Int?,
offset: Int?,
ids: List<String>?,
gain: Float?): Call<JukeboxResponse> {
gain: Float?
): Call<JukeboxResponse> {
checkVersion(V1_2_0)
checkParamVersion(offset, V1_7_0)
return api.jukeboxControl(action, index, offset, ids, gain)
@ -218,9 +237,11 @@ internal class ApiVersionCheckWrapper(
return api.getShares()
}
override fun createShare(idsToShare: List<String>,
override fun createShare(
idsToShare: List<String>,
description: String?,
expires: Long?): Call<SharesResponse> {
expires: Long?
): Call<SharesResponse> {
checkVersion(V1_6_0)
return api.createShare(idsToShare, description, expires)
}
@ -230,9 +251,11 @@ internal class ApiVersionCheckWrapper(
return api.deleteShare(id)
}
override fun updateShare(id: String,
override fun updateShare(
id: String,
description: String?,
expires: Long?): Call<SubsonicResponse> {
expires: Long?
): Call<SubsonicResponse> {
checkVersion(V1_6_0)
return api.updateShare(id, description, expires)
}
@ -242,10 +265,12 @@ internal class ApiVersionCheckWrapper(
return api.getGenres()
}
override fun getSongsByGenre(genre: String,
override fun getSongsByGenre(
genre: String,
count: Int,
offset: Int,
musicFolderId: String?): Call<GetSongsByGenreResponse> {
musicFolderId: String?
): Call<GetSongsByGenreResponse> {
checkVersion(V1_9_0)
checkParamVersion(musicFolderId, V1_12_0)
return api.getSongsByGenre(genre, count, offset, musicFolderId)
@ -271,9 +296,11 @@ internal class ApiVersionCheckWrapper(
return api.getBookmarks()
}
override fun createBookmark(id: String,
override fun createBookmark(
id: String,
position: Long,
comment: String?): Call<SubsonicResponse> {
comment: String?
): Call<SubsonicResponse> {
checkVersion(V1_9_0)
return api.createBookmark(id, position, comment)
}

View File

@ -35,14 +35,16 @@ private const val READ_TIMEOUT = 60_000L
*
* @author Yahor Berdnikau
*/
class SubsonicAPIClient(baseUrl: String,
class SubsonicAPIClient(
baseUrl: String,
username: String,
password: String,
minimalProtocolVersion: SubsonicAPIVersions,
clientID: String,
allowSelfSignedCertificate: Boolean = false,
enableLdapUserSupport: Boolean = false,
debug: Boolean = false) {
debug: Boolean = false
) {
private val versionInterceptor = VersionInterceptor(minimalProtocolVersion) {
protocolVersion = it
}

View File

@ -54,8 +54,10 @@ interface SubsonicAPIDefinition {
fun getMusicFolders(): Call<MusicFoldersResponse>
@GET("getIndexes.view")
fun getIndexes(@Query("musicFolderId") musicFolderId: String?,
@Query("ifModifiedSince") ifModifiedSince: Long?): Call<GetIndexesResponse>
fun getIndexes(
@Query("musicFolderId") musicFolderId: String?,
@Query("ifModifiedSince") ifModifiedSince: Long?
): Call<GetIndexesResponse>
@GET("getMusicDirectory.view")
fun getMusicDirectory(@Query("id") id: String): Call<GetMusicDirectoryResponse>
@ -64,14 +66,18 @@ interface SubsonicAPIDefinition {
fun getArtists(@Query("musicFolderId") musicFolderId: String?): Call<GetArtistsResponse>
@GET("star.view")
fun star(@Query("id") id: String? = null,
fun star(
@Query("id") id: String? = null,
@Query("albumId") albumId: String? = null,
@Query("artistId") artistId: String? = null): Call<SubsonicResponse>
@Query("artistId") artistId: String? = null
): Call<SubsonicResponse>
@GET("unstar.view")
fun unstar(@Query("id") id: String? = null,
fun unstar(
@Query("id") id: String? = null,
@Query("albumId") albumId: String? = null,
@Query("artistId") artistId: String? = null): Call<SubsonicResponse>
@Query("artistId") artistId: String? = null
): Call<SubsonicResponse>
@GET("getArtist.view")
fun getArtist(@Query("id") id: String): Call<GetArtistResponse>
@ -80,31 +86,37 @@ interface SubsonicAPIDefinition {
fun getAlbum(@Query("id") id: String): Call<GetAlbumResponse>
@GET("search.view")
fun search(@Query("artist") artist: String? = null,
fun search(
@Query("artist") artist: String? = null,
@Query("album") album: String? = null,
@Query("title") title: String? = null,
@Query("any") any: String? = null,
@Query("count") count: Int? = null,
@Query("offset") offset: Int? = null,
@Query("newerThan") newerThan: Long? = null): Call<SearchResponse>
@Query("newerThan") newerThan: Long? = null
): Call<SearchResponse>
@GET("search2.view")
fun search2(@Query("query") query: String,
fun search2(
@Query("query") query: String,
@Query("artistCount") artistCount: Int? = null,
@Query("artistOffset") artistOffset: Int? = null,
@Query("albumCount") albumCount: Int? = null,
@Query("albumOffset") albumOffset: Int? = null,
@Query("songCount") songCount: Int? = null,
@Query("musicFolderId") musicFolderId: String? = null): Call<SearchTwoResponse>
@Query("musicFolderId") musicFolderId: String? = null
): Call<SearchTwoResponse>
@GET("search3.view")
fun search3(@Query("query") query: String,
fun search3(
@Query("query") query: String,
@Query("artistCount") artistCount: Int? = null,
@Query("artistOffset") artistOffset: Int? = null,
@Query("albumCount") albumCount: Int? = null,
@Query("albumOffset") albumOffset: Int? = null,
@Query("songCount") songCount: Int? = null,
@Query("musicFolderId") musicFolderId: String? = null): Call<SearchThreeResponse>
@Query("musicFolderId") musicFolderId: String? = null
): Call<SearchThreeResponse>
@GET("getPlaylist.view")
fun getPlaylist(@Query("id") id: String): Call<GetPlaylistResponse>
@ -113,9 +125,11 @@ interface SubsonicAPIDefinition {
fun getPlaylists(@Query("username") username: String? = null): Call<GetPlaylistsResponse>
@GET("createPlaylist.view")
fun createPlaylist(@Query("playlistId") id: String? = null,
fun createPlaylist(
@Query("playlistId") id: String? = null,
@Query("name") name: String? = null,
@Query("songId") songIds: List<String>? = null): Call<SubsonicResponse>
@Query("songId") songIds: List<String>? = null
): Call<SubsonicResponse>
@GET("deletePlaylist.view")
fun deletePlaylist(@Query("id") id: String): Call<SubsonicResponse>
@ -127,21 +141,28 @@ interface SubsonicAPIDefinition {
@Query("comment") comment: String? = null,
@Query("public") public: Boolean? = null,
@Query("songIdToAdd") songIdsToAdd: List<String>? = null,
@Query("songIndexToRemove") songIndexesToRemove: List<Int>? = null):
@Query("songIndexToRemove") songIndexesToRemove: List<Int>? = null
):
Call<SubsonicResponse>
@GET("getPodcasts.view")
fun getPodcasts(@Query("includeEpisodes") includeEpisodes: Boolean? = null,
@Query("id") id: String? = null): Call<GetPodcastsResponse>
fun getPodcasts(
@Query("includeEpisodes") includeEpisodes: Boolean? = null,
@Query("id") id: String? = null
): Call<GetPodcastsResponse>
@GET("getLyrics.view")
fun getLyrics(@Query("artist") artist: String? = null,
@Query("title") title: String? = null): Call<GetLyricsResponse>
fun getLyrics(
@Query("artist") artist: String? = null,
@Query("title") title: String? = null
): Call<GetLyricsResponse>
@GET("scrobble.view")
fun scrobble(@Query("id") id: String,
fun scrobble(
@Query("id") id: String,
@Query("time") time: Long? = null,
@Query("submission") submission: Boolean? = null): Call<SubsonicResponse>
@Query("submission") submission: Boolean? = null
): Call<SubsonicResponse>
@GET("getAlbumList.view")
fun getAlbumList(
@ -151,7 +172,8 @@ interface SubsonicAPIDefinition {
@Query("fromYear") fromYear: Int? = null,
@Query("toYear") toYear: Int? = null,
@Query("genre") genre: String? = null,
@Query("musicFolderId") musicFolderId: String? = null): Call<GetAlbumListResponse>
@Query("musicFolderId") musicFolderId: String? = null
): Call<GetAlbumListResponse>
@GET("getAlbumList2.view")
fun getAlbumList2(
@ -161,7 +183,8 @@ interface SubsonicAPIDefinition {
@Query("fromYear") fromYear: Int? = null,
@Query("toYear") toYear: Int? = null,
@Query("genre") genre: String? = null,
@Query("musicFolderId") musicFolderId: String? = null): Call<GetAlbumList2Response>
@Query("musicFolderId") musicFolderId: String? = null
): Call<GetAlbumList2Response>
@GET("getRandomSongs.view")
fun getRandomSongs(
@ -169,53 +192,65 @@ interface SubsonicAPIDefinition {
@Query("genre") genre: String? = null,
@Query("fromYear") fromYear: Int? = null,
@Query("toYear") toYear: Int? = null,
@Query("musicFolderId") musicFolderId: String? = null): Call<GetRandomSongsResponse>
@Query("musicFolderId") musicFolderId: String? = null
): Call<GetRandomSongsResponse>
@GET("getStarred.view")
fun getStarred(@Query("musicFolderId") musicFolderId: String? = null): Call<GetStarredResponse>
@GET("getStarred2.view")
fun getStarred2(
@Query("musicFolderId") musicFolderId: String? = null): Call<GetStarredTwoResponse>
@Query("musicFolderId") musicFolderId: String? = null
): Call<GetStarredTwoResponse>
@Streaming
@GET("getCoverArt.view")
fun getCoverArt(@Query("id") id: String,
@Query("size") size: Long? = null): Call<ResponseBody>
fun getCoverArt(
@Query("id") id: String,
@Query("size") size: Long? = null
): Call<ResponseBody>
@Streaming
@GET("stream.view")
fun stream(@Query("id") id: String,
fun stream(
@Query("id") id: String,
@Query("maxBitRate") maxBitRate: Int? = null,
@Query("format") format: String? = null,
@Query("timeOffset") timeOffset: Int? = null,
@Query("size") videoSize: String? = null,
@Query("estimateContentLength") estimateContentLength: Boolean? = null,
@Query("converted") converted: Boolean? = null,
@Header("Range") offset: Long? = null): Call<ResponseBody>
@Header("Range") offset: Long? = null
): Call<ResponseBody>
@GET("jukeboxControl.view")
fun jukeboxControl(@Query("action") action: JukeboxAction,
fun jukeboxControl(
@Query("action") action: JukeboxAction,
@Query("index") index: Int? = null,
@Query("offset") offset: Int? = 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>
@GET("createShare.view")
fun createShare(@Query("id") idsToShare: List<String>,
fun createShare(
@Query("id") idsToShare: List<String>,
@Query("description") description: String? = null,
@Query("expires") expires: Long? = null): Call<SharesResponse>
@Query("expires") expires: Long? = null
): Call<SharesResponse>
@GET("deleteShare.view")
fun deleteShare(@Query("id") id: String): Call<SubsonicResponse>
@GET("updateShare.view")
fun updateShare(@Query("id") id: String,
fun updateShare(
@Query("id") id: String,
@Query("description") description: String? = null,
@Query("expires") expires: Long? = null): Call<SubsonicResponse>
@Query("expires") expires: Long? = null
): Call<SubsonicResponse>
@GET("getGenres.view")
fun getGenres(): Call<GenresResponse>
@ -225,7 +260,8 @@ interface SubsonicAPIDefinition {
@Query("genre") genre: String,
@Query("count") count: Int = 10,
@Query("offset") offset: Int = 0,
@Query("musicFolderId") musicFolderId: String? = null): Call<GetSongsByGenreResponse>
@Query("musicFolderId") musicFolderId: String? = null
): Call<GetSongsByGenreResponse>
@GET("getUser.view")
fun getUser(@Query("username") username: String): Call<GetUserResponse>
@ -243,7 +279,8 @@ interface SubsonicAPIDefinition {
fun createBookmark(
@Query("id") id: String,
@Query("position") position: Long,
@Query("comment") comment: String? = null): Call<SubsonicResponse>
@Query("comment") comment: String? = null
): Call<SubsonicResponse>
@GET("deleteBookmark.view")
fun deleteBookmark(@Query("id") id: String): Call<SubsonicResponse>

View File

@ -56,8 +56,10 @@ enum class SubsonicAPIVersions(val subsonicVersions: String, val restApiVersion:
}
class SubsonicAPIVersionsDeserializer : JsonDeserializer<SubsonicAPIVersions>() {
override fun deserialize(p: JsonParser,
ctxt: DeserializationContext?): SubsonicAPIVersions {
override fun deserialize(
p: JsonParser,
ctxt: DeserializationContext?
): SubsonicAPIVersions {
if (p.currentName != "version") {
throw JsonParseException(p, "Not valid token for API version!")
}

View File

@ -21,7 +21,8 @@ private const val DEFAULT_PEEK_BYTE_COUNT = 1000L
*/
internal class VersionInterceptor(
internal var protocolVersion: SubsonicAPIVersions,
private val notifier: (SubsonicAPIVersions) -> Unit = {}) : Interceptor {
private val notifier: (SubsonicAPIVersions) -> Unit = {}
) : Interceptor {
private val jsonFactory = JsonFactory()
override fun intercept(chain: Chain): okhttp3.Response {

View File

@ -14,4 +14,5 @@ data class Album(
val created: Calendar? = null,
val year: Int = 0,
val genre: String = "",
@JsonProperty("song") val songList: List<MusicDirectoryChild> = emptyList())
@JsonProperty("song") val songList: List<MusicDirectoryChild> = emptyList()
)

View File

@ -3,10 +3,12 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
import java.util.Calendar
data class Artist(val id: String = "",
data class Artist(
val id: String = "",
val name: String = "",
val coverArt: String = "",
val albumCount: Int = 0,
val starred: Calendar? = null,
@JsonProperty("album")
val albumsList: List<Album> = emptyList())
val albumsList: List<Album> = emptyList()
)

View File

@ -8,4 +8,5 @@ data class Bookmark(
val comment: String = "",
val created: Calendar? = null,
val changed: Calendar? = null,
val entry: MusicDirectoryChild = MusicDirectoryChild())
val entry: MusicDirectoryChild = MusicDirectoryChild()
)

View File

@ -3,4 +3,5 @@ package org.moire.ultrasonic.api.subsonic.models
data class ChatMessage(
val username: String = "",
val time: Long = 0,
val message: String = "")
val message: String = ""
)

View File

@ -2,6 +2,8 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
data class Genre(val songCount: Int = 0,
data class Genre(
val songCount: Int = 0,
val albumCount: Int = 0,
@JsonProperty("value") val name: String)
@JsonProperty("value") val name: String
)

View File

@ -2,6 +2,8 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
data class Index(val name: String = "",
data class Index(
val name: String = "",
@JsonProperty("artist")
val artists: List<Artist> = emptyList())
val artists: List<Artist> = emptyList()
)

View File

@ -2,9 +2,11 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
data class Indexes(val lastModified: Long = 0,
data class Indexes(
val lastModified: Long = 0,
val ignoredArticles: String = "",
@JsonProperty("index")
val indexList: List<Index> = emptyList(),
@JsonProperty("shortcut")
val shortcutList: List<Artist> = emptyList())
val shortcutList: List<Artist> = emptyList()
)

View File

@ -7,4 +7,5 @@ data class JukeboxStatus(
val playing: Boolean = false,
val gain: Float = 0.0f,
val position: Int = 0,
@JsonProperty("entry") val playlistEntries: List<MusicDirectoryChild> = emptyList())
@JsonProperty("entry") val playlistEntries: List<MusicDirectoryChild> = emptyList()
)

View File

@ -6,4 +6,5 @@ data class License(
val valid: Boolean = false,
val email: String = "",
val trialExpires: Calendar = Calendar.getInstance(),
val licenseExpires: Calendar = Calendar.getInstance())
val licenseExpires: Calendar = Calendar.getInstance()
)

View File

@ -5,4 +5,5 @@ import com.fasterxml.jackson.annotation.JsonProperty
data class Lyrics(
val artist: String = "",
val title: String = "",
@JsonProperty("value") val text: String = "")
@JsonProperty("value") val text: String = ""
)

View File

@ -3,7 +3,8 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
import java.util.Calendar
data class MusicDirectory(val id: String = "",
data class MusicDirectory(
val id: String = "",
val parent: String = "",
val name: String = "",
val userRating: Int = 0,
@ -11,4 +12,5 @@ data class MusicDirectory(val id: String = "",
val starred: Calendar? = null,
val playCount: Int = 0,
@JsonProperty("child")
val childList: List<MusicDirectoryChild> = emptyList())
val childList: List<MusicDirectoryChild> = emptyList()
)

View File

@ -2,7 +2,8 @@ package org.moire.ultrasonic.api.subsonic.models
import java.util.Calendar
data class MusicDirectoryChild(val id: String = "",
data class MusicDirectoryChild(
val id: String = "",
val parent: String = "",
val isDir: Boolean = false,
val title: String = "",
@ -34,4 +35,5 @@ data class MusicDirectoryChild(val id: String = "",
val status: String = "",
val publishDate: Calendar? = null,
val userRating: Int? = null,
val averageRating: Float? = null)
val averageRating: Float? = null
)

View File

@ -11,4 +11,5 @@ data class PodcastChannel(
val originalImageUrl: String = "",
val status: String = "",
val errorMessage: String = "",
@JsonProperty("episode") val episodeList: List<MusicDirectoryChild> = emptyList())
@JsonProperty("episode") val episodeList: List<MusicDirectoryChild> = emptyList()
)

View File

@ -5,4 +5,5 @@ import com.fasterxml.jackson.annotation.JsonProperty
data class SearchResult(
val offset: Int = 0,
val totalHits: Int = 0,
@JsonProperty("match") val matchList: List<MusicDirectoryChild> = emptyList())
@JsonProperty("match") val matchList: List<MusicDirectoryChild> = emptyList()
)

View File

@ -12,4 +12,5 @@ data class Share(
val visitCount: Int = 0,
val description: String = "",
val lastVisited: Calendar? = null,
@JsonProperty("entry") val items: List<MusicDirectoryChild> = emptyList())
@JsonProperty("entry") val items: List<MusicDirectoryChild> = emptyList()
)

View File

@ -18,4 +18,5 @@ data class User(
val jukeboxRole: Boolean = false,
val shareRole: Boolean = false,
val videoConverstionRole: Boolean = false,
@JsonProperty("folder") val folderList: List<Int> = emptyList())
@JsonProperty("folder") val folderList: List<Int> = emptyList()
)

View File

@ -8,11 +8,13 @@ import org.moire.ultrasonic.api.subsonic.models.Bookmark
class BookmarksResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?) : SubsonicResponse(status, version, error) {
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())
@JsonProperty("bookmark") val bookmarkList: List<Bookmark> = emptyList()
)

View File

@ -8,11 +8,13 @@ import org.moire.ultrasonic.api.subsonic.models.ChatMessage
class ChatMessagesResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?) : SubsonicResponse(status, version, error) {
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("chatMessages") private val wrapper = ChatMessagesWrapper()
val chatMessages: List<ChatMessage> get() = wrapper.messagesList
}
internal class ChatMessagesWrapper(
@JsonProperty("chatMessage") val messagesList: List<ChatMessage> = emptyList())
@JsonProperty("chatMessage") val messagesList: List<ChatMessage> = emptyList()
)

View File

@ -5,9 +5,11 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.Genre
class GenresResponse(status: Status,
class GenresResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?) : SubsonicResponse(status, version, error) {
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("genres") private val genresWrapper = GenresWrapper()
val genresList: List<Genre> get() = genresWrapper.genresList
}

View File

@ -6,10 +6,11 @@ import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.Album
@Suppress("NamingConventionViolation")
class GetAlbumList2Response(status: Status,
class GetAlbumList2Response(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?)
: SubsonicResponse(status, version, error) {
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("albumList2") private val albumWrapper2 = AlbumWrapper2()
val albumList: List<Album>
@ -18,4 +19,5 @@ class GetAlbumList2Response(status: Status,
@Suppress("NamingConventionViolation")
private class AlbumWrapper2(
@JsonProperty("album") val albumList: List<Album> = emptyList())
@JsonProperty("album") val albumList: List<Album> = emptyList()
)

View File

@ -5,10 +5,11 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.MusicDirectoryChild
class GetAlbumListResponse(status: Status,
class GetAlbumListResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?)
: SubsonicResponse(status, version, error) {
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("albumList") private val albumWrapper = AlbumWrapper()
val albumList: List<MusicDirectoryChild>
@ -16,4 +17,5 @@ class GetAlbumListResponse(status: Status,
}
private class AlbumWrapper(
@JsonProperty("album") val albumList: List<MusicDirectoryChild> = emptyList())
@JsonProperty("album") val albumList: List<MusicDirectoryChild> = emptyList()
)

View File

@ -4,7 +4,9 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.Album
class GetAlbumResponse(status: Status,
class GetAlbumResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val album: Album = Album()) : SubsonicResponse(status, version, error)
val album: Album = Album()
) : SubsonicResponse(status, version, error)

View File

@ -4,8 +4,9 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.Artist
class GetArtistResponse(status: Status,
class GetArtistResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val artist: Artist = Artist())
: SubsonicResponse(status, version, error)
val artist: Artist = Artist()
) : SubsonicResponse(status, version, error)

View File

@ -5,8 +5,9 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.Indexes
class GetArtistsResponse(status: Status,
class GetArtistsResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
@JsonProperty("artists") val indexes: Indexes = Indexes()) :
SubsonicResponse(status, version, error)
@JsonProperty("artists") val indexes: Indexes = Indexes()
) : SubsonicResponse(status, version, error)

View File

@ -4,8 +4,9 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.Indexes
class GetIndexesResponse(status: Status,
class GetIndexesResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val indexes: Indexes = Indexes()) :
SubsonicResponse(status, version, error)
val indexes: Indexes = Indexes()
) : SubsonicResponse(status, version, error)

View File

@ -4,8 +4,9 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.Lyrics
class GetLyricsResponse(status: Status,
class GetLyricsResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val lyrics: Lyrics = Lyrics())
: SubsonicResponse(status, version, error)
val lyrics: Lyrics = Lyrics()
) : SubsonicResponse(status, version, error)

View File

@ -5,9 +5,10 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.MusicDirectory
class GetMusicDirectoryResponse(status: Status,
class GetMusicDirectoryResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
@JsonProperty("directory")
val musicDirectory: MusicDirectory = MusicDirectory()) :
SubsonicResponse(status, version, error)
val musicDirectory: MusicDirectory = MusicDirectory()
) : SubsonicResponse(status, version, error)

View File

@ -8,4 +8,5 @@ class GetPlaylistResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val playlist: Playlist = Playlist()) : SubsonicResponse(status, version, error)
val playlist: Playlist = Playlist()
) : SubsonicResponse(status, version, error)

View File

@ -5,10 +5,11 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.Playlist
class GetPlaylistsResponse(status: Status,
class GetPlaylistsResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?)
: SubsonicResponse(status, version, error) {
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("playlists")
private val playlistsWrapper: PlaylistsWrapper = PlaylistsWrapper()
@ -17,4 +18,5 @@ class GetPlaylistsResponse(status: Status,
}
private class PlaylistsWrapper(
@JsonProperty("playlist") val playlistList: List<Playlist> = emptyList())
@JsonProperty("playlist") val playlistList: List<Playlist> = emptyList()
)

View File

@ -8,7 +8,8 @@ import org.moire.ultrasonic.api.subsonic.models.PodcastChannel
class GetPodcastsResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?) : SubsonicResponse(status, version, error) {
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("podcasts") private val channelsWrapper = PodcastChannelWrapper()
val podcastChannels: List<PodcastChannel>
@ -16,4 +17,5 @@ class GetPodcastsResponse(
}
private class PodcastChannelWrapper(
@JsonProperty("channel") val channelsList: List<PodcastChannel> = emptyList())
@JsonProperty("channel") val channelsList: List<PodcastChannel> = emptyList()
)

View File

@ -5,10 +5,11 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.MusicDirectoryChild
class GetRandomSongsResponse(status: Status,
class GetRandomSongsResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?)
: SubsonicResponse(status, version, error) {
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("randomSongs") private val songsWrapper = RandomSongsWrapper()
val songsList
@ -16,4 +17,5 @@ class GetRandomSongsResponse(status: Status,
}
private class RandomSongsWrapper(
@JsonProperty("song") val songsList: List<MusicDirectoryChild> = emptyList())
@JsonProperty("song") val songsList: List<MusicDirectoryChild> = emptyList()
)

View File

@ -8,11 +8,13 @@ import org.moire.ultrasonic.api.subsonic.models.MusicDirectoryChild
class GetSongsByGenreResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?) : SubsonicResponse(status, version, error) {
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("songsByGenre") private val songsByGenreList = SongsByGenreWrapper()
val songsList get() = songsByGenreList.songsList
}
internal class SongsByGenreWrapper(
@JsonProperty("song") val songsList: List<MusicDirectoryChild> = emptyList())
@JsonProperty("song") val songsList: List<MusicDirectoryChild> = emptyList()
)

View File

@ -4,8 +4,9 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.SearchTwoResult
class GetStarredResponse(status: Status,
class GetStarredResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val starred: SearchTwoResult = SearchTwoResult())
: SubsonicResponse(status, version, error)
val starred: SearchTwoResult = SearchTwoResult()
) : SubsonicResponse(status, version, error)

View File

@ -4,8 +4,9 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.SearchTwoResult
class GetStarredTwoResponse(status: Status,
class GetStarredTwoResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val starred2: SearchTwoResult = SearchTwoResult())
: SubsonicResponse(status, version, error)
val starred2: SearchTwoResult = SearchTwoResult()
) : SubsonicResponse(status, version, error)

View File

@ -8,4 +8,5 @@ class GetUserResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val user: User = User()) : SubsonicResponse(status, version, error)
val user: User = User()
) : SubsonicResponse(status, version, error)

View File

@ -5,11 +5,12 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.JukeboxStatus
class JukeboxResponse(status: Status,
class JukeboxResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
var jukebox: JukeboxStatus = JukeboxStatus())
: SubsonicResponse(status, version, error) {
var jukebox: JukeboxStatus = JukeboxStatus()
) : SubsonicResponse(status, version, error) {
@JsonSetter("jukeboxStatus") fun setJukeboxStatus(jukebox: JukeboxStatus) {
this.jukebox = jukebox
}

View File

@ -4,8 +4,9 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.License
class LicenseResponse(val license: License = License(),
class LicenseResponse(
val license: License = License(),
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?) :
SubsonicResponse(status, version, error)
error: SubsonicError?
) : SubsonicResponse(status, version, error)

View File

@ -5,14 +5,16 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.MusicFolder
class MusicFoldersResponse(status: Status,
class MusicFoldersResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?) :
SubsonicResponse(status, version, error) {
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("musicFolders") private val wrapper = MusicFoldersWrapper()
val musicFolders get() = wrapper.musicFolders
}
internal class MusicFoldersWrapper(
@JsonProperty("musicFolder") val musicFolders: List<MusicFolder> = emptyList())
@JsonProperty("musicFolder") val musicFolders: List<MusicFolder> = emptyList()
)

View File

@ -4,8 +4,9 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.SearchResult
class SearchResponse(status: Status,
class SearchResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val searchResult: SearchResult = SearchResult())
: SubsonicResponse(status, version, error)
val searchResult: SearchResult = SearchResult()
) : SubsonicResponse(status, version, error)

View File

@ -9,5 +9,5 @@ class SearchThreeResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
@JsonProperty("searchResult3") val searchResult: SearchThreeResult = SearchThreeResult())
: SubsonicResponse(status, version, error)
@JsonProperty("searchResult3") val searchResult: SearchThreeResult = SearchThreeResult()
) : SubsonicResponse(status, version, error)

View File

@ -9,5 +9,5 @@ class SearchTwoResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
@JsonProperty("searchResult2") val searchResult: SearchTwoResult = SearchTwoResult())
: SubsonicResponse(status, version, error)
@JsonProperty("searchResult2") val searchResult: SearchTwoResult = SearchTwoResult()
) : SubsonicResponse(status, version, error)

View File

@ -5,10 +5,11 @@ 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,
class SharesResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?)
: SubsonicResponse(status, version, error) {
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("shares") private val wrappedShares = SharesWrapper()
val shares get() = wrappedShares.share

View File

@ -9,9 +9,11 @@ import java.io.InputStream
*
* [responseHttpCode] will be there always.
*/
class StreamResponse(val stream: InputStream? = null,
class StreamResponse(
val stream: InputStream? = null,
val apiError: SubsonicError? = null,
val responseHttpCode: Int) {
val responseHttpCode: Int
) {
/**
* Check if this response has error.
*/

View File

@ -13,9 +13,11 @@ import org.moire.ultrasonic.api.subsonic.SubsonicError
* Base Subsonic API response.
*/
@JsonRootName(value = "subsonic-response")
open class SubsonicResponse(val status: Status,
open class SubsonicResponse(
val status: Status,
val version: SubsonicAPIVersions,
val error: SubsonicError?) {
val error: SubsonicError?
) {
@JsonDeserialize(using = Status.Companion.StatusJsonDeserializer::class)
enum class Status(val jsonValue: String) {
OK("ok"), ERROR("failed");

View File

@ -8,11 +8,13 @@ import org.moire.ultrasonic.api.subsonic.models.MusicDirectoryChild
class VideosResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?) : SubsonicResponse(status, version, error) {
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("videos") private val videosWrapper = VideosWrapper()
val videosList: List<MusicDirectoryChild> get() = videosWrapper.videosList
}
internal class VideosWrapper(
@JsonProperty("video") val videosList: List<MusicDirectoryChild> = emptyList())
@JsonProperty("video") val videosList: List<MusicDirectoryChild> = emptyList()
)