* Use Ktor for network requests * Remove V0 version * Remove Retrofit dependency * Fix url * Update versions of dependencies * Revert kotlinx-datetime Due to https://github.com/Kotlin/kotlinx-datetime/issues/304 * Rename leftovers * Remove OkHttp * Remove unused manifest * Remove unused Hilt module * Fix building empty image URLs * Use OkHttp as engine for Ktor * Reduce visibility of internal classes * Fix first set up test * Store only auth token, not header * Remove UnitInfo/FoodInfo/VersionInfo/NewShoppingListItemInfo * Remove RecipeSummaryInfo and ShoppingListsInfo * Remove FullShoppingListInfo * Remove ParseRecipeURLInfo * Remove FullRecipeInfo * Sign out if access token does not work * Rename getVersionInfo method * Update version name
49 lines
1.5 KiB
Kotlin
49 lines
1.5 KiB
Kotlin
package gq.kirmanak.mealient.datasource
|
|
|
|
import dagger.Binds
|
|
import dagger.Module
|
|
import dagger.Provides
|
|
import dagger.hilt.InstallIn
|
|
import dagger.hilt.components.SingletonComponent
|
|
import gq.kirmanak.mealient.datasource.impl.MealieDataSourceImpl
|
|
import gq.kirmanak.mealient.datasource.impl.MealieServiceKtor
|
|
import gq.kirmanak.mealient.datasource.impl.NetworkRequestWrapperImpl
|
|
import gq.kirmanak.mealient.datasource.impl.OkHttpBuilderImpl
|
|
import gq.kirmanak.mealient.datasource.impl.TrustedCertificatesStoreImpl
|
|
import kotlinx.serialization.json.Json
|
|
import okhttp3.OkHttpClient
|
|
import javax.inject.Singleton
|
|
|
|
@Module
|
|
@InstallIn(SingletonComponent::class)
|
|
internal interface DataSourceModule {
|
|
|
|
companion object {
|
|
|
|
@Provides
|
|
@Singleton
|
|
fun provideJson(): Json = Json {
|
|
coerceInputValues = true
|
|
ignoreUnknownKeys = true
|
|
encodeDefaults = true
|
|
}
|
|
|
|
@Provides
|
|
@Singleton
|
|
fun provideOkHttp(okHttpBuilder: OkHttpBuilderImpl): OkHttpClient =
|
|
okHttpBuilder.buildOkHttp()
|
|
|
|
}
|
|
|
|
@Binds
|
|
fun bindMealieDataSource(mealientDataSourceImpl: MealieDataSourceImpl): MealieDataSource
|
|
|
|
@Binds
|
|
fun bindMealieService(impl: MealieServiceKtor): MealieService
|
|
|
|
@Binds
|
|
fun bindNetworkRequestWrapper(networkRequestWrapperImpl: NetworkRequestWrapperImpl): NetworkRequestWrapper
|
|
|
|
@Binds
|
|
fun bindTrustedCertificatesStore(impl: TrustedCertificatesStoreImpl): TrustedCertificatesStore
|
|
} |