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

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

View file

@ -44,7 +44,7 @@ internal class DefaultCashbackRepositoryTest {
fun `GIVEN promotions response WHEN getCashbackPromotions THEN converter result is returned`() = runTest {
// Arrange
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
val actual = createRepository().getCashbackPromotions(userWalletId)
@ -56,7 +56,7 @@ internal class DefaultCashbackRepositoryTest {
@Test
fun `GIVEN backend error WHEN getCashbackPromotions THEN error is propagated`() = runTest {
// Arrange
coEvery { tangemPayApi.getCashbackPromotions(any(), any()) } returns
coEvery { tangemPayApi.getCashbackPromotions(any()) } returns
ApiResponse.Error(ApiResponseError.NetworkException()) as ApiResponse<CashbackPromotionsResponse>
// Act
@ -72,7 +72,7 @@ internal class DefaultCashbackRepositoryTest {
val response = CashbackAccrualDocsResponse(
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
val actual = createRepository().getCashbackAccrualDocs(userWalletId)
@ -84,7 +84,7 @@ internal class DefaultCashbackRepositoryTest {
@Test
fun `GIVEN backend error WHEN getCashbackAccrualDocs THEN error is propagated`() = runTest {
// Arrange
coEvery { tangemPayApi.getCashbackAccrualDocs(any(), any()) } returns
coEvery { tangemPayApi.getCashbackAccrualDocs(any()) } returns
ApiResponse.Error(ApiResponseError.NetworkException()) as ApiResponse<CashbackAccrualDocsResponse>
// Act