Updated on 2026-08-14
This commit is contained in:
parent
1f6b9ac469
commit
5c5d891014
11 changed files with 62 additions and 67 deletions
|
|
@ -0,0 +1,46 @@
|
|||
package com.tangem.tap.domain.termsOfUse
|
||||
|
||||
import android.content.res.Resources
|
||||
import android.net.Uri
|
||||
import androidx.core.os.ConfigurationCompat
|
||||
import com.tangem.commands.common.card.Card
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class CardTou {
|
||||
private val locale: Locale = ConfigurationCompat.getLocales(Resources.getSystem().configuration).get(0)
|
||||
|
||||
fun getUrl(card: Card): Uri? {
|
||||
val issuerName = card.cardData?.issuerName ?: return null
|
||||
if (issuerName.toLowerCase() != "start2coin") return null
|
||||
|
||||
val baseUrl = "https://app.tangem.com/tou/"
|
||||
val regionCode = regionCode(card.cardId) ?: "fr"
|
||||
val filename = filename(locale.language, regionCode)
|
||||
return Uri.parse(baseUrl + filename)
|
||||
}
|
||||
|
||||
private fun filename(languageCode: String, regionCode: String): String {
|
||||
return when {
|
||||
languageCode == "fr" && regionCode == "ch" -> "Start2Coin-fr-ch-tangem.pdf"
|
||||
languageCode == "de" && regionCode == "ch" -> "Start2Coin-de-ch-tangem.pdf"
|
||||
languageCode == "en" && regionCode == "ch" -> "Start2Coin-en-ch-tangem.pdf"
|
||||
languageCode == "it" && regionCode == "ch" -> "Start2Coin-it-ch-tangem.pdf"
|
||||
languageCode == "fr" && regionCode == "fr" -> "Start2Coin-fr-fr-atangem.pdf"
|
||||
languageCode == "de" && regionCode == "at" -> "Start2Coin-de-at-tangem.pdf"
|
||||
languageCode.isEmpty() && regionCode == "fr" -> "Start2Coin-fr-fr-atangem.pdf"
|
||||
languageCode.isEmpty() && regionCode == "ch" -> "Start2Coin-en-ch-tangem.pdf"
|
||||
languageCode.isEmpty() && regionCode == "at" -> "Start2Coin-de-at-tangem.pdf"
|
||||
else -> "Start2Coin-fr-fr-atangem.pdf"
|
||||
}
|
||||
}
|
||||
|
||||
private fun regionCode(cardId: String): String? = when (cardId.substring(2..3)) {
|
||||
"0" -> "fr"
|
||||
"1" -> "ch"
|
||||
"2" -> "at"
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
package com.tangem.tap.domain.termsOfUse
|
||||
|
||||
import android.content.res.Resources
|
||||
import androidx.core.os.ConfigurationCompat
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class TermsOfUse {
|
||||
val locale: Locale = ConfigurationCompat.getLocales(Resources.getSystem().configuration).get(0)
|
||||
|
||||
fun getUrl(cardId: String): String? {
|
||||
val terms = CardTermsFactory.create(cardId) ?: return null
|
||||
|
||||
return terms.getUrl(locale.country)
|
||||
}
|
||||
}
|
||||
|
||||
class CardTermsOfUse(
|
||||
private val urlsByRegion: Map<String, String>,
|
||||
private val defaultRegion: String,
|
||||
) {
|
||||
|
||||
fun getUrl(region: String): String? {
|
||||
return urlsByRegion[region.toLowerCase()] ?: urlsByRegion[defaultRegion]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class CardTermsFactory {
|
||||
companion object {
|
||||
|
||||
fun create(cardId: String): CardTermsOfUse? {
|
||||
val batch = cardId.substring(0..3)
|
||||
|
||||
return when (batch) {
|
||||
"CB05" -> {
|
||||
CardTermsOfUse(
|
||||
mapOf(
|
||||
"ru" to "https://yandex.ru/",
|
||||
"en" to "https://www.google.com/",
|
||||
"fr" to "https://www.qwant.com",
|
||||
),
|
||||
"ru"
|
||||
)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue