- @Serializable CharacterDto/CharactersResponseDto/PageInfoDto in dto/.
- mappers/CharacterMapper.kt: internal, pure toDomain()/toCharacter()/toCharacterDetails();
nextPage parsed from info.next URL. No mapping inside DTO/data-source classes.
- KtorCharacterDataSource via the typed HttpClient.get helpers (errors -> DataError.Network).
- NetworkCharacterRepository (not *Impl) maps DTO -> domain; DataError.Network widens to DataError.
- charactersDataModule: singleOf(::KtorCharacterDataSource) + singleOf(::NetworkCharacterRepository) { bind<CharacterRepository>() }.
- core:data: expose ktor-client-core as api (public inline helpers are inlined into consumers) and
move Timber logging into a @PublishedApi internal fn so Timber doesn't leak across modules.
26 lines
784 B
Kotlin
26 lines
784 B
Kotlin
plugins {
|
|
alias(libs.plugins.architecture.android.library)
|
|
alias(libs.plugins.architecture.ktor)
|
|
alias(libs.plugins.architecture.koin)
|
|
}
|
|
|
|
android {
|
|
namespace = "com.example.architecture.core.data"
|
|
|
|
buildFeatures {
|
|
buildConfig = true
|
|
}
|
|
defaultConfig {
|
|
// The no-key Rick & Morty API. constructRoute() reads this BuildConfig field.
|
|
buildConfigField("String", "BASE_URL", "\"https://rickandmortyapi.com/api\"")
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation(project(":core:domain"))
|
|
implementation(libs.timber)
|
|
// `api`: the public inline HttpClient.get/post/delete helpers are inlined into consumer modules,
|
|
// so those modules need the Ktor request/response types on their compile classpath.
|
|
api(libs.ktor.client.core)
|
|
}
|