Updated on 2026-08-14

This commit is contained in:
Tangem 2026-07-20 02:39:06 -07:00
parent 4d331c622d
commit d09743e8f4
5 changed files with 11 additions and 15 deletions

View file

@ -3,6 +3,7 @@ package com.tangem.datasource.api.common.config
import com.tangem.datasource.BuildConfig import com.tangem.datasource.BuildConfig
import com.tangem.datasource.local.config.environment.EnvironmentConfig import com.tangem.datasource.local.config.environment.EnvironmentConfig
import com.tangem.utils.ProviderSuspend import com.tangem.utils.ProviderSuspend
import com.tangem.utils.SupportedLanguages
import com.tangem.utils.info.AppInfoProvider import com.tangem.utils.info.AppInfoProvider
internal sealed class TangemPay( internal sealed class TangemPay(
@ -56,6 +57,7 @@ internal sealed class TangemPay(
"platform" to ProviderSuspend { "Android" }, "platform" to ProviderSuspend { "Android" },
"X-API-KEY" to ProviderSuspend { getBffStaticToken(apiEnvironment) }, "X-API-KEY" to ProviderSuspend { getBffStaticToken(apiEnvironment) },
"X-Device-Scale" to ProviderSuspend { appInfoProvider.deviceScale.toString() }, "X-Device-Scale" to ProviderSuspend { appInfoProvider.deviceScale.toString() },
"Accept-Language" to ProviderSuspend { SupportedLanguages.getCurrentSupportedLanguageCode() },
) )
private fun getBffStaticToken(apiEnvironment: ApiEnvironment): String { private fun getBffStaticToken(apiEnvironment: ApiEnvironment): String {

View file

@ -194,13 +194,11 @@ interface TangemPayApi {
@GET("v1/customer/cashback/promotions") @GET("v1/customer/cashback/promotions")
suspend fun getCashbackPromotions( suspend fun getCashbackPromotions(
@Header("Authorization") authHeader: String, @Header("Authorization") authHeader: String,
@Header("Accept-Language") language: String,
): ApiResponse<CashbackPromotionsResponse> ): ApiResponse<CashbackPromotionsResponse>
@GET("v1/customer/cashback/accruals/docs") @GET("v1/customer/cashback/accruals/docs")
suspend fun getCashbackAccrualDocs( suspend fun getCashbackAccrualDocs(
@Header("Authorization") authHeader: String, @Header("Authorization") authHeader: String,
@Header("Accept-Language") language: String,
): ApiResponse<CashbackAccrualDocsResponse> ): ApiResponse<CashbackAccrualDocsResponse>
@GET("v1/customer/cashback/history") @GET("v1/customer/cashback/history")

View file

@ -18,6 +18,7 @@ import com.tangem.datasource.api.auth.P2PEthPoolAuthProvider
import com.tangem.datasource.api.auth.StakeKitAuthProvider import com.tangem.datasource.api.auth.StakeKitAuthProvider
import com.tangem.test.core.ProvideTestModels import com.tangem.test.core.ProvideTestModels
import com.tangem.utils.ProviderSuspend import com.tangem.utils.ProviderSuspend
import com.tangem.utils.SupportedLanguages
import com.tangem.utils.info.AppInfoProvider import com.tangem.utils.info.AppInfoProvider
import io.mockk.clearMocks import io.mockk.clearMocks
import io.mockk.coEvery import io.mockk.coEvery
@ -300,6 +301,7 @@ internal class ProdApiConfigsManagerTest {
"platform" to ProviderSuspend { "Android" }, "platform" to ProviderSuspend { "Android" },
"X-API-KEY" to ProviderSuspend { TANGEM_PAY_BFF_KEY_DEV }, "X-API-KEY" to ProviderSuspend { TANGEM_PAY_BFF_KEY_DEV },
"X-Device-Scale" to ProviderSuspend { DEVICE_SCALE.toString() }, "X-Device-Scale" to ProviderSuspend { DEVICE_SCALE.toString() },
"Accept-Language" to ProviderSuspend { SupportedLanguages.getCurrentSupportedLanguageCode() },
), ),
), ),
) )
@ -316,6 +318,7 @@ internal class ProdApiConfigsManagerTest {
"platform" to ProviderSuspend { "Android" }, "platform" to ProviderSuspend { "Android" },
"X-API-KEY" to ProviderSuspend { TANGEM_PAY_BFF_KEY_DEV }, "X-API-KEY" to ProviderSuspend { TANGEM_PAY_BFF_KEY_DEV },
"X-Device-Scale" to ProviderSuspend { DEVICE_SCALE.toString() }, "X-Device-Scale" to ProviderSuspend { DEVICE_SCALE.toString() },
"Accept-Language" to ProviderSuspend { SupportedLanguages.getCurrentSupportedLanguageCode() },
), ),
), ),
) )

View file

@ -14,7 +14,6 @@ import com.tangem.domain.pay.model.CashbackPromotions
import com.tangem.domain.pay.model.CashbackSummary import com.tangem.domain.pay.model.CashbackSummary
import com.tangem.domain.pay.repository.CashbackRepository import com.tangem.domain.pay.repository.CashbackRepository
import com.tangem.domain.visa.error.VisaApiError import com.tangem.domain.visa.error.VisaApiError
import com.tangem.utils.SupportedLanguages
import javax.inject.Inject import javax.inject.Inject
internal class DefaultCashbackRepository @Inject constructor( internal class DefaultCashbackRepository @Inject constructor(
@ -31,10 +30,7 @@ internal class DefaultCashbackRepository @Inject constructor(
override suspend fun getCashbackPromotions(userWalletId: UserWalletId): Either<VisaApiError, CashbackPromotions> { override suspend fun getCashbackPromotions(userWalletId: UserWalletId): Either<VisaApiError, CashbackPromotions> {
return requestHelper.performRequest(userWalletId) { authHeader -> return requestHelper.performRequest(userWalletId) { authHeader ->
tangemPayApi.getCashbackPromotions( tangemPayApi.getCashbackPromotions(authHeader = authHeader)
authHeader = authHeader,
language = SupportedLanguages.getCurrentSupportedLanguageCode(),
)
}.map(CashbackPromotionsConverter::convert) }.map(CashbackPromotionsConverter::convert)
} }
@ -42,10 +38,7 @@ internal class DefaultCashbackRepository @Inject constructor(
userWalletId: UserWalletId, userWalletId: UserWalletId,
): Either<VisaApiError, List<CashbackDocument>> { ): Either<VisaApiError, List<CashbackDocument>> {
return requestHelper.performRequest(userWalletId) { authHeader -> return requestHelper.performRequest(userWalletId) { authHeader ->
tangemPayApi.getCashbackAccrualDocs( tangemPayApi.getCashbackAccrualDocs(authHeader = authHeader)
authHeader = authHeader,
language = SupportedLanguages.getCurrentSupportedLanguageCode(),
)
}.map(CashbackAccrualDocsConverter::convert) }.map(CashbackAccrualDocsConverter::convert)
} }

View file

@ -44,7 +44,7 @@ internal class DefaultCashbackRepositoryTest {
fun `GIVEN promotions response WHEN getCashbackPromotions THEN converter result is returned`() = runTest { fun `GIVEN promotions response WHEN getCashbackPromotions THEN converter result is returned`() = runTest {
// Arrange // Arrange
val response = CashbackPromotionsResponse(cashbackOnCards = null, additionalCashback = null) val response = CashbackPromotionsResponse(cashbackOnCards = null, additionalCashback = null)
coEvery { tangemPayApi.getCashbackPromotions(any(), any()) } returns ApiResponse.Success(response) coEvery { tangemPayApi.getCashbackPromotions(any()) } returns ApiResponse.Success(response)
// Act // Act
val actual = createRepository().getCashbackPromotions(userWalletId) val actual = createRepository().getCashbackPromotions(userWalletId)
@ -56,7 +56,7 @@ internal class DefaultCashbackRepositoryTest {
@Test @Test
fun `GIVEN backend error WHEN getCashbackPromotions THEN error is propagated`() = runTest { fun `GIVEN backend error WHEN getCashbackPromotions THEN error is propagated`() = runTest {
// Arrange // Arrange
coEvery { tangemPayApi.getCashbackPromotions(any(), any()) } returns coEvery { tangemPayApi.getCashbackPromotions(any()) } returns
ApiResponse.Error(ApiResponseError.NetworkException()) as ApiResponse<CashbackPromotionsResponse> ApiResponse.Error(ApiResponseError.NetworkException()) as ApiResponse<CashbackPromotionsResponse>
// Act // Act
@ -72,7 +72,7 @@ internal class DefaultCashbackRepositoryTest {
val response = CashbackAccrualDocsResponse( val response = CashbackAccrualDocsResponse(
docs = listOf(CashbackAccrualDocsResponse.Doc(id = "1", title = "Terms", url = "https://a")), docs = listOf(CashbackAccrualDocsResponse.Doc(id = "1", title = "Terms", url = "https://a")),
) )
coEvery { tangemPayApi.getCashbackAccrualDocs(any(), any()) } returns ApiResponse.Success(response) coEvery { tangemPayApi.getCashbackAccrualDocs(any()) } returns ApiResponse.Success(response)
// Act // Act
val actual = createRepository().getCashbackAccrualDocs(userWalletId) val actual = createRepository().getCashbackAccrualDocs(userWalletId)
@ -84,7 +84,7 @@ internal class DefaultCashbackRepositoryTest {
@Test @Test
fun `GIVEN backend error WHEN getCashbackAccrualDocs THEN error is propagated`() = runTest { fun `GIVEN backend error WHEN getCashbackAccrualDocs THEN error is propagated`() = runTest {
// Arrange // Arrange
coEvery { tangemPayApi.getCashbackAccrualDocs(any(), any()) } returns coEvery { tangemPayApi.getCashbackAccrualDocs(any()) } returns
ApiResponse.Error(ApiResponseError.NetworkException()) as ApiResponse<CashbackAccrualDocsResponse> ApiResponse.Error(ApiResponseError.NetworkException()) as ApiResponse<CashbackAccrualDocsResponse>
// Act // Act