feat(characters:domain): models + CharacterRepository interface (REDI-85)
- Character, CharacterStatus, CharactersPage(characters, nextPage), CharacterDetails. - CharacterRepository interface returning Result<CharactersPage, DataError> and Result<CharacterDetails, DataError>. Pure Kotlin, no serialization annotations, no Android.
This commit is contained in:
@@ -0,0 +1,17 @@
|
|||||||
|
package com.example.architecture.feature.characters.domain
|
||||||
|
|
||||||
|
import com.example.architecture.core.domain.DataError
|
||||||
|
import com.example.architecture.core.domain.Result
|
||||||
|
import com.example.architecture.feature.characters.domain.model.CharacterDetails
|
||||||
|
import com.example.architecture.feature.characters.domain.model.CharactersPage
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contract for the characters data layer. Lives in domain so presentation never depends on data.
|
||||||
|
* Returns the [DataError] supertype because an implementation may merge sources (e.g. an
|
||||||
|
* offline-first repository combining network + local).
|
||||||
|
*/
|
||||||
|
interface CharacterRepository {
|
||||||
|
suspend fun getCharacters(page: Int): Result<CharactersPage, DataError>
|
||||||
|
|
||||||
|
suspend fun getCharacterDetails(id: Int): Result<CharacterDetails, DataError>
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.example.architecture.feature.characters.domain.model
|
||||||
|
|
||||||
|
/** A character as shown in the list. */
|
||||||
|
data class Character(
|
||||||
|
val id: Int,
|
||||||
|
val name: String,
|
||||||
|
val status: CharacterStatus,
|
||||||
|
val species: String,
|
||||||
|
val imageUrl: String,
|
||||||
|
)
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.example.architecture.feature.characters.domain.model
|
||||||
|
|
||||||
|
/** Full character profile shown on the detail screen. */
|
||||||
|
data class CharacterDetails(
|
||||||
|
val id: Int,
|
||||||
|
val name: String,
|
||||||
|
val status: CharacterStatus,
|
||||||
|
val species: String,
|
||||||
|
val type: String,
|
||||||
|
val gender: String,
|
||||||
|
val origin: String,
|
||||||
|
val location: String,
|
||||||
|
val imageUrl: String,
|
||||||
|
val episodeCount: Int,
|
||||||
|
)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.example.architecture.feature.characters.domain.model
|
||||||
|
|
||||||
|
/** Life status of a character. Mapped from the API's string in the data layer. */
|
||||||
|
enum class CharacterStatus {
|
||||||
|
ALIVE,
|
||||||
|
DEAD,
|
||||||
|
UNKNOWN,
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.example.architecture.feature.characters.domain.model
|
||||||
|
|
||||||
|
/** One page of characters plus the next page index ([nextPage] is null when there are no more). */
|
||||||
|
data class CharactersPage(
|
||||||
|
val characters: List<Character>,
|
||||||
|
val nextPage: Int?,
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user