Updated on 2026-08-14
This commit is contained in:
parent
3b6eeb7535
commit
8b677a8e6b
25 changed files with 1149 additions and 17 deletions
|
|
@ -6,9 +6,11 @@ import java.util.Locale
|
|||
|
||||
@Serializable
|
||||
data class TangemPayTariffPlan(
|
||||
@SerialName("id") val id: String,
|
||||
@SerialName("type") val type: Type,
|
||||
@SerialName("name") val name: String,
|
||||
@SerialName("description_items") val descriptionItems: List<DescriptionItem>,
|
||||
@SerialName("images") val images: List<Image> = emptyList(),
|
||||
) {
|
||||
@Serializable
|
||||
data class DescriptionItem(
|
||||
|
|
@ -18,6 +20,37 @@ data class TangemPayTariffPlan(
|
|||
@SerialName("body") val body: String,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Image(
|
||||
@SerialName("type") val type: Type,
|
||||
@SerialName("url") val url: String,
|
||||
) {
|
||||
@Serializable
|
||||
enum class Type {
|
||||
@SerialName("THUMBNAIL")
|
||||
THUMBNAIL,
|
||||
|
||||
@SerialName("MAIN")
|
||||
MAIN,
|
||||
|
||||
@SerialName("BANNER")
|
||||
BANNER,
|
||||
|
||||
@SerialName("UNKNOWN")
|
||||
UNKNOWN,
|
||||
;
|
||||
|
||||
companion object {
|
||||
fun fromString(value: String?) = when (value?.uppercase(Locale.US)) {
|
||||
"THUMBNAIL" -> THUMBNAIL
|
||||
"MAIN" -> MAIN
|
||||
"BANNER" -> BANNER
|
||||
else -> UNKNOWN
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
enum class Type {
|
||||
@SerialName("BASIC")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
package com.tangem.domain.models.account
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import java.util.Locale
|
||||
|
||||
@Serializable
|
||||
data class TangemPayTariffPlanTransition(
|
||||
@SerialName("type") val type: Type,
|
||||
@SerialName("tariff_plan") val plan: TangemPayTariffPlan,
|
||||
) {
|
||||
|
||||
@Serializable
|
||||
enum class Type {
|
||||
@SerialName("UPGRADE")
|
||||
UPGRADE,
|
||||
|
||||
@SerialName("DOWNGRADE")
|
||||
DOWNGRADE,
|
||||
|
||||
@SerialName("SYSTEM_DOWNGRADE")
|
||||
SYSTEM_DOWNGRADE,
|
||||
|
||||
@SerialName("ACTIVATION")
|
||||
ACTIVATION,
|
||||
|
||||
@SerialName("UNKNOWN")
|
||||
UNKNOWN,
|
||||
;
|
||||
|
||||
companion object {
|
||||
fun fromString(value: String?) = when (value?.uppercase(Locale.US)) {
|
||||
"UPGRADE" -> UPGRADE
|
||||
"DOWNGRADE" -> DOWNGRADE
|
||||
"SYSTEM_DOWNGRADE" -> SYSTEM_DOWNGRADE
|
||||
"ACTIVATION" -> ACTIVATION
|
||||
else -> UNKNOWN
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.tangem.domain.pay.repository
|
||||
|
||||
import arrow.core.Either
|
||||
import com.tangem.domain.models.account.TangemPayTariffPlanTransition
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.visa.error.VisaApiError
|
||||
|
||||
interface TangemPayTariffPlanTransitionsRepository {
|
||||
|
||||
suspend fun getTransitions(userWalletId: UserWalletId): Either<VisaApiError, List<TangemPayTariffPlanTransition>>
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.tangem.domain.pay.usecase
|
||||
|
||||
import arrow.core.Either
|
||||
import com.tangem.domain.models.account.TangemPayTariffPlanTransition
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.pay.repository.TangemPayTariffPlanTransitionsRepository
|
||||
import com.tangem.domain.visa.error.VisaApiError
|
||||
|
||||
class GetTangemPayTariffPlanTransitionsUseCase(
|
||||
private val repository: TangemPayTariffPlanTransitionsRepository,
|
||||
) {
|
||||
suspend operator fun invoke(
|
||||
userWalletId: UserWalletId,
|
||||
): Either<VisaApiError, List<TangemPayTariffPlanTransition>> = repository.getTransitions(userWalletId)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue