Skip to content

Commit 6f0f128

Browse files
fix(deps): update retrofit monorepo to v3 (major) (#273)
* fix(deps): update retrofit monorepo to v3 * refactor: use `toRequestBody` & `toMediaTypeOrNull` extension functions This commit updates the `GraphRequestConverter.kt` file to utilize the Kotlin extension functions `toRequestBody` and `toMediaTypeOrNull` for creating OkHttp `RequestBody` and `MediaType` objects respectively. This change simplifies the code and aligns with modern Kotlin practices. --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Maxwell <mxt.developer@gmail.com>
1 parent b464c84 commit 6f0f128

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jetbrains-kotlinx-serialization = "1.8.1"
3838
koin-core = "4.0.4"
3939
koin-android = "4.0.4"
4040

41-
square-retrofit = "2.12.0"
41+
square-retrofit = "3.0.0"
4242
square-okhttp = "4.12.0"
4343

4444
[plugins]

library/src/main/kotlin/io/github/wax911/library/converter/request/GraphRequestConverter.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ import com.google.gson.Gson
2020
import io.github.wax911.library.annotation.processor.contract.AbstractGraphProcessor
2121
import io.github.wax911.library.model.request.QueryContainerBuilder
2222
import okhttp3.MediaType
23+
import okhttp3.MediaType.Companion.toMediaTypeOrNull
2324
import okhttp3.RequestBody
25+
import okhttp3.RequestBody.Companion.toRequestBody
2426
import retrofit2.Converter
2527

2628
/**
@@ -43,10 +45,10 @@ open class GraphRequestConverter(
4345
containerBuilder.setQuery(rawQuery)
4446
.build()
4547
val queryJson = gson.toJson(queryContainer)
46-
return RequestBody.create(MEDIA_TYPE, queryJson)
48+
return queryJson.toRequestBody(MEDIA_TYPE)
4749
}
4850

4951
companion object {
50-
private val MEDIA_TYPE = MediaType.parse("application/json")
52+
private val MEDIA_TYPE = "application/json".toMediaTypeOrNull()
5153
}
5254
}

0 commit comments

Comments
 (0)