Kotlin SDK
Install and use the Misar.IO Kotlin SDK
Installation
Add to build.gradle.kts:
dependencies {
implementation("io.misar:misario-kotlin:1.0.0")
}
Quick Start
import io.misar.io.MisarIOClient
import io.misar.io.models.*
suspend fun main() {
val client = MisarIOClient(apiKey = System.getenv("MISARIO_API_KEY"))
val profile = client.account.get()
println("Hello, ${profile.displayName}!")
client.close()
}
Available Methods
| Method | Description |
|--------|-------------|
| client.account.get() | Get the current account profile |
| client.account.update(request) | Update account details |
| client.sessions.list() | List active sessions |
| client.sessions.revoke(id) | Revoke a session |
| client.keys.list() | List API keys |
| client.keys.create(request) | Create an API key |
| client.keys.revoke(id) | Revoke an API key |
| client.sso.token(request) | Generate a cross-TLD SSO token |
| client.close() | Close the HTTP client |
Error Handling
import io.misar.io.exceptions.*
try {
val profile = client.account.get()
println("Hello, ${profile.displayName}!")
} catch (e: MisarIOApiException) {
println("API error ${e.statusCode}: ${e.message}")
} catch (e: MisarIONetworkException) {
println("Network error: ${e.message}")
}