Initial commit

- Retrofit used to call API
This commit is contained in:
2024-07-18 17:04:56 +01:00
commit 982b4e8d5d
20 changed files with 534 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
import kotlinx.coroutines.runBlocking
import retrofit2.Response
import java.io.IOException
abstract class NetworkTests {
fun <T : Any> responseUnwrap(
call: suspend () -> Response<T>
): T {
val response = runBlocking { call.invoke() }
if (response.isSuccessful) {
return response.body()!!
} else {
val error = response.errorBody()?.string()
throw IOException(error ?: "Unable to handle end point")
}
}
}