All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.eu.codlab.tcgmapper.GithubDefinitions.kt Maven / Gradle / Ivy

The newest version!
package eu.codlab.tcgmapper

import io.ktor.client.request.get
import io.ktor.client.statement.bodyAsText
import io.ktor.http.isSuccess
import korlibs.io.lang.FileNotFoundException

internal object GithubDefinitions {
    suspend fun dataFileContent(
        githubGroup: String,
        githubRepo: String,
        version: String,
        file: String
    ): String {
        val prefix = "https://raw.githubusercontent.com"
        val url = "$prefix/$githubGroup/$githubRepo/$version/data/$file.yml"

        val request = Provider.client.get(url)

        if (!request.status.isSuccess()) {
            throw FileNotFoundException("Impossible to find the file $file for version $version")
        }

        return request.bodyAsText()
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy