Skip to content

Commit b9c7ef9

Browse files
committed
Feat: 나의 감정 조회 API 연동
1 parent d5b86ac commit b9c7ef9

File tree

7 files changed

+57
-0
lines changed

7 files changed

+57
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.threegap.bitnagil.data.emotion.datasource
22

33
import com.threegap.bitnagil.data.emotion.model.response.GetEmotionsResponse
4+
import com.threegap.bitnagil.data.emotion.model.response.MyEmotionResponseDto
45
import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
56

67
interface EmotionDataSource {
78
suspend fun getEmotions(): Result<GetEmotionsResponse>
89
suspend fun registerEmotion(emotion: String): Result<RegisterEmotionResponse>
10+
suspend fun getMyEmotionMarble(currentDate: String): Result<MyEmotionResponseDto>
911
}

data/src/main/java/com/threegap/bitnagil/data/emotion/datasourceImpl/EmotionDataSourceImpl.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.threegap.bitnagil.data.common.safeApiCall
44
import com.threegap.bitnagil.data.emotion.datasource.EmotionDataSource
55
import com.threegap.bitnagil.data.emotion.model.request.RegisterEmotionRequest
66
import com.threegap.bitnagil.data.emotion.model.response.GetEmotionsResponse
7+
import com.threegap.bitnagil.data.emotion.model.response.MyEmotionResponseDto
78
import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
89
import com.threegap.bitnagil.data.emotion.service.EmotionService
910
import javax.inject.Inject
@@ -23,4 +24,9 @@ class EmotionDataSourceImpl @Inject constructor(
2324
emotionService.postEmotions(registerEmotionRequest)
2425
}
2526
}
27+
28+
override suspend fun getMyEmotionMarble(currentDate: String): Result<MyEmotionResponseDto> =
29+
safeApiCall {
30+
emotionService.getMyEmotionMarble(currentDate)
31+
}
2632
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.threegap.bitnagil.data.emotion.model.response
2+
3+
import com.threegap.bitnagil.domain.emotion.model.Emotion
4+
import com.threegap.bitnagil.domain.emotion.model.MyEmotion
5+
import kotlinx.serialization.SerialName
6+
import kotlinx.serialization.Serializable
7+
8+
@Serializable
9+
data class MyEmotionResponseDto(
10+
@SerialName("emotionMarbleType")
11+
val emotionMarbleType: String?,
12+
@SerialName("emotionMarbleName")
13+
val emotionMarbleName: String?,
14+
@SerialName("imageUrl")
15+
val imageUrl: String?,
16+
)
17+
18+
fun MyEmotionResponseDto.toDomain(): MyEmotion =
19+
MyEmotion(
20+
emotionMarbleType = emotionMarbleType?.let { Emotion.valueOf(it) },
21+
emotionMarbleName = emotionMarbleName,
22+
imageUrl = imageUrl,
23+
)

data/src/main/java/com/threegap/bitnagil/data/emotion/repositoryImpl/EmotionRepositoryImpl.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.threegap.bitnagil.data.emotion.repositoryImpl
22

33
import com.threegap.bitnagil.data.emotion.datasource.EmotionDataSource
4+
import com.threegap.bitnagil.data.emotion.model.response.toDomain
45
import com.threegap.bitnagil.domain.emotion.model.Emotion
6+
import com.threegap.bitnagil.domain.emotion.model.MyEmotion
57
import com.threegap.bitnagil.domain.emotion.repository.EmotionRepository
68
import javax.inject.Inject
79

@@ -36,4 +38,7 @@ class EmotionRepositoryImpl @Inject constructor(
3638

3739
return emotionDataSource.registerEmotion(selectedEmotion).map { _ -> }
3840
}
41+
42+
override suspend fun getMyEmotionMarble(currentDate: String): Result<MyEmotion> =
43+
emotionDataSource.getMyEmotionMarble(currentDate).map { it.toDomain() }
3944
}

data/src/main/java/com/threegap/bitnagil/data/emotion/service/EmotionService.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package com.threegap.bitnagil.data.emotion.service
22

33
import com.threegap.bitnagil.data.emotion.model.request.RegisterEmotionRequest
44
import com.threegap.bitnagil.data.emotion.model.response.GetEmotionsResponse
5+
import com.threegap.bitnagil.data.emotion.model.response.MyEmotionResponseDto
56
import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
67
import com.threegap.bitnagil.network.model.BaseResponse
78
import retrofit2.http.Body
89
import retrofit2.http.GET
910
import retrofit2.http.POST
11+
import retrofit2.http.Query
1012

1113
interface EmotionService {
1214
@GET("/api/v1/emotion-marbles")
@@ -16,4 +18,9 @@ interface EmotionService {
1618
suspend fun postEmotions(
1719
@Body request: RegisterEmotionRequest,
1820
): BaseResponse<RegisterEmotionResponse>
21+
22+
@GET("/api/v1/emotion-marbles/me")
23+
suspend fun getMyEmotionMarble(
24+
@Query("searchDate") date: String,
25+
): BaseResponse<MyEmotionResponseDto>
1926
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package com.threegap.bitnagil.domain.emotion.repository
22

33
import com.threegap.bitnagil.domain.emotion.model.Emotion
4+
import com.threegap.bitnagil.domain.emotion.model.MyEmotion
45

56
interface EmotionRepository {
67
suspend fun getEmotions(): Result<List<Emotion>>
78
suspend fun registerEmotion(emotion: Emotion): Result<Unit>
9+
suspend fun getMyEmotionMarble(currentDate: String): Result<MyEmotion>
810
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.threegap.bitnagil.domain.emotion.usecase
2+
3+
import com.threegap.bitnagil.domain.emotion.model.MyEmotion
4+
import com.threegap.bitnagil.domain.emotion.repository.EmotionRepository
5+
import javax.inject.Inject
6+
7+
class GetMyEmotionUseCase @Inject constructor(
8+
private val emotionRepository: EmotionRepository,
9+
) {
10+
suspend operator fun invoke(currentDate: String): Result<MyEmotion> =
11+
emotionRepository.getMyEmotionMarble(currentDate)
12+
}

0 commit comments

Comments
 (0)