request

open suspend fun request(client: HttpClient, authorization: String, decoder: Json = DEFAULT_JSON, postChecker: suspend (HttpResponse) -> Unit = {}): ApiResult

通过 client 执行网络请求并尝试得到结果。

Parameters

client

使用的 HttpClient 实例。

authorization

使用的鉴权值。注意,这里是完整的 Authorization 请求头中应当存在的内容,例如 Bot aaaabbbbccccdddd. 请参考 https://developer.kaiheila.cn/doc/reference#%E5%B8%B8%E8%A7%84%20http%20%E6%8E%A5%E5%8F%A3%E8%A7%84%E8%8C%83.

decoder

用于反序列化的 Json 实例。如果不提供则使用内部的默认值:

Json {
isLenient = true
ignoreUnknownKeys = true
}

可以通过重写 requestFinishingAction 来实现提供额外的收尾操作,例如为请求提供 body 等。

postChecker

当得到了 http response 之后的后置检查,可以用于提供部分自定义的响应值检查函数,例如进行速率限制检查。

Throws

当API速度达到上限的时候。检查需要通过 postChecker 进行实现支持。