TP-42804: Add Brotli encoding & decoding for Digital Gold API calls (#8139)
Co-authored-by: Shivam Goyal <shivam.goyal@navi.com>
This commit is contained in:
@@ -276,7 +276,6 @@ dependencies {
|
||||
androidTestImplementation libs.hamcrest
|
||||
debugImplementation libs.androidx.test.monitor
|
||||
|
||||
androidTestImplementation libs.okhttp.mockwebserver
|
||||
androidTestImplementation libs.arch.core.testing
|
||||
testImplementation libs.arch.core.testing
|
||||
testImplementation libs.junit
|
||||
|
||||
@@ -46,7 +46,7 @@ arch-workRuntimeKtx = "1.0.1"
|
||||
awaitility = "4.1.0"
|
||||
branch = "5.1.1"
|
||||
cashfree = "2.0.6"
|
||||
chucker = "3.5.2"
|
||||
chucker = "4.0.0"
|
||||
coilCompose = "2.4.0"
|
||||
compose-bom = "2023.09.01"
|
||||
compose-lib = '1.5.3'
|
||||
@@ -89,8 +89,7 @@ moengage-push-amp-plus = "6.2.1"
|
||||
moengage-rich-notification = "4.3.2"
|
||||
navi-uitron = "1.0.28-20231004.104806-1"
|
||||
navigation = "2.5.3"
|
||||
okhttp-loggingInterceptor = "4.10.0"
|
||||
okhttp-mockwebserver = "4.4.1"
|
||||
okhttp-bom = "4.11.0"
|
||||
otaliastudios-cameraview = "2.7.2"
|
||||
otpless = "1.1.4"
|
||||
payu-checkoutPro = "2.0.17"
|
||||
@@ -305,8 +304,9 @@ moengage-rich-notification = { module = "com.moengage:rich-notification", versio
|
||||
|
||||
navi-uitron = { module = "com.navi.medici:uitron", version.ref = "navi-uitron" }
|
||||
|
||||
okhttp-loggingInterceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp-loggingInterceptor" }
|
||||
okhttp-mockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "okhttp-mockwebserver" }
|
||||
okhttp-bom = { module = "com.squareup.okhttp3:okhttp-bom", version.ref = "okhttp-bom" }
|
||||
okhttp-brotli = { module = "com.squareup.okhttp3:okhttp-brotli" }
|
||||
okhttp-loggingIntercepter = { module = "com.squareup.okhttp3:logging-interceptor" }
|
||||
|
||||
otaliastudios-cameraview = { module = "com.otaliastudios:cameraview", version.ref = "otaliastudios-cameraview" }
|
||||
|
||||
@@ -319,7 +319,6 @@ philjay-mpAndroidChart = { module = "com.github.PhilJay:MPAndroidChart", version
|
||||
|
||||
pierfrancescosoffritti-androidyoutubeplayer = { module = "com.pierfrancescosoffritti.androidyoutubeplayer:core", version.ref = "pierfrancescosoffritti-androidyoutubeplayer" }
|
||||
|
||||
raamcosta-composeDestinations-core = { module = "io.github.raamcosta.compose-destinations:core", version.ref = "raamcosta-composeDestinations" }
|
||||
raamcosta-composeDestinations-animation-core = { module = "io.github.raamcosta.compose-destinations:animations-core", version.ref = "raamcosta-composeDestinations" }
|
||||
raamcosta-composeDestinations-ksp = { module = "io.github.raamcosta.compose-destinations:ksp", version.ref = "raamcosta-composeDestinations" }
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api platform(libs.okhttp.bom)
|
||||
|
||||
implementation libs.android.play.core.ktx
|
||||
|
||||
implementation libs.androidx.room.ktx
|
||||
@@ -61,7 +63,8 @@ dependencies {
|
||||
|
||||
api libs.jakewharton.timber
|
||||
|
||||
api libs.okhttp.loggingInterceptor
|
||||
api libs.okhttp.brotli
|
||||
api libs.okhttp.loggingIntercepter
|
||||
|
||||
kapt libs.androidx.hilt.compiler
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ object FirebaseRemoteConfigHelper {
|
||||
"DISABLE_UPDATE_COMMUNICATION_MEDIUMS_ON_LOGIN"
|
||||
const val COIL_IMAGE_LOADER_ENABLE_DISK_CACHING = "COIL_IMAGE_LOADER_ENABLE_DISK_CACHING"
|
||||
const val PROFILE_CACHING_DISABLE = "PROFILE_CACHING_DISABLE"
|
||||
const val BROTLI_ENCODING_ENABLED = "BROTLI_ENCODING_ENABLED"
|
||||
|
||||
fun init() {
|
||||
remoteConfig = getFirebaseRemoteConfig()
|
||||
|
||||
@@ -62,6 +62,13 @@ abstract class BaseHttpClient(
|
||||
addInterceptor(EncryptionHashInterceptor(context))
|
||||
addInterceptor(headerInterceptor)
|
||||
addInterceptor(GzipInterceptor())
|
||||
|
||||
getChildInterceptors()?.let { interceptors ->
|
||||
interceptors.forEach { interceptor ->
|
||||
addInterceptor(interceptor)
|
||||
}
|
||||
}
|
||||
|
||||
addInterceptor(MetricInterceptor())
|
||||
connectionPool(ConnectionPool(0, 5, TimeUnit.MINUTES))
|
||||
.protocols(listOf(Protocol.HTTP_1_1))
|
||||
@@ -148,4 +155,6 @@ abstract class BaseHttpClient(
|
||||
}
|
||||
response
|
||||
}
|
||||
|
||||
open fun getChildInterceptors(): List<Interceptor>? = null
|
||||
}
|
||||
|
||||
@@ -3,10 +3,13 @@ package com.navi.gold.retrofit
|
||||
import android.content.Context
|
||||
import com.chuckerteam.chucker.api.ChuckerCollector
|
||||
import com.chuckerteam.chucker.api.ChuckerInterceptor
|
||||
import com.navi.common.firebaseremoteconfig.FirebaseRemoteConfigHelper
|
||||
import com.navi.common.model.NetworkInfo
|
||||
import com.navi.common.network.BaseHttpClient
|
||||
import com.navi.gold.BuildConfig
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.brotli.BrotliInterceptor
|
||||
import okhttp3.logging.HttpLoggingInterceptor
|
||||
|
||||
class NaviHttpClient(networkInfo: NetworkInfo, private val context: Context) :
|
||||
@@ -28,7 +31,6 @@ class NaviHttpClient(networkInfo: NetworkInfo, private val context: Context) :
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
okHttpClientBuilder.addInterceptor {
|
||||
|
||||
val oldRequest = it.request()
|
||||
@@ -54,4 +56,12 @@ class NaviHttpClient(networkInfo: NetworkInfo, private val context: Context) :
|
||||
private fun loggingInterceptor() = HttpLoggingInterceptor().apply {
|
||||
setLevel(HttpLoggingInterceptor.Level.BODY)
|
||||
}
|
||||
|
||||
override fun getChildInterceptors(): List<Interceptor>? {
|
||||
return if (FirebaseRemoteConfigHelper.getBoolean(FirebaseRemoteConfigHelper.BROTLI_ENCODING_ENABLED)) {
|
||||
listOf(BrotliInterceptor)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +63,6 @@ dependencies {
|
||||
implementation libs.androidx.constraintlayout
|
||||
implementation libs.androidx.fragment.ktx
|
||||
implementation libs.androidx.legacy.support.v4
|
||||
|
||||
implementation libs.okhttp.loggingInterceptor
|
||||
}
|
||||
|
||||
kapt {
|
||||
|
||||
Reference in New Issue
Block a user