Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/foso/ksp1.0.26' into foso/ksp1.0.26
Browse files Browse the repository at this point in the history
  • Loading branch information
Foso committed Nov 5, 2024
2 parents 9823636 + fd7be88 commit d1e7917
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 20 deletions.
2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ See https://foso.github.io/Ktorfit/generation/#nodelegation

OptIn annotations on interfaces and functions will now be propagated to the generated classes.

- Fixed documentation for converters to match the current version.

# [2.1.0]()

* Supported Kotlin version: 2.0.0; 2.0.10; 2.0.20, 2.1.0-Beta1; 2.0.21-RC, 2.0.21
Expand Down
12 changes: 6 additions & 6 deletions docs/converters/example1.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,32 +72,32 @@ Next we create the SuspendResponseConverter:
```kotlin
if (typeData.typeInfo.type == User::class) {
return object : Converter.SuspendResponseConverter<HttpResponse, Any> {
override suspend fun convert(response: HttpResponse): Any {
override suspend fun convert(result: KtorfitResult): Any {
...
}
}
}

```
Inside of **convert** we get the HttpResponse and we want to return a User object.
Inside of **convert** we get the KtorfitResult and we want to return a User object.

Now we could do the following:

When we know that this converter will always be used for a API that wraps the User inside an Envelope class, we can directly transform the body to an envelope object and just return the user object.

```kotlin
override suspend fun convert(response: HttpResponse): Any {
val envelope = response.body<Envelope>()
override suspend fun convert(result: KtorfitResult): Any {
val envelope = result.response.body<Envelope>()
return envelope.user
}
```

or we can create a TypeData of Envelope and use **nextSuspendResponseConverter()** to look up the next converter that can convert the response

```kotlin
override suspend fun convert(response: HttpResponse): Any {
override suspend fun convert(result: KtorfitResult): Any {
val typeData = TypeData.createTypeData("com.example.model.Envelope", typeInfo<Envelope>())
val envelope = ktorfit.nextSuspendResponseConverter(null, typeData)?.convert(response) as? Envelope
val envelope = ktorfit.nextSuspendResponseConverter(null, typeData)?.convert(result) as? Envelope
return envelope.user
}
```
Expand Down
8 changes: 4 additions & 4 deletions example/AndroidOnlyExample/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach

val ktorfit = "2.0.0"
val ktor = "2.3.11"
val compose_ui_version = "1.7.3"
val compose_ui_version = "1.7.4"
dependencies {
implementation("de.jensklingenberg.ktorfit:ktorfit-lib:$ktorfit")
implementation("io.ktor:ktor-client-serialization:$ktor")
Expand All @@ -65,11 +65,11 @@ dependencies {
implementation("de.jensklingenberg.ktorfit:ktorfit-converters-flow:$ktorfit")


implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.4")
implementation("androidx.activity:activity-compose:1.9.2")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.6")
implementation("androidx.activity:activity-compose:1.9.3")
implementation("androidx.compose.ui:ui:$compose_ui_version")
implementation("androidx.compose.ui:ui-tooling-preview:$compose_ui_version")
implementation("androidx.compose.material:material:1.6.7")
implementation("androidx.compose.material:material:1.7.4")
debugImplementation("androidx.compose.ui:ui-tooling:$compose_ui_version")
debugImplementation("androidx.compose.ui:ui-test-manifest:$compose_ui_version")
testImplementation("junit:junit:4.13.2")
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ktor-client-serialization = { module = "io.ktor:ktor-client-serialization", vers
ktor-serialization-gson = { module = "io.ktor:ktor-serialization-gson", version.ref = "ktorVersion" }
ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktorVersion" }

licensee-gradle-plugin = "app.cash.licensee:licensee-gradle-plugin:1.11.0"
licensee-gradle-plugin = "app.cash.licensee:licensee-gradle-plugin:1.12.0"
logbackClassic = "ch.qos.logback:logback-classic:1.5.6"
mockito-kotlin = { module = "org.mockito.kotlin:mockito-kotlin", version.ref = "mockito-kotlin" }
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
Expand Down
21 changes: 12 additions & 9 deletions renovate.json5
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"extends": ["config:base"],
"schedule": [
"every weekend"
extends: [
'config:best-practices',
],
"packageRules": [
schedule: [
'every weekend',
],
packageRules: [
{
"groupName": "Ktor Client",
"matchPackagePatterns": ["^io\\.ktor:ktor-client(-[^:]+)?$"],

}
]
groupName: 'Ktor Client',
matchPackageNames: [
'/^io\\.ktor:ktor-client(-[^:]+)?$/',
],
},
],
}

0 comments on commit d1e7917

Please sign in to comment.