package ru.fincode.tsudesk.core.config.di

import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import ru.fincode.tsudesk.core.config.data.remote.ConfigApiContract.CONFIG_BASE_URL
import ru.fincode.tsudesk.core.network.RetrofitFactory
import ru.fincode.tsudesk.core.config.data.remote.api.ConfigApi
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object ConfigNetworkModule {
    @Provides
    @Singleton
    @ConfigRetrofit
    fun provideConfigRetrofit(
        factory: RetrofitFactory,
        client: OkHttpClient
    ): Retrofit =
        factory.create(
            baseUrl = CONFIG_BASE_URL,
            client = client
        )

    @Provides
    @Singleton
    fun provideConfigApi(
        @ConfigRetrofit retrofit: Retrofit
    ): ConfigApi =
        retrofit.create(ConfigApi::class.java)
}
