diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/onramp/MockedOnrampApi.kt b/core/datasource/src/main/java/com/tangem/datasource/api/onramp/MockedOnrampApi.kt new file mode 100644 index 0000000000..a960766de8 --- /dev/null +++ b/core/datasource/src/main/java/com/tangem/datasource/api/onramp/MockedOnrampApi.kt @@ -0,0 +1,178 @@ +package com.tangem.datasource.api.onramp + +import com.tangem.datasource.api.common.response.ApiResponse +import com.tangem.datasource.api.onramp.models.common.OnrampDestinationDTO +import com.tangem.datasource.api.onramp.models.request.OnrampPairsRequest +import com.tangem.datasource.api.onramp.models.response.OnrampDataResponse +import com.tangem.datasource.api.onramp.models.response.OnrampQuoteResponse +import com.tangem.datasource.api.onramp.models.response.OnrampStatusResponse +import com.tangem.datasource.api.onramp.models.response.model.OnrampCountryDTO +import com.tangem.datasource.api.onramp.models.response.model.OnrampCurrencyDTO +import com.tangem.datasource.api.onramp.models.response.model.OnrampPairDTO +import com.tangem.datasource.api.onramp.models.response.model.PaymentMethodDTO + +internal class MockedOnrampApi : OnrampApi { + override suspend fun getCurrencies(): ApiResponse> = ApiResponse.Success( + COUNTRIES.map(OnrampCountryDTO::defaultCurrency), + ) + + override suspend fun getCountries(): ApiResponse> = ApiResponse.Success(COUNTRIES + RUSSIA) + + override suspend fun getCountryByIp(): ApiResponse = ApiResponse.Success(RUSSIA) + + override suspend fun getPaymentMethods(): ApiResponse> = ApiResponse.Success( + listOf( + PaymentMethodDTO(id = "google", name = "Google Play", image = ""), + PaymentMethodDTO(id = "apple", name = "Apple Pay", image = ""), + PaymentMethodDTO(id = "card", name = "Card", image = ""), + ), + ) + + override suspend fun getPairs(body: OnrampPairsRequest): ApiResponse> = ApiResponse.Success( + listOf( + OnrampPairDTO( + fromCurrencyCode = "USD", + to = OnrampDestinationDTO(contractAddress = "0xcontract_address", network = "ethereum"), + providers = listOf(), + ), + ), + ) + + override suspend fun getQuote( + fromCurrencyCode: String, + toContractAddress: String, + toNetwork: String, + paymentMethod: String, + countryCode: String, + fromAmount: String, + toDecimals: Int, + providerId: String, + ): ApiResponse { + TODO("Not yet implemented") + } + + override suspend fun getData( + fromCurrencyCode: String, + toContractAddress: String, + toNetwork: String, + paymentMethod: String, + countryCode: String, + fromAmount: String, + toDecimals: Int, + providerId: String, + toAddress: String, + redirectUrl: String, + language: String?, + theme: String?, + requestId: String, + ): ApiResponse { + TODO("Not yet implemented") + } + + override suspend fun getStatus(txId: String): ApiResponse { + TODO("Not yet implemented") + } + + private companion object { + private val RUSSIA = OnrampCountryDTO( + name = "Russia", + code = "RU", + image = "https://hatscripts.github.io/circle-flags/flags/ru.svg", + alpha3 = "RUS", + continent = "", + defaultCurrency = OnrampCurrencyDTO( + name = "Russian ruble", + code = "RUB", + image = "https://hatscripts.github.io/circle-flags/flags/ru.svg", + precision = 2, + ), + onrampAvailable = false, + ) + private val COUNTRIES = listOf( + OnrampCountryDTO( + name = "United States of America", + code = "USA", + image = "https://hatscripts.github.io/circle-flags/flags/us.svg", + alpha3 = "USA", + continent = "", + defaultCurrency = OnrampCurrencyDTO( + name = "US Dollar", + code = "USD", + image = "https://hatscripts.github.io/circle-flags/flags/us.svg", + precision = 2, + ), + onrampAvailable = true, + ), + OnrampCountryDTO( + name = "Europe Union", + code = "EU", + image = "https://hatscripts.github.io/circle-flags/flags/eu.svg", + alpha3 = "EUR", + continent = "", + defaultCurrency = OnrampCurrencyDTO( + name = "Euro", + code = "EUR", + image = "https://hatscripts.github.io/circle-flags/flags/eu.svg", + precision = 2, + ), + onrampAvailable = true, + ), + OnrampCountryDTO( + name = "Great Britain", + code = "GB", + image = "https://hatscripts.github.io/circle-flags/flags/gb.svg", + alpha3 = "GB", + continent = "", + defaultCurrency = OnrampCurrencyDTO( + name = "British Pound Sterling", + code = "GBP", + image = "https://hatscripts.github.io/circle-flags/flags/gb.svg", + precision = 2, + ), + onrampAvailable = true, + ), + OnrampCountryDTO( + name = "CANADA", + code = "CA", + image = "https://hatscripts.github.io/circle-flags/flags/ca.svg", + alpha3 = "CA", + continent = "", + defaultCurrency = OnrampCurrencyDTO( + name = "Canadian Dollar", + code = "CAD", + image = "https://hatscripts.github.io/circle-flags/flags/ca.svg", + precision = 2, + ), + onrampAvailable = true, + ), + OnrampCountryDTO( + name = "Hon Kong", + code = "HK", + image = "https://hatscripts.github.io/circle-flags/flags/hk.svg", + alpha3 = "HK", + continent = "", + defaultCurrency = OnrampCurrencyDTO( + name = "Hon Kong Dollar", + code = "HKD", + image = "https://hatscripts.github.io/circle-flags/flags/hk.svg", + precision = 2, + ), + onrampAvailable = true, + ), + OnrampCountryDTO( + name = "Australia", + code = "AU", + image = "https://hatscripts.github.io/circle-flags/flags/au.svg", + alpha3 = "AU", + continent = "", + defaultCurrency = OnrampCurrencyDTO( + name = "Australian Dollar", + code = "AUD", + image = "https://hatscripts.github.io/circle-flags/flags/au.svg", + precision = 2, + ), + onrampAvailable = true, + ), + ) + } +} \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/di/NetworkModule.kt b/core/datasource/src/main/java/com/tangem/datasource/di/NetworkModule.kt index 8b38ca983a..720e14ac0b 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/di/NetworkModule.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/di/NetworkModule.kt @@ -11,6 +11,7 @@ import com.tangem.datasource.api.common.config.managers.ProdApiConfigsManager import com.tangem.datasource.api.common.response.ApiResponseCallAdapterFactory import com.tangem.datasource.api.express.TangemExpressApi import com.tangem.datasource.api.markets.TangemTechMarketsApi +import com.tangem.datasource.api.onramp.MockedOnrampApi import com.tangem.datasource.api.onramp.OnrampApi import com.tangem.datasource.api.stakekit.StakeKitApi import com.tangem.datasource.api.tangemTech.TangemTechApi @@ -98,22 +99,24 @@ internal object NetworkModule { @Provides @Singleton fun provideOnrampApi( - @NetworkMoshi moshi: Moshi, - @ApplicationContext context: Context, - apiConfigsManager: ApiConfigsManager, - appLogsStore: AppLogsStore, + // @NetworkMoshi moshi: Moshi, + // @ApplicationContext context: Context, + // apiConfigsManager: ApiConfigsManager, + // appLogsStore: AppLogsStore, ): OnrampApi { - return createApi( - id = ApiConfig.ID.Express, - moshi = moshi, - context = context, - apiConfigsManager = apiConfigsManager, - clientBuilder = { - addInterceptor( - NetworkLogsSaveInterceptor(appLogsStore), - ) - }, - ) + // TODO: Remove when backend will be ready - [REDACTED_TASK_KEY] + return MockedOnrampApi() + // return createApi( + // id = ApiConfig.ID.Express, + // moshi = moshi, + // context = context, + // apiConfigsManager = apiConfigsManager, + // clientBuilder = { + // addInterceptor( + // NetworkLogsSaveInterceptor(appLogsStore), + // ) + // }, + // ) } @Provides