Created
June 25, 2022 14:13
-
-
Save alibahaaa/41e07eac0538cdcf6b5c4e10431a753d to your computer and use it in GitHub Desktop.
This file contains 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
import io.ktor.client.* | |
import io.ktor.client.call.* | |
import io.ktor.client.request.* | |
import org.koin.core.component.KoinComponent | |
interface RemoteDatasource { | |
suspend fun fetchOrigami(): List<Entity> | |
} | |
class RemoteDatasourceImpl( | |
private val client: HttpClient | |
) : KoinComponent, RemoteDatasource { | |
override suspend fun fetchOrigami(): List<Entity> { | |
return try { | |
val response = client.get("https://kashkool.basalam.com/server_driven_ui/type6") | |
if (response.status.value == 200) | |
response.body() | |
else | |
listOf() | |
} catch (e: Exception) { | |
listOf() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment