From 1a2939d9da7eaeb59ed5872f77b377947cd01323 Mon Sep 17 00:00:00 2001 From: Michael Shafrir <45020849+mshafrir-stripe@users.noreply.github.com> Date: Wed, 19 Aug 2020 09:27:31 -0400 Subject: [PATCH] Create LegacyCardAccountRangeRepository (#2741) A `CardAccountRangeRepository` that simulates existing card account range lookup logic by only using a local, static source. --- .../cards/LegacyCardAccountRangeRepository.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 stripe/src/main/java/com/stripe/android/cards/LegacyCardAccountRangeRepository.kt diff --git a/stripe/src/main/java/com/stripe/android/cards/LegacyCardAccountRangeRepository.kt b/stripe/src/main/java/com/stripe/android/cards/LegacyCardAccountRangeRepository.kt new file mode 100644 index 00000000000..829196b4ac6 --- /dev/null +++ b/stripe/src/main/java/com/stripe/android/cards/LegacyCardAccountRangeRepository.kt @@ -0,0 +1,17 @@ +package com.stripe.android.cards + +import com.stripe.android.model.CardMetadata + +/** + * A [CardAccountRangeRepository] that simulates existing card account range lookup logic by only + * using a local, static source. + */ +internal class LegacyCardAccountRangeRepository( + private val localCardAccountRangeSource: CardAccountRangeSource +) : CardAccountRangeRepository { + override suspend fun getAccountRange(cardNumber: String): CardMetadata.AccountRange? { + return Bin.create(cardNumber)?.let { + localCardAccountRangeSource.getAccountRange(cardNumber) + } + } +}