mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-18 10:17:02 +05:30
Replace Moshi with kotlinx.serialization
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
43295a58eb
commit
84f45f523a
10 changed files with 40 additions and 52 deletions
|
@ -1,18 +1,14 @@
|
|||
plugins {
|
||||
id("com.android.library")
|
||||
kotlin("android")
|
||||
kotlin("kapt")
|
||||
kotlin("plugin.serialization") version "1.4.10"
|
||||
`lobsters-plugin`
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":model"))
|
||||
implementation(Dependencies.ThirdParty.Retrofit.lib)
|
||||
implementation(Dependencies.ThirdParty.Retrofit.moshi)
|
||||
implementation(Dependencies.Kotlin.Serialization.json)
|
||||
implementation(Dependencies.ThirdParty.retrofitSerialization)
|
||||
kaptTest(Dependencies.ThirdParty.Moshi.codegen)
|
||||
testImplementation(Dependencies.Testing.junit)
|
||||
testImplementation(Dependencies.Kotlin.Coroutines.core)
|
||||
testImplementation(Dependencies.Testing.mockWebServer)
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
package dev.msfjarvis.lobsters.api
|
||||
|
||||
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.MediaType
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.converter.moshi.MoshiConverterFactory
|
||||
|
||||
object ApiClient {
|
||||
inline fun <reified T> getClient(baseUrl: String): T {
|
||||
return Retrofit.Builder()
|
||||
.baseUrl(baseUrl)
|
||||
.addConverterFactory(MoshiConverterFactory.create())
|
||||
.addConverterFactory(Json.asConverterFactory(MediaType.get("application/json")))
|
||||
.build()
|
||||
.create(T::class.java)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue