Skip to content

Commit

Permalink
[FEAT/#116] 계정탈퇴 서버통신 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeyubin committed Jul 17, 2024
1 parent 2dc83de commit eac14e7
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ import com.terning.data.dto.NonDataBaseResponse

interface MyPageDataSource {
suspend fun postLogout(): NonDataBaseResponse

suspend fun deleteQuit(): NonDataBaseResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ class MyPageDataSourceImpl @Inject constructor(
private val myPageService: MyPageService
) : MyPageDataSource {
override suspend fun postLogout(): NonDataBaseResponse = myPageService.postLogout()

override suspend fun deleteQuit(): NonDataBaseResponse = myPageService.deleteQuit()
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ class MyPageRepositoryImpl @Inject constructor(
runCatching {
myPageDataSource.postLogout()
}

override suspend fun deleteQuit(): Result<Unit> =
runCatching{
myPageDataSource.deleteQuit()
}
}
4 changes: 4 additions & 0 deletions data/src/main/java/com/terning/data/service/MyPageService.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.terning.data.service

import com.terning.data.dto.NonDataBaseResponse
import retrofit2.http.DELETE
import retrofit2.http.POST

interface MyPageService {
@POST("api/v1/auth/logout")
suspend fun postLogout(): NonDataBaseResponse

@DELETE("api/v1/auth/withdraw")
suspend fun deleteQuit(): NonDataBaseResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ package com.terning.domain.repository

interface MyPageRepository {
suspend fun postLogout() : Result<Unit>

suspend fun deleteQuit() : Result<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fun MyPageRoute(
MyPageQuitBottomSheet(
onDismiss = { showQuitBottomSheet = false },
onQuitClick = {
viewModel.patchQuit()
viewModel.quitKakao()
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,24 @@ class MyPageViewModel @Inject constructor(
}
}

fun patchQuit() {
fun quitKakao() {
UserApiClient.instance.unlink { error ->
if (error == null) {
deleteQuit()
} else {
_state.value = _state.value.copy(isSuccess = UiState.Failure(error.toString()))
}
}
}

private fun deleteQuit() {
viewModelScope.launch {
myPageRepository.deleteQuit().onSuccess {
tokenRepository.clearInfo()
_state.value = _state.value.copy(isSuccess = UiState.Success(true))
}.onFailure {
_state.value = _state.value.copy(isSuccess = UiState.Failure(it.toString()))
}
}
}
}

0 comments on commit eac14e7

Please sign in to comment.