From 823a1c84d62efabf0c18c5f047184d88da93088d Mon Sep 17 00:00:00 2001 From: kimhyemin Date: Mon, 6 Jan 2025 21:49:38 +0900 Subject: [PATCH] =?UTF-8?q?style:=20ktLint=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../remote/KakaoRemoteAuthDataSource.kt | 74 +++++++++---------- .../data/remote/core/service/LoginService.kt | 14 ++++ 2 files changed, 51 insertions(+), 37 deletions(-) create mode 100644 android/app/src/main/java/com/mulberry/ody/data/remote/core/service/LoginService.kt diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/KakaoRemoteAuthDataSource.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/KakaoRemoteAuthDataSource.kt index 7a2ad76d1..b7b5eef7d 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/KakaoRemoteAuthDataSource.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/KakaoRemoteAuthDataSource.kt @@ -15,49 +15,49 @@ import com.mulberry.ody.domain.model.AuthToken import javax.inject.Inject class KakaoRemoteAuthDataSource -@Inject -constructor( - private val loginService: LoginService, - private val authService: AuthService, - private val refreshTokenService: RefreshTokenService, - private val kakaoOAuthLoginService: KakaoOAuthLoginService, -) : RemoteAuthDataSource { - override suspend fun isLoggedIn(): Boolean { - return kakaoOAuthLoginService.isLoggedIn() - } - - override suspend fun postAuthToken(): ApiResult { - return refreshTokenService.postRefreshToken().map { - it.toAuthToken() + @Inject + constructor( + private val loginService: LoginService, + private val authService: AuthService, + private val refreshTokenService: RefreshTokenService, + private val kakaoOAuthLoginService: KakaoOAuthLoginService, + ) : RemoteAuthDataSource { + override suspend fun isLoggedIn(): Boolean { + return kakaoOAuthLoginService.isLoggedIn() } - } - override suspend fun login( - fcmToken: String, - context: Context, - ): ApiResult { - val loginResult = - kakaoOAuthLoginService.login(context).toApiResult() - .map { LoginRequest(fcmToken, it.providerId, it.nickname, it.imageUrl) } + override suspend fun postAuthToken(): ApiResult { + return refreshTokenService.postRefreshToken().map { + it.toAuthToken() + } + } - return loginResult.flatMap { loginRequest -> - loginService.postLoginWithKakao(loginRequest).map { it.toAuthToken() } + override suspend fun login( + fcmToken: String, + context: Context, + ): ApiResult { + val loginResult = + kakaoOAuthLoginService.login(context).toApiResult() + .map { LoginRequest(fcmToken, it.providerId, it.nickname, it.imageUrl) } + + return loginResult.flatMap { loginRequest -> + loginService.postLoginWithKakao(loginRequest).map { it.toAuthToken() } + } } - } - override suspend fun logout(): ApiResult { - val kakaoLogoutResult = kakaoOAuthLoginService.logout() - val odyLogoutResult = authService.postLogout() + override suspend fun logout(): ApiResult { + val kakaoLogoutResult = kakaoOAuthLoginService.logout() + val odyLogoutResult = authService.postLogout() - val exception = kakaoLogoutResult.exceptionOrNull() - if (exception != null) { - return ApiResult.Unexpected(exception) - } + val exception = kakaoLogoutResult.exceptionOrNull() + if (exception != null) { + return ApiResult.Unexpected(exception) + } - return odyLogoutResult - } + return odyLogoutResult + } - override suspend fun withdraw(): ApiResult { - return authService.deleteMember() + override suspend fun withdraw(): ApiResult { + return authService.deleteMember() + } } -} diff --git a/android/app/src/main/java/com/mulberry/ody/data/remote/core/service/LoginService.kt b/android/app/src/main/java/com/mulberry/ody/data/remote/core/service/LoginService.kt new file mode 100644 index 000000000..1f407a380 --- /dev/null +++ b/android/app/src/main/java/com/mulberry/ody/data/remote/core/service/LoginService.kt @@ -0,0 +1,14 @@ +package com.mulberry.ody.data.remote.core.service + +import com.mulberry.ody.data.remote.core.entity.login.request.LoginRequest +import com.mulberry.ody.data.remote.core.entity.login.response.LoginResponse +import com.mulberry.ody.domain.apiresult.ApiResult +import retrofit2.http.Body +import retrofit2.http.POST + +interface LoginService { + @POST("/v1/auth/kakao") + suspend fun postLoginWithKakao( + @Body loginRequest: LoginRequest, + ): ApiResult +}