From 02cbdedd3b8e0e90872b93efa8c883aa65dfb279 Mon Sep 17 00:00:00 2001 From: youjin09222 Date: Fri, 3 May 2024 17:22:01 +0900 Subject: [PATCH] =?UTF-8?q?feat/#9:=20ApiFactory=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/sopt/now/test/data/ApiFactory.kt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 app/src/main/java/com/sopt/now/test/data/ApiFactory.kt diff --git a/app/src/main/java/com/sopt/now/test/data/ApiFactory.kt b/app/src/main/java/com/sopt/now/test/data/ApiFactory.kt new file mode 100644 index 0000000..ef33f15 --- /dev/null +++ b/app/src/main/java/com/sopt/now/test/data/ApiFactory.kt @@ -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 create(): T = retrofit.create(T::class.java) +} + +object ServicePool { + val authService = ApiFactory.create() +} \ No newline at end of file