I have function:
@GET("weather")
fun getWeatherByCityName(
@Query("q") cityName: String,
@Query("appid") appId: String = API_KEY,
@Query("units") unit: String,
@Query("lang") lang: String
): Call<WeatherResult>
I want to localize my app so i need to change two fields of this request: units and lang. I want my interceptor to get this request and change it. How can i make my interceptor do this?
val client = OkHttpClient.Builder().apply {
if (BuildConfig.DEBUG) {
addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
}
}.build()
val json = Json { ignoreUnknownKeys = true }
Retrofit.Builder()
.baseUrl(BASE_URL)
.client(client)
.addConverterFactory(json.asConverterFactory(CONTENT_TYPE.toMediaType()))
.build()
}