2022-07-04 17:31:58 +02:00
|
|
|
/*
|
|
|
|
* APIBookmarkConverter.kt
|
|
|
|
* Copyright (C) 2009-2022 Ultrasonic developers
|
|
|
|
*
|
|
|
|
* Distributed under terms of the GNU GPLv3 license.
|
|
|
|
*/
|
|
|
|
|
2017-11-18 21:34:03 +01:00
|
|
|
// Contains helper functions to convert api Bookmark entity to domain entity
|
|
|
|
@file:JvmName("APIBookmarkConverter")
|
2022-07-04 17:31:58 +02:00
|
|
|
|
2018-02-17 20:36:19 +01:00
|
|
|
package org.moire.ultrasonic.domain
|
2017-11-18 21:34:03 +01:00
|
|
|
|
|
|
|
import org.moire.ultrasonic.api.subsonic.models.Bookmark as ApiBookmark
|
|
|
|
|
2022-07-04 17:31:58 +02:00
|
|
|
fun ApiBookmark.toDomainEntity(serverId: Int): Bookmark = Bookmark(
|
2018-02-22 22:23:48 +01:00
|
|
|
position = this@toDomainEntity.position.toInt(),
|
|
|
|
username = this@toDomainEntity.username,
|
|
|
|
comment = this@toDomainEntity.comment,
|
|
|
|
created = this@toDomainEntity.created?.time,
|
|
|
|
changed = this@toDomainEntity.changed?.time,
|
2022-07-04 17:31:58 +02:00
|
|
|
track = this@toDomainEntity.entry.toTrackEntity(serverId)
|
2018-02-22 22:23:48 +01:00
|
|
|
)
|
2017-11-18 21:34:03 +01:00
|
|
|
|
2022-07-04 17:31:58 +02:00
|
|
|
fun List<ApiBookmark>.toDomainEntitiesList(serverId: Int): List<Bookmark> =
|
|
|
|
map { it.toDomainEntity(serverId) }
|