File tree Expand file tree Collapse file tree 7 files changed +57
-0
lines changed
data/src/main/java/com/threegap/bitnagil/data/emotion
domain/src/main/java/com/threegap/bitnagil/domain/emotion Expand file tree Collapse file tree 7 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 11package com.threegap.bitnagil.data.emotion.datasource
22
33import com.threegap.bitnagil.data.emotion.model.response.GetEmotionsResponse
4+ import com.threegap.bitnagil.data.emotion.model.response.MyEmotionResponseDto
45import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
56
67interface EmotionDataSource {
78 suspend fun getEmotions (): Result <GetEmotionsResponse >
89 suspend fun registerEmotion (emotion : String ): Result <RegisterEmotionResponse >
10+ suspend fun getMyEmotionMarble (currentDate : String ): Result <MyEmotionResponseDto >
911}
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import com.threegap.bitnagil.data.common.safeApiCall
44import com.threegap.bitnagil.data.emotion.datasource.EmotionDataSource
55import com.threegap.bitnagil.data.emotion.model.request.RegisterEmotionRequest
66import com.threegap.bitnagil.data.emotion.model.response.GetEmotionsResponse
7+ import com.threegap.bitnagil.data.emotion.model.response.MyEmotionResponseDto
78import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
89import com.threegap.bitnagil.data.emotion.service.EmotionService
910import 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}
Original file line number Diff line number Diff line change 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+ )
Original file line number Diff line number Diff line change 11package com.threegap.bitnagil.data.emotion.repositoryImpl
22
33import com.threegap.bitnagil.data.emotion.datasource.EmotionDataSource
4+ import com.threegap.bitnagil.data.emotion.model.response.toDomain
45import com.threegap.bitnagil.domain.emotion.model.Emotion
6+ import com.threegap.bitnagil.domain.emotion.model.MyEmotion
57import com.threegap.bitnagil.domain.emotion.repository.EmotionRepository
68import 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}
Original file line number Diff line number Diff line change @@ -2,11 +2,13 @@ package com.threegap.bitnagil.data.emotion.service
22
33import com.threegap.bitnagil.data.emotion.model.request.RegisterEmotionRequest
44import com.threegap.bitnagil.data.emotion.model.response.GetEmotionsResponse
5+ import com.threegap.bitnagil.data.emotion.model.response.MyEmotionResponseDto
56import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
67import com.threegap.bitnagil.network.model.BaseResponse
78import retrofit2.http.Body
89import retrofit2.http.GET
910import retrofit2.http.POST
11+ import retrofit2.http.Query
1012
1113interface 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}
Original file line number Diff line number Diff line change 11package com.threegap.bitnagil.domain.emotion.repository
22
33import com.threegap.bitnagil.domain.emotion.model.Emotion
4+ import com.threegap.bitnagil.domain.emotion.model.MyEmotion
45
56interface 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}
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments