Skip to content

Commit 6b13a06

Browse files
authored
Merge branch 'develop' into feature/#23-home-ui
2 parents 7f07a8d + 0c7cf49 commit 6b13a06

File tree

22 files changed

+509
-0
lines changed

22 files changed

+509
-0
lines changed

app/src/main/java/com/threegap/bitnagil/di/data/DataSourceModule.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import com.threegap.bitnagil.data.auth.datasource.AuthLocalDataSource
44
import com.threegap.bitnagil.data.auth.datasource.AuthRemoteDataSource
55
import com.threegap.bitnagil.data.auth.datasourceimpl.AuthLocalDataSourceImpl
66
import com.threegap.bitnagil.data.auth.datasourceimpl.AuthRemoteDataSourceImpl
7+
import com.threegap.bitnagil.data.emotion.datasource.EmotionDataSource
8+
import com.threegap.bitnagil.data.emotion.datasourceImpl.EmotionDataSourceImpl
79
import com.threegap.bitnagil.data.onboarding.datasource.OnBoardingDataSource
810
import com.threegap.bitnagil.data.onboarding.datasourceImpl.OnBoardingDataSourceImpl
911
import com.threegap.bitnagil.data.routine.datasource.RoutineRemoteDataSource
@@ -36,6 +38,10 @@ abstract class DataSourceModule {
3638
@Singleton
3739
abstract fun bindRoutineDataSource(routineDataSourceImpl: RoutineRemoteDataSourceImpl): RoutineRemoteDataSource
3840

41+
@Binds
42+
@Singleton
43+
abstract fun bindEmotionDataSource(emotionDataSourceImpl: EmotionDataSourceImpl): EmotionDataSource
44+
3945
@Binds
4046
@Singleton
4147
abstract fun bindWriteRoutineDataSource(writeRoutineDataSourceImpl: WriteRoutineDataSourceImpl): WriteRoutineDataSource

app/src/main/java/com/threegap/bitnagil/di/data/RepositoryModule.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.threegap.bitnagil.di.data
22

33
import com.threegap.bitnagil.data.auth.repositoryimpl.AuthRepositoryImpl
4+
import com.threegap.bitnagil.data.emotion.repositoryImpl.EmotionRepositoryImpl
45
import com.threegap.bitnagil.data.onboarding.repositoryImpl.OnBoardingRepositoryImpl
56
import com.threegap.bitnagil.data.routine.repositoryImpl.RoutineRepositoryImpl
67
import com.threegap.bitnagil.data.writeroutine.repositoryImpl.WriteRoutineRepositoryImpl
78
import com.threegap.bitnagil.domain.auth.repository.AuthRepository
9+
import com.threegap.bitnagil.domain.emotion.repository.EmotionRepository
810
import com.threegap.bitnagil.domain.onboarding.repository.OnBoardingRepository
911
import com.threegap.bitnagil.domain.routine.repository.RoutineRepository
1012
import com.threegap.bitnagil.domain.writeroutine.repository.WriteRoutineRepository
@@ -30,6 +32,10 @@ abstract class RepositoryModule {
3032
@Singleton
3133
abstract fun bindRoutineRepository(routineRepositoryImpl: RoutineRepositoryImpl): RoutineRepository
3234

35+
@Binds
36+
@Singleton
37+
abstract fun bindEmotionRepository(emotionRepositoryImpl: EmotionRepositoryImpl): EmotionRepository
38+
3339
@Binds
3440
@Singleton
3541
abstract fun bindWriteRoutineRepository(writeRoutineRepositoryImpl: WriteRoutineRepositoryImpl): WriteRoutineRepository

app/src/main/java/com/threegap/bitnagil/di/data/ServiceModule.kt

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

33
import com.threegap.bitnagil.data.auth.service.AuthService
4+
import com.threegap.bitnagil.data.emotion.service.EmotionService
45
import com.threegap.bitnagil.data.onboarding.service.OnBoardingService
56
import com.threegap.bitnagil.data.routine.service.RoutineService
67
import com.threegap.bitnagil.data.writeroutine.service.WriteRoutineService
@@ -33,6 +34,11 @@ object ServiceModule {
3334
fun provideRoutineService(@Auth retrofit: Retrofit): RoutineService =
3435
retrofit.create(RoutineService::class.java)
3536

37+
@Provides
38+
@Singleton
39+
fun providerEmotionService(@Auth retrofit: Retrofit): EmotionService =
40+
retrofit.create(EmotionService::class.java)
41+
3642
@Provides
3743
@Singleton
3844
fun providerWriteRoutineService(@Auth retrofit: Retrofit): WriteRoutineService =
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.threegap.bitnagil.data.emotion.datasource
2+
3+
import com.threegap.bitnagil.data.emotion.model.response.GetEmotionsResponse
4+
import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
5+
6+
interface EmotionDataSource {
7+
suspend fun getEmotions(): Result<GetEmotionsResponse>
8+
suspend fun registerEmotion(emotion: String): Result<RegisterEmotionResponse>
9+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.threegap.bitnagil.data.emotion.datasourceImpl
2+
3+
import com.threegap.bitnagil.data.common.safeApiCall
4+
import com.threegap.bitnagil.data.emotion.datasource.EmotionDataSource
5+
import com.threegap.bitnagil.data.emotion.model.request.RegisterEmotionRequest
6+
import com.threegap.bitnagil.data.emotion.model.response.GetEmotionsResponse
7+
import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
8+
import com.threegap.bitnagil.data.emotion.service.EmotionService
9+
import javax.inject.Inject
10+
11+
class EmotionDataSourceImpl @Inject constructor(
12+
private val emotionService: EmotionService,
13+
) : EmotionDataSource {
14+
override suspend fun getEmotions(): Result<GetEmotionsResponse> {
15+
return safeApiCall {
16+
emotionService.getEmotions()
17+
}
18+
}
19+
20+
override suspend fun registerEmotion(emotion: String): Result<RegisterEmotionResponse> {
21+
val registerEmotionRequest = RegisterEmotionRequest(emotionMarbleType = emotion)
22+
return safeApiCall {
23+
emotionService.postEmotions(registerEmotionRequest)
24+
}
25+
}
26+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.threegap.bitnagil.data.emotion.model.dto
2+
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
5+
6+
@Serializable
7+
data class EmotionRecommendedRoutineDto(
8+
@SerialName("recommendedRoutineId")
9+
val recommendedRoutineId: Int,
10+
@SerialName("recommendedRoutineName")
11+
val recommendedRoutineName: String,
12+
@SerialName("routineDescription")
13+
val routineDescription: String,
14+
@SerialName("recommendedSubRoutines")
15+
val recommendedSubRoutines: List<EmotionRecommendedSubRoutineDto>,
16+
)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.threegap.bitnagil.data.emotion.model.dto
2+
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
5+
6+
@Serializable
7+
data class EmotionRecommendedSubRoutineDto(
8+
@SerialName("recommendedSubRoutineId")
9+
val recommendedSubRoutineId: Int,
10+
@SerialName("recommendedSubRoutineName")
11+
val recommendedSubRoutineName: String,
12+
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.threegap.bitnagil.data.emotion.model.request
2+
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
5+
6+
@Serializable
7+
data class RegisterEmotionRequest(
8+
@SerialName("emotionMarbleType")
9+
val emotionMarbleType: String,
10+
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.threegap.bitnagil.data.emotion.model.response
2+
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
5+
6+
@Serializable
7+
data class GetEmotionsResponse(
8+
@SerialName("emotionMarbleTypes")
9+
val emotionMarbleTypes: List<String>,
10+
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.threegap.bitnagil.data.emotion.model.response
2+
3+
import com.threegap.bitnagil.data.emotion.model.dto.EmotionRecommendedRoutineDto
4+
import kotlinx.serialization.SerialName
5+
import kotlinx.serialization.Serializable
6+
7+
@Serializable
8+
data class RegisterEmotionResponse(
9+
@SerialName("recommendedRoutines")
10+
val recommendedRoutines: List<EmotionRecommendedRoutineDto>,
11+
)

0 commit comments

Comments
 (0)