Hello guys, again me :sweat_smile: I have one modu...
# kodein
j
Hello guys, again me 😅 I have one module for
Retrofit
as :
Copy code
val retrofitModule = Kodein.Module("retrofitModule") {

    bind<OkHttpClient>() with singleton {
        OkHttpClient()
            .newBuilder()
            .addInterceptor(HeadersInterceptor())
            .addInterceptor(HttpLoggingInterceptor().apply {
                level = if (BuildConfig.DEBUG) HttpLoggingInterceptor.Level.BASIC else HttpLoggingInterceptor.Level.NONE
            })
            .build()
    }
    bind<Retrofit>() with singleton {
        Retrofit.Builder()
            .baseUrl("realbaseurl")
            .client(instance())
            .addConverterFactory(GsonConverterFactory.create())
            .build()
    }
    bind<MyService>() with singleton {
        instance<Retrofit>().create(MyService::class.java)
    }

}
but now I want to start using
MockWebServer
and I saw that I have to create a "Fake retrofit" with the
baseUrl
as
"/"
, so I'm wondering if I create a
fakeRetrofitModule
how can I get the instance of that
Retrofit
since I have two, now.
Copy code
val fakeRetrofitModule = Kodein.Module("fakeRetrofitModule") {

    bind<Retrofit>() with singleton {
        Retrofit.Builder()
            .baseUrl("/")
            .client(instance())
            .addConverterFactory(GsonConverterFactory.create())
            .build()
    }
    bind<MyService>() with singleton {
        instance<Retrofit>().create(MyService::class.java)
    }
}
Any idea?