Skip to content

Commit

Permalink
feat/#9: ApiFactory 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
youjin09222 committed May 3, 2024
1 parent 905ac81 commit 02cbded
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/src/main/java/com/sopt/now/test/data/ApiFactory.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.sopt.now.test.data

import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import com.sopt.now.BuildConfig
import kotlinx.serialization.json.Json
import okhttp3.MediaType.Companion.toMediaType
import retrofit2.Retrofit

object ApiFactory {
private const val BASE_URL: String = BuildConfig.AUTH_BASE_URL

val retrofit: Retrofit by lazy {
Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType()))
.build()
}

inline fun <reified T> create(): T = retrofit.create(T::class.java)
}

object ServicePool {
val authService = ApiFactory.create<AuthService>()
}

0 comments on commit 02cbded

Please sign in to comment.