Implement priority filtering, rename package, preset URL, update remotes
Some checks failed
Build / Check (push) Has been cancelled
Some checks failed
Build / Check (push) Has been cancelled
This commit is contained in:
34
app/src/main/kotlin/com/github/gotifycustom/api/Api.kt
Normal file
34
app/src/main/kotlin/com/github/gotifycustom/api/Api.kt
Normal file
@@ -0,0 +1,34 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user