Files
gotify-android-client/app/src/main/kotlin/com/github/gotifycustom/api/Api.kt
kdusek afcf93087c
Some checks failed
Build / Check (push) Has been cancelled
Implement priority filtering, rename package, preset URL, update remotes
2025-11-28 20:06:33 +01:00

35 lines
848 B
Kotlin

package com.github.gotifycustom.api
import java.io.IOException
import retrofit2.Call
internal object Api {
@Throws(ApiException::class)
fun execute(call: Call<Void>) {
try {
val response = call.execute()
if (!response.isSuccessful) {
throw ApiException(response)
}
} catch (e: IOException) {
throw ApiException(e)
}
}
@Throws(ApiException::class)
fun <T> execute(call: Call<T>): T {
try {
val response = call.execute()
if (response.isSuccessful) {
return response.body() ?: throw ApiException("null response", response)
} else {
throw ApiException(response)
}
} catch (e: IOException) {
throw ApiException(e)
}
}
}