Skip to content

Instantly share code, notes, and snippets.

@alibahaaa
Created June 25, 2022 14:13
Show Gist options
  • Save alibahaaa/41e07eac0538cdcf6b5c4e10431a753d to your computer and use it in GitHub Desktop.
Save alibahaaa/41e07eac0538cdcf6b5c4e10431a753d to your computer and use it in GitHub Desktop.
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