Package-level declarations

Types

Link copied to clipboard
class ApiConfig(val url: String, val secure: Boolean = url.startsWith("https://"), val sessionToken: String)
Link copied to clipboard
class AsyncLazy<T>(initializer: suspend () -> T)

Shares an initialization attempt between callers and caches a successful result. Failed or cancelled attempts are reported to their callers; a later call can retry.

Link copied to clipboard
abstract class BaseApi(baseUrl: String, val defaultHeaders: Headers = HttpClient.EMPTY_HEADERS)

Base API class

Link copied to clipboard
object HttpClient
Link copied to clipboard
class HttpException(val method: HttpMethod, val url: String, val code: Int, val content: String) : Exception
Link copied to clipboard
Link copied to clipboard

Reports how much of a response body has been read.

Link copied to clipboard
data class RetryingJob<T : Any>(val stateFlow: StateFlow<RetryingJob.State<T>>, val producerJob: Job) : Record

Properties

Link copied to clipboard

The HttpException behind this. OkHttp hands one thrown by an interceptor of an async call on wrapped in an IOException.

Link copied to clipboard
val ioScope: CoroutineScope
Link copied to clipboard
val renderScope: CoroutineScope

Functions

Link copied to clipboard
fun String.asForm(): RequestBody
Link copied to clipboard
fun formatAvatarUrl(uuid: UUID?, username: String): String
Link copied to clipboard
fun Gson.makeRequestBody(data: Any?): RequestBody
Link copied to clipboard
inline fun <T> Response.parse(): T

Parse body from Response.

Link copied to clipboard
inline fun <T : Any> CoroutineScope.retrying(interval: Duration, name: String = "data", maxRetries: Int = Int.MAX_VALUE, start: CoroutineStart = CoroutineStart.DEFAULT, crossinline producer: suspend CoroutineScope.() -> T): RetryingJob<T>

Retries a suspending function producer up to maxRetries times with a delay of interval between each retry.

Link copied to clipboard
fun Response.toFile(file: File): Long

Save response body to file.

Link copied to clipboard
fun JsonElement.toRequestBody(gson: Gson = requestBodyGson): RequestBody
Link copied to clipboard
fun BufferedSource.utf8Lines(): Iterator<String>

Read all UTF-8 lines from BufferedSource as an Iterator.

Link copied to clipboard
fun withScope(block: suspend CoroutineScope.() -> Unit): Job