Updated on 2026-08-14
This commit is contained in:
parent
fd018a73f9
commit
faf6c2e31f
1 changed files with 9 additions and 5 deletions
|
|
@ -67,12 +67,16 @@ class GetOnrampOffersUseCase(
|
|||
}
|
||||
|
||||
private fun findRecentOffer(offers: List<OnrampOffer>, transactions: List<OnrampTransaction>): OnrampOffer? {
|
||||
val lastTransaction = transactions.maxByOrNull { it.timestamp } ?: return null
|
||||
|
||||
return offers.find { offer ->
|
||||
offer.quote.provider.info.name == lastTransaction.providerName &&
|
||||
offer.quote.paymentMethod.name == lastTransaction.paymentMethod && isRecentUsed(lastTransaction.status)
|
||||
if (transactions.isEmpty()) return null
|
||||
val matchingPairs = transactions.mapNotNull { transaction ->
|
||||
if (!isRecentUsed(transaction.status)) return@mapNotNull null
|
||||
val matchingOffer = offers.find { offer ->
|
||||
offer.quote.provider.info.name == transaction.providerName &&
|
||||
offer.quote.paymentMethod.name == transaction.paymentMethod
|
||||
}
|
||||
matchingOffer?.let { it to transaction }
|
||||
}
|
||||
return matchingPairs.maxByOrNull { (_, transaction) -> transaction.timestamp }?.first
|
||||
}
|
||||
|
||||
private fun findBestRateOffer(offers: List<OnrampOffer>, isGooglePayAvailable: Boolean): OnrampOffer? {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue