commonMain.net.folivo.trixnity.clientserverapi.client.ServerApiClient.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of trixnity-clientserverapi-client Show documentation
Show all versions of trixnity-clientserverapi-client Show documentation
Multiplatform Kotlin SDK for matrix-protocol
package net.folivo.trixnity.clientserverapi.client
import net.folivo.trixnity.clientserverapi.model.server.GetCapabilities
import net.folivo.trixnity.clientserverapi.model.server.GetVersions
import net.folivo.trixnity.clientserverapi.model.server.Search
import net.folivo.trixnity.clientserverapi.model.server.WhoIs
import net.folivo.trixnity.core.model.UserId
interface ServerApiClient {
/**
* @see [GetVersions]
*/
suspend fun getVersions(): Result
/**
* @see [GetCapabilities]
*/
suspend fun getCapabilities(): Result
/**
* @see [Search]
*/
suspend fun search(
request: Search.Request,
nextBatch: String? = null,
asUserId: UserId? = null
): Result
/**
* @see [WhoIs]
*/
suspend fun whoIs(
userId: UserId,
asUserId: UserId? = null
): Result
}
class ServerApiClientImpl(private val httpClient: MatrixClientServerApiHttpClient) : ServerApiClient {
override suspend fun getVersions(): Result =
httpClient.request(GetVersions)
override suspend fun getCapabilities(): Result =
httpClient.request(GetCapabilities)
override suspend fun search(
request: Search.Request,
nextBatch: String?,
asUserId: UserId?
): Result =
httpClient.request(Search(nextBatch, asUserId), request)
override suspend fun whoIs(
userId: UserId,
asUserId: UserId?
): Result =
httpClient.request(WhoIs(userId, asUserId))
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy