This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class FirebaseDynamicLinkDataSource( | |
| private val host: String, | |
| private val firebaseDynamicLinks: FirebaseDynamicLinks, | |
| private val backgroundDispatcher: CoroutineDispatcher = Dispatchers.IO, | |
| ) { | |
| suspend fun parseLink(uri: String): String? = withContext(backgroundDispatcher) { | |
| if (uri.matchesPattern(host).not()) return@withContext null | |
| try { | |
| firebaseDynamicLinks.getDynamicLink(Uri.parse(uri)).await().link?.toString() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DynamicLinkDataRepository( | |
| private val dataSource: FirebaseDynamicLinkDataSource, | |
| ) : DynamicLinkRepository { | |
| override suspend fun parseLink(uri: String): String? { | |
| return dataSource.parseLink(uri) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface DynamicLinkRepository { | |
| suspend fun parseLink(uri: String): String? | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class GetDynamicLinkUseCase( | |
| private val dynamicLinkRepository: DynamicLinkRepository, | |
| ) { | |
| suspend operator fun invoke(uri: String): String? { | |
| return dynamicLinkRepository.parseLink(uri) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sealed class AppDeepLink: DeepLink { | |
| data object Unknown : AppDeepLink() | |
| data object Home : AppDeepLink() | |
| data class FareList(val ryderId: String) : AppDeepLink() | |
| data class Confirmation( | |
| val ryderId: String, | |
| val fare: Fare, | |
| ) : AppDeepLink() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AppDeepLinkLocalDataSource( | |
| private val backgroundDispatcher: CoroutineDispatcher = Dispatchers.IO, | |
| ) { | |
| companion object { | |
| private const val RYDER_ID = "ryderId" | |
| private const val PRICE = "price" | |
| const val HOME = "moove://app/home" | |
| const val FARE_LIST = "moove://app/fare_list" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DeeplinkDataRepository( | |
| private val localDataSource: AppDeepLinkLocalDataSource, | |
| ) : DeeplinkRepository { | |
| override suspend fun getDeepLink(uri: String): DeepLink { | |
| return localDataSource.getDeepLinkData(uri) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface DeepLink |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface DeeplinkRepository { | |
| suspend fun getDeepLink(uri: String): DeepLink | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class GetDeeplinkUseCase( | |
| private val deeplinkRepository: DeeplinkRepository, | |
| ) { | |
| suspend operator fun invoke(uri: String): DeepLink { | |
| val deepLink = deeplinkRepository.getDeepLink(parsedUri) | |
| return deepLink | |
| } | |
| } |