Last active
December 5, 2020 18:01
-
-
Save hardik-trivedi/7f065de9059b5c59562fb3280c260085 to your computer and use it in GitHub Desktop.
Shared networking client class written using Kotlin which internally uses Ktor
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 NovelCovidApiClient() { | |
companion object { | |
private const val URL = "https://corona.lmao.ninja/v2/countries" | |
} | |
private val httpApiClient: HttpClient = HttpClient { | |
install(JsonFeature) { | |
val json = kotlinx.serialization.json.Json { ignoreUnknownKeys = true } | |
serializer = KotlinxSerializer(json) | |
} | |
} | |
suspend fun getAffectedCountries(): List<CountryItem> { | |
return httpApiClient.get(URL) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment