2017-09-02 19:40:32 +02:00
|
|
|
// Converts Artist entity from [org.moire.ultrasonic.api.subsonic.SubsonicAPIClient]
|
|
|
|
// to app domain entities.
|
|
|
|
@file:JvmName("APIArtistConverter")
|
2018-02-17 20:36:19 +01:00
|
|
|
package org.moire.ultrasonic.domain
|
2017-09-02 19:40:32 +02:00
|
|
|
|
|
|
|
import org.moire.ultrasonic.api.subsonic.models.Artist as APIArtist
|
|
|
|
|
2021-06-20 16:31:08 +02:00
|
|
|
// When we like to convert to an Artist
|
2018-02-22 22:30:39 +01:00
|
|
|
fun APIArtist.toDomainEntity(): Artist = Artist(
|
|
|
|
id = this@toDomainEntity.id,
|
2020-11-18 21:46:46 +01:00
|
|
|
coverArt = this@toDomainEntity.coverArt,
|
2017-09-02 19:40:32 +02:00
|
|
|
name = this@toDomainEntity.name
|
2018-02-22 22:30:39 +01:00
|
|
|
)
|
2017-09-02 19:40:32 +02:00
|
|
|
|
2021-06-20 16:31:08 +02:00
|
|
|
// When we like to convert to an index (eg. a single directory).
|
|
|
|
fun APIArtist.toIndexEntity(): Index = Index(
|
|
|
|
id = this@toIndexEntity.id,
|
|
|
|
coverArt = this@toIndexEntity.coverArt,
|
|
|
|
name = this@toIndexEntity.name
|
|
|
|
)
|
|
|
|
|
2017-09-02 19:40:32 +02:00
|
|
|
fun APIArtist.toMusicDirectoryDomainEntity(): MusicDirectory = MusicDirectory().apply {
|
|
|
|
name = this@toMusicDirectoryDomainEntity.name
|
|
|
|
addAll(this@toMusicDirectoryDomainEntity.albumsList.map { it.toDomainEntity() })
|
|
|
|
}
|
2021-11-26 17:03:33 +01:00
|
|
|
|
|
|
|
fun APIArtist.toDomainEntityList(): List<MusicDirectory.Album> {
|
|
|
|
return this.albumsList.map { it.toDomainEntity() }
|
|
|
|
}
|