commonMain.net.folivo.trixnity.clientserverapi.client.DeviceApiClient.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.devices.*
import net.folivo.trixnity.core.model.UserId
interface DeviceApiClient {
/**
* @see [GetDevices]
*/
suspend fun getDevices(asUserId: UserId? = null): Result>
/**
* @see [GetDevice]
*/
suspend fun getDevice(deviceId: String, asUserId: UserId? = null): Result
/**
* @see [UpdateDevice]
*/
suspend fun updateDevice(
deviceId: String,
displayName: String,
asUserId: UserId? = null
): Result
/**
* @see [DeleteDevices]
*/
suspend fun deleteDevices(devices: List, asUserId: UserId? = null): Result>
/**
* @see [DeleteDevice]
*/
suspend fun deleteDevice(deviceId: String, asUserId: UserId? = null): Result>
}
class DeviceApiClientImpl(
private val httpClient: MatrixClientServerApiHttpClient
) : DeviceApiClient {
override suspend fun getDevices(asUserId: UserId?): Result> =
httpClient.request(GetDevices(asUserId)).map { it.devices }
override suspend fun getDevice(deviceId: String, asUserId: UserId?): Result =
httpClient.request(GetDevice(deviceId, asUserId))
override suspend fun updateDevice(
deviceId: String,
displayName: String,
asUserId: UserId?
): Result =
httpClient.request(UpdateDevice(deviceId, asUserId), UpdateDevice.Request(displayName))
override suspend fun deleteDevices(devices: List, asUserId: UserId?): Result> =
httpClient.uiaRequest(DeleteDevices(asUserId), DeleteDevices.Request(devices))
override suspend fun deleteDevice(deviceId: String, asUserId: UserId?): Result> =
httpClient.uiaRequest(DeleteDevice(deviceId, asUserId))
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy