Updated on 2026-08-14
This commit is contained in:
parent
7b71962131
commit
5d2282b734
4 changed files with 20 additions and 33 deletions
|
|
@ -6,7 +6,6 @@ import com.tangem.datasource.api.promotion.models.*
|
|||
import com.tangem.feature.learn2earn.data.api.Learn2earnPreferenceStorage
|
||||
import com.tangem.feature.learn2earn.data.api.Learn2earnRepository
|
||||
import com.tangem.feature.learn2earn.data.models.PromoUserData
|
||||
import com.tangem.feature.learn2earn.data.models.getData
|
||||
import com.tangem.utils.coroutines.AppCoroutineDispatcherProvider
|
||||
import kotlinx.coroutines.withContext
|
||||
import timber.log.Timber
|
||||
|
|
@ -127,4 +126,12 @@ internal class DefaultLearn2earnRepository(
|
|||
private companion object {
|
||||
const val PROGRAM_NAME: String = "1inch"
|
||||
}
|
||||
}
|
||||
|
||||
private fun PromotionInfoResponse.getData(promoCode: String?): PromotionInfoResponse.Data? {
|
||||
return if (promoCode == null) {
|
||||
newCard
|
||||
} else {
|
||||
oldCard
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package com.tangem.feature.learn2earn.data.models
|
||||
|
||||
import com.tangem.datasource.api.promotion.models.PromotionInfoResponse
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal fun PromotionInfoResponse.getData(promoCode: String?): PromotionInfoResponse.Data? {
|
||||
return if (promoCode == null) {
|
||||
newCard
|
||||
} else {
|
||||
oldCard
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,6 @@ import com.tangem.feature.learn2earn.data.models.PromoUserData
|
|||
import com.tangem.feature.learn2earn.domain.api.*
|
||||
import com.tangem.feature.learn2earn.domain.models.Promotion
|
||||
import com.tangem.feature.learn2earn.domain.models.PromotionError
|
||||
import com.tangem.feature.learn2earn.domain.models.getData
|
||||
import com.tangem.feature.learn2earn.domain.models.toDomainError
|
||||
import com.tangem.lib.crypto.DerivationManager
|
||||
import com.tangem.lib.crypto.UserWalletManager
|
||||
|
|
@ -210,11 +209,12 @@ class DefaultLearn2earnInteractor(
|
|||
onSuccess = { response ->
|
||||
val responseError = response.error
|
||||
if (responseError == null) {
|
||||
val npeMessage = { "Shouldn't be null" }
|
||||
Promotion(
|
||||
info = Promotion.PromotionInfo(
|
||||
newCard = response.newCard!!,
|
||||
oldCard = response.oldCard!!,
|
||||
awardPaymentToken = response.awardPaymentToken!!,
|
||||
newCard = requireNotNull(response.newCard, npeMessage),
|
||||
oldCard = requireNotNull(response.oldCard, npeMessage),
|
||||
awardPaymentToken = requireNotNull(response.awardPaymentToken, npeMessage),
|
||||
),
|
||||
error = null,
|
||||
)
|
||||
|
|
@ -252,4 +252,12 @@ class DefaultLearn2earnInteractor(
|
|||
repository.updateUserData(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun Promotion.PromotionInfo.getData(promoCode: String?): PromotionInfoResponse.Data {
|
||||
return if (promoCode == null) {
|
||||
newCard
|
||||
} else {
|
||||
oldCard
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package com.tangem.feature.learn2earn.domain.models
|
||||
|
||||
import com.tangem.datasource.api.promotion.models.PromotionInfoResponse
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal fun Promotion.PromotionInfo.getData(promoCode: String?): PromotionInfoResponse.Data {
|
||||
return if (promoCode == null) {
|
||||
newCard
|
||||
} else {
|
||||
oldCard
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue