Updated on 2026-08-14
This commit is contained in:
parent
ee722c5f46
commit
67a245a19c
18 changed files with 296 additions and 60 deletions
|
|
@ -25,6 +25,9 @@ android {
|
|||
|
||||
dependencies {
|
||||
|
||||
/** Project */
|
||||
implementation(project(":libs:auth"))
|
||||
|
||||
/** DI */
|
||||
implementation(Library.hilt)
|
||||
kapt(Library.hiltKapt)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package com.tangem.datasource.api
|
||||
|
||||
import com.tangem.lib.auth.AuthProvider
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.Response
|
||||
|
||||
class AuthHeaderInterceptor(
|
||||
private val authProvider: AuthProvider,
|
||||
) : Interceptor {
|
||||
|
||||
override fun intercept(chain: Interceptor.Chain): Response {
|
||||
val request = chain.request().newBuilder().apply {
|
||||
addHeader(
|
||||
HEADER_CARD_KEY, authProvider.getAuthToken(),
|
||||
)
|
||||
}.build()
|
||||
|
||||
return chain.proceed(request)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val HEADER_CARD_KEY = "card_public_key"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package com.tangem.datasource.di
|
||||
|
||||
import com.tangem.datasource.api.AuthHeaderInterceptor
|
||||
import com.tangem.datasource.api.referral.ReferralApi
|
||||
import com.tangem.lib.auth.AuthProvider
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
|
|
@ -30,15 +32,16 @@ class NetworkModule {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideOkHttpClient(): OkHttpClient {
|
||||
fun provideOkHttpClient(authProvider: AuthProvider): OkHttpClient {
|
||||
return OkHttpClient.Builder()
|
||||
.addInterceptor(
|
||||
HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC),
|
||||
)
|
||||
.addInterceptor(AuthHeaderInterceptor(authProvider))
|
||||
.build()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val PROD_REFERRAL_BASE_URL = ""
|
||||
const val PROD_REFERRAL_BASE_URL = "https://api.tangem-tech.com/v1/"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue