Updated on 2026-08-14
This commit is contained in:
parent
8aa7bf9b75
commit
4032360f13
34 changed files with 679 additions and 101 deletions
|
|
@ -1,19 +1,28 @@
|
|||
package com.tangem.domain.pay.model
|
||||
|
||||
import java.math.BigDecimal
|
||||
|
||||
private const val APPROVED_KYC_STATUS = "APPROVED"
|
||||
private const val ACTIVE_PI_STATUS = "active"
|
||||
|
||||
data class CustomerInfo(
|
||||
val productInstance: ProductInstance?,
|
||||
val kycStatus: String?,
|
||||
val cardInfo: CardInfo?,
|
||||
) {
|
||||
|
||||
data class ProductInstance(
|
||||
val id: String,
|
||||
val status: String,
|
||||
)
|
||||
|
||||
data class CardInfo(
|
||||
val lastFourDigits: String,
|
||||
val balance: BigDecimal,
|
||||
val currencyCode: String,
|
||||
)
|
||||
|
||||
fun isKycApproved() = kycStatus == APPROVED_KYC_STATUS
|
||||
|
||||
fun isProductInstanceActive() = productInstance?.status == ACTIVE_PI_STATUS
|
||||
}
|
||||
|
||||
data class ProductInstance(
|
||||
val id: String,
|
||||
val status: String,
|
||||
)
|
||||
}
|
||||
|
|
@ -9,4 +9,9 @@ interface OnboardingRepository {
|
|||
suspend fun validateDeeplink(link: String): Either<UniversalError, Boolean>
|
||||
|
||||
suspend fun getCustomerInfo(): Either<UniversalError, CustomerInfo>
|
||||
|
||||
/**
|
||||
* Returns only if the user already authorised at least once
|
||||
*/
|
||||
suspend fun getMainScreenCustomerInfo(): Either<UniversalError, CustomerInfo>
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.tangem.domain.pay.usecase
|
||||
|
||||
import com.tangem.domain.pay.model.CustomerInfo
|
||||
import com.tangem.domain.pay.repository.OnboardingRepository
|
||||
|
||||
/**
|
||||
* Returns tangem pay customer info for the main screen banner
|
||||
* Works only if the user already authorised at least once (won't emit anything otherwise)
|
||||
*/
|
||||
class TangemPayMainScreenCustomerInfoUseCase(
|
||||
private val repository: OnboardingRepository,
|
||||
) {
|
||||
|
||||
suspend operator fun invoke(): CustomerInfo? = repository.getMainScreenCustomerInfo().getOrNull()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue