feat(data): add Retrofit API, DTOs and mappers
This commit is contained in:
32
app/src/main/java/com/radiola/data/remote/ApiMapper.kt
Normal file
32
app/src/main/java/com/radiola/data/remote/ApiMapper.kt
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.radiola.data.remote
|
||||
|
||||
import com.radiola.data.remote.dto.NowPlayingItemDto
|
||||
import com.radiola.data.remote.dto.StationDto
|
||||
import com.radiola.domain.model.Station
|
||||
import com.radiola.domain.model.Track
|
||||
|
||||
object ApiMapper {
|
||||
|
||||
fun StationDto.toDomain(): Station {
|
||||
val cover = iconPng ?: iconSvg ?: ""
|
||||
return Station(
|
||||
id = id,
|
||||
name = name,
|
||||
prefix = prefix,
|
||||
streamUrl = "https://air.radiorecord.ru:805/${prefix}_128",
|
||||
coverUrl = cover,
|
||||
genre = genre ?: "",
|
||||
tags = emptyList(),
|
||||
sortOrder = id
|
||||
)
|
||||
}
|
||||
|
||||
fun NowPlayingItemDto.toDomain(): Track {
|
||||
return Track(
|
||||
artist = artist,
|
||||
song = song,
|
||||
coverUrl = image600 ?: image100,
|
||||
stationName = prefix
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user