Skip to content

Commit

Permalink
FEAT/#17: UserProfileRepository 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
youjin09222 committed Jun 7, 2024
1 parent acb32da commit 7bd80bd
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.sopt.now.test.data.repository

import com.sopt.now.test.core.view.UiState
import com.sopt.now.test.data.ServicePool
import com.sopt.now.test.data.dto.response.ResponseFriendDto
import com.sopt.now.test.data.dto.response.ResponseUserInfoDto
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

class UserProfileRepository {
suspend fun getUserProfile(): UiState<ResponseUserInfoDto> {
return withContext(Dispatchers.IO) {
runCatching {
ServicePool.userService.getUserInfo()
}.fold(
{ UiState.Success(it) },
{ UiState.Failure(it.message.toString()) }
)
}
}

suspend fun getFriendProfile(): UiState<ResponseFriendDto> {
return withContext(Dispatchers.IO) {
runCatching {
ServicePool.friendService.getFriendInfo(1)
}.fold(
{ UiState.Success(it) },
{ UiState.Failure(it.message.toString()) }
)
}
}
}

0 comments on commit 7bd80bd

Please sign in to comment.