Skip to content

Commit

Permalink
add network client and repository
Browse files Browse the repository at this point in the history
  • Loading branch information
asterixorobelix committed Aug 10, 2024
1 parent a61e819 commit e33293f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package asterixorobelix.afrikaburn.di

import asterixorobelix.afrikaburn.network.NetworkClient
import asterixorobelix.afrikaburn.repository.AfrikaburnRepository
import io.ktor.client.HttpClient
import org.koin.dsl.module

val commonModule = module {

single { NetworkClient(HttpClient()) }
single { AfrikaburnRepository(get<NetworkClient>()) }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package asterixorobelix.afrikaburn.network

import io.ktor.client.HttpClient
import io.ktor.client.request.get
import io.ktor.client.statement.HttpResponse

class NetworkClient(private val ktorClient: HttpClient) {

suspend fun getAfrikaburnInfo(): HttpResponse {
return ktorClient.get("https://www.jsonkeeper.com/b/99ON")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package asterixorobelix.afrikaburn.repository

import asterixorobelix.afrikaburn.network.NetworkClient

class AfrikaburnRepository(private val networkClient: NetworkClient) {

suspend fun retrieveAfrikaburnInfo() = networkClient.getAfrikaburnInfo()
}

0 comments on commit e33293f

Please sign in to comment.