diff --git a/app/build.gradle b/app/build.gradle index f7c1b6a..048b28b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -70,4 +70,6 @@ dependencies { // define any required OkHttp artifacts without version implementation("com.squareup.okhttp3:okhttp") implementation("com.squareup.okhttp3:logging-interceptor") + + } \ No newline at end of file diff --git a/app/src/main/java/org/android/go/sopt/module/AuthApiFactory.kt b/app/src/main/java/org/android/go/sopt/module/AuthApiFactory.kt index ee733ae..f4853fb 100644 --- a/app/src/main/java/org/android/go/sopt/module/AuthApiFactory.kt +++ b/app/src/main/java/org/android/go/sopt/module/AuthApiFactory.kt @@ -4,6 +4,8 @@ import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFact import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.json.Json import okhttp3.MediaType.Companion.toMediaType +import okhttp3.OkHttpClient +import okhttp3.logging.HttpLoggingInterceptor import org.android.go.sopt.BuildConfig import org.android.go.sopt.data.service.AuthService import retrofit2.Retrofit @@ -11,11 +13,19 @@ import retrofit2.Retrofit object AuthApiFactory { private const val BASE_URL = BuildConfig.AUTH_BASE_URL + private val client by lazy { + OkHttpClient.Builder().addInterceptor(HttpLoggingInterceptor().apply { + level = + if (BuildConfig.DEBUG) HttpLoggingInterceptor.Level.BODY else HttpLoggingInterceptor.Level.NONE + }).build() + } + @OptIn(ExperimentalSerializationApi::class) val retrofit: Retrofit by lazy { Retrofit.Builder() .baseUrl(BASE_URL) .addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) + .client(client) .build() } diff --git a/app/src/main/java/org/android/go/sopt/presentation/auth/LoginViewModel.kt b/app/src/main/java/org/android/go/sopt/presentation/auth/LoginViewModel.kt index 9c9ce78..841b542 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/auth/LoginViewModel.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/auth/LoginViewModel.kt @@ -18,8 +18,6 @@ class LoginViewModel : ViewModel() { private val _errorResult: MutableLiveData = MutableLiveData() val errorResult: LiveData = _errorResult - private lateinit var binding: ActivityLoginBinding - fun login(id: String, password: String) { authService.login( LoginRequestDTO(