Skip to content

Commit

Permalink
refactor(RecommendationDataSource): RecommendationDataSource abstraction
Browse files Browse the repository at this point in the history
  • Loading branch information
looee1q committed Dec 20, 2024
1 parent 484d1d2 commit a75c569
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.personalization.di

import com.personalization.SDK
import com.personalization.features.notification.service.NotificationService
import com.personalization.sdk.data.di.AbstractDataSourcesModule
import com.personalization.sdk.data.di.DataSourcesModule
import com.personalization.sdk.data.di.ModelsModule
import com.personalization.sdk.data.di.RepositoriesModule
Expand All @@ -15,7 +14,6 @@ import javax.inject.Singleton
DataSourcesModule::class,
RepositoriesModule::class,
ModelsModule::class,
AbstractDataSourcesModule::class,
SdkModule::class,
AppModule::class
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.personalization.sdk.data.repositories.notification.NotificationDataSo
import com.personalization.sdk.data.repositories.preferences.PreferencesDataSource
import com.personalization.sdk.data.repositories.preferences.PreferencesDataSourceImpl
import com.personalization.sdk.data.repositories.recommendation.RecommendationDataSource
import com.personalization.sdk.data.repositories.recommendation.RecommendationDataSourceImpl
import com.personalization.sdk.data.repositories.userSettings.UserSettingsDataSource
import com.personalization.sdk.data.repositories.userSettings.UserSettingsDataSourceImpl
import dagger.Binds
Expand All @@ -15,19 +16,15 @@ import dagger.assisted.AssistedFactory
import javax.inject.Singleton

@Module
class DataSourcesModule {
interface DataSourcesModule {

@Provides
@Binds
@Singleton
fun provideRecommendationDataSource() = RecommendationDataSource()
}

@Module
interface AbstractDataSourcesModule {
fun bindPreferencesDataSource(impl: PreferencesDataSourceImpl): PreferencesDataSource

@Binds
@Singleton
fun bindPreferencesDataSource(impl: PreferencesDataSourceImpl): PreferencesDataSource
fun bindRecommendationDataSource(impl: RecommendationDataSourceImpl): RecommendationDataSource

companion object {

Expand All @@ -40,7 +37,7 @@ interface AbstractDataSourcesModule {

@Provides
@Singleton
fun bindUserSettingsDataSource(
fun provideUserSettingsDataSource(
preferencesDataSource: PreferencesDataSource,
shopId: String,
segment: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
package com.personalization.sdk.data.repositories.recommendation

import com.personalization.sdk.domain.models.RecommendedBy
import javax.inject.Inject

class RecommendationDataSource @Inject constructor() {
interface RecommendationDataSource {

private var recommendedBy: RecommendedBy? = null
fun getRecommendedBy(): RecommendedBy?

fun getRecommendedBy(): RecommendedBy? = recommendedBy

fun setRecommendedBy(recommendedBy: RecommendedBy?) {
this.recommendedBy = recommendedBy
}
fun setRecommendedBy(recommendedBy: RecommendedBy?)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.personalization.sdk.data.repositories.recommendation

import com.personalization.sdk.domain.models.RecommendedBy
import javax.inject.Inject

class RecommendationDataSourceImpl @Inject constructor() : RecommendationDataSource {

private var recommendedBy: RecommendedBy? = null

override fun getRecommendedBy(): RecommendedBy? = recommendedBy

override fun setRecommendedBy(recommendedBy: RecommendedBy?) {
this.recommendedBy = recommendedBy
}
}

0 comments on commit a75c569

Please sign in to comment.