Updated on 2026-08-14
This commit is contained in:
parent
9bfcf6376a
commit
aa996b6d22
3 changed files with 13 additions and 18 deletions
|
|
@ -13,11 +13,9 @@ data class CustomerMeResponse(
|
||||||
@Json(name = "id") val id: String,
|
@Json(name = "id") val id: String,
|
||||||
@Json(name = "state") val state: String,
|
@Json(name = "state") val state: String,
|
||||||
@Json(name = "created_at") val createdAt: String,
|
@Json(name = "created_at") val createdAt: String,
|
||||||
@Json(name = "product_instance") val productInstance: ProductInstance?,
|
|
||||||
@Json(name = "payment_account") val paymentAccount: PaymentAccount?,
|
@Json(name = "payment_account") val paymentAccount: PaymentAccount?,
|
||||||
@Json(name = "kyc") val kyc: Kyc?,
|
@Json(name = "kyc") val kyc: Kyc?,
|
||||||
@Json(name = "deposit_address") val depositAddress: String?,
|
@Json(name = "deposit_address") val depositAddress: String?,
|
||||||
@Json(name = "card") val card: Card?,
|
|
||||||
@Json(name = "balance") val balance: BalanceResponse?,
|
@Json(name = "balance") val balance: BalanceResponse?,
|
||||||
@Json(name = "product_instances") val productInstances: List<ProductInstance>,
|
@Json(name = "product_instances") val productInstances: List<ProductInstance>,
|
||||||
@Json(name = "cards") val cards: List<Card>,
|
@Json(name = "cards") val cards: List<Card>,
|
||||||
|
|
@ -156,9 +154,7 @@ data class CustomerMeResponse(
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class Card(
|
data class Card(
|
||||||
// Present in the multi-card `cards[]` array to join a card to its product instance;
|
@Json(name = "id") val id: String?,
|
||||||
// absent in the legacy single-card `card` object, where the card joins the single product instance.
|
|
||||||
@Json(name = "card_id") val cardId: String?,
|
|
||||||
@Json(name = "token") val token: String,
|
@Json(name = "token") val token: String,
|
||||||
@Json(name = "expiration_month") val expirationMonth: String,
|
@Json(name = "expiration_month") val expirationMonth: String,
|
||||||
@Json(name = "expiration_year") val expirationYear: String,
|
@Json(name = "expiration_year") val expirationYear: String,
|
||||||
|
|
|
||||||
|
|
@ -101,8 +101,11 @@ internal class DefaultOnboardingRepository @Inject constructor(
|
||||||
return requestHelper.performRequest(userWalletId) { authHeader -> tangemPayApi.getCustomerMe(authHeader) }
|
return requestHelper.performRequest(userWalletId) { authHeader -> tangemPayApi.getCustomerMe(authHeader) }
|
||||||
.flatMap { response ->
|
.flatMap { response ->
|
||||||
val result = response.result ?: return@flatMap VisaApiError.UnknownWithoutCode.left()
|
val result = response.result ?: return@flatMap VisaApiError.UnknownWithoutCode.left()
|
||||||
val status = result.productInstance?.status
|
val productInstances = result.productInstances
|
||||||
val isDeactivated = status == CustomerMeResponse.ProductInstance.Status.DEACTIVATED
|
|
||||||
|
val isDeactivated = productInstances.isNotEmpty() &&
|
||||||
|
productInstances.all { it.status == CustomerMeResponse.ProductInstance.Status.DEACTIVATED }
|
||||||
|
|
||||||
val isFormer = result.state.let { CustomerInfo.State.fromString(it) } == CustomerInfo.State.FORMER
|
val isFormer = result.state.let { CustomerInfo.State.fromString(it) } == CustomerInfo.State.FORMER
|
||||||
if (isDeactivated || isFormer) {
|
if (isDeactivated || isFormer) {
|
||||||
tangemPayStorage.storeIsTangemPayDeactivated(userWalletId)
|
tangemPayStorage.storeIsTangemPayDeactivated(userWalletId)
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,7 @@ internal object CustomerInfoConverter : Converter<CustomerMeResponse.Result, Cus
|
||||||
val cards = if (value.paymentAccount == null || value.balance == null) {
|
val cards = if (value.paymentAccount == null || value.balance == null) {
|
||||||
emptyList()
|
emptyList()
|
||||||
} else {
|
} else {
|
||||||
value.cards.mapIndexed { index, cardWire ->
|
value.cards.mapNotNull { it.toDomain() }
|
||||||
// Legacy single-card has no card_id on the card object → join to the single product instance.
|
|
||||||
val cardId = cardWire.cardId ?: value.productInstances.getOrNull(index)?.cardId.orEmpty()
|
|
||||||
buildCardInfo(cardId = cardId, card = cardWire)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return CustomerInfo(
|
return CustomerInfo(
|
||||||
|
|
@ -87,13 +83,13 @@ internal object CustomerInfoConverter : Converter<CustomerMeResponse.Result, Cus
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildCardInfo(cardId: String, card: CustomerMeResponse.Card): CardInfo {
|
private fun CustomerMeResponse.Card.toDomain(): CardInfo? {
|
||||||
return CardInfo(
|
return CardInfo(
|
||||||
cardId = cardId,
|
cardId = id ?: return null,
|
||||||
cardStatus = TangemPayCard.Status.fromString(card.cardStatus),
|
cardStatus = TangemPayCard.Status.fromString(cardStatus),
|
||||||
lastFourDigits = card.cardNumberEnd,
|
lastFourDigits = cardNumberEnd,
|
||||||
isPinSet = card.isPinSet == true,
|
isPinSet = isPinSet == true,
|
||||||
images = card.images.orEmpty().mapNotNull(::convertCardImage),
|
images = images.orEmpty().mapNotNull(::convertCardImage),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue