Updated on 2026-08-14
This commit is contained in:
parent
3fefb7bf52
commit
ff958f6bba
23 changed files with 631 additions and 24 deletions
|
|
@ -120,6 +120,7 @@ internal class PaymentAccountStatusValueDMConverter @Inject constructor(
|
|||
},
|
||||
error = null,
|
||||
virtualAccount = VirtualAccountOnramp.None,
|
||||
tariffPlan = null,
|
||||
)
|
||||
is PaymentAccountStatusValueDM.UnderReview -> PaymentAccountStatusValue.UnderReview(
|
||||
source = StatusSource.CACHE,
|
||||
|
|
|
|||
|
|
@ -395,6 +395,7 @@ internal class DefaultPaymentAccountStatusFetcher @Inject constructor(
|
|||
),
|
||||
error = null,
|
||||
virtualAccount = virtualAccount,
|
||||
tariffPlan = tariffPlan,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import com.tangem.datasource.api.pay.models.response.CustomerMeResponse
|
|||
import com.tangem.datasource.api.pay.models.response.FiatBalance
|
||||
import com.tangem.domain.models.account.CardDisplayName
|
||||
import com.tangem.domain.models.account.PaymentAccountStatusValue
|
||||
import com.tangem.domain.models.account.TangemPayCustomerTariffPlan
|
||||
import com.tangem.domain.models.account.TangemPayTariffPlan
|
||||
import com.tangem.domain.models.kyc.KycStatus
|
||||
import com.tangem.domain.models.pay.TangemPayCard
|
||||
import com.tangem.domain.models.pay.TangemPayCardFrozenState
|
||||
|
|
@ -18,6 +20,7 @@ import com.tangem.domain.pay.model.CustomerInfo.ProductInstance.SpecificationDat
|
|||
import com.tangem.domain.pay.model.CustomerInfo.ProductInstance.Status
|
||||
import com.tangem.utils.converter.Converter
|
||||
import com.tangem.utils.extensions.orZero
|
||||
import org.joda.time.DateTime
|
||||
|
||||
internal object CustomerInfoConverter : Converter<CustomerMeResponse.Result, CustomerInfo> {
|
||||
override fun convert(value: CustomerMeResponse.Result): CustomerInfo {
|
||||
|
|
@ -45,9 +48,37 @@ internal object CustomerInfoConverter : Converter<CustomerMeResponse.Result, Cus
|
|||
fiatBalance = fiatBalance?.toDomain(),
|
||||
cryptoBalance = cryptoBalance?.toDomain(),
|
||||
availableForWithdrawal = value.balance?.availableForWithdrawal?.amount.orZero(),
|
||||
tariffPlan = value.customerTariffPlan?.toDomain(),
|
||||
)
|
||||
}
|
||||
|
||||
private fun CustomerMeResponse.CustomerTariffPlan.toDomain(): TangemPayCustomerTariffPlan? {
|
||||
val plan = tariffPlan?.toDomain() ?: return null
|
||||
return TangemPayCustomerTariffPlan(
|
||||
status = TangemPayCustomerTariffPlan.Status.fromString(status),
|
||||
plan = plan,
|
||||
nextBillingAt = nextBillingAt.toDateTimeOrNull(),
|
||||
pendingPlan = pendingTariffPlan?.toDomain(),
|
||||
pendingTransitionAt = pendingTransitionAt.toDateTimeOrNull(),
|
||||
)
|
||||
}
|
||||
|
||||
private fun CustomerMeResponse.TariffPlan.toDomain(): TangemPayTariffPlan? {
|
||||
val name = name ?: return null
|
||||
return TangemPayTariffPlan(
|
||||
type = TangemPayTariffPlan.Type.fromString(type),
|
||||
name = name,
|
||||
descriptionItems = descriptionItems.orEmpty().map { it.toDomain() },
|
||||
)
|
||||
}
|
||||
|
||||
private fun CustomerMeResponse.DescriptionItem.toDomain() = TangemPayTariffPlan.DescriptionItem(
|
||||
section = TangemPayTariffPlan.Section.fromString(type),
|
||||
order = order ?: 0,
|
||||
title = title.orEmpty(),
|
||||
body = body.orEmpty(),
|
||||
)
|
||||
|
||||
private fun CustomerMeResponse.ProductInstance.toDomain(): ProductInstance {
|
||||
val status = status.toDomain()
|
||||
val cardFrozenState = when (status) {
|
||||
|
|
@ -116,4 +147,6 @@ internal object CustomerInfoConverter : Converter<CustomerMeResponse.Result, Cus
|
|||
CustomerMeResponse.ProductInstance.SpecificationDataType.ACCOUNT -> SpecificationDataType.ACCOUNT
|
||||
CustomerMeResponse.ProductInstance.SpecificationDataType.CARD -> SpecificationDataType.CARD
|
||||
}
|
||||
|
||||
private fun String?.toDateTimeOrNull(): DateTime? = this?.let { runCatching { DateTime.parse(it) }.getOrNull() }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue