Add SDK service contracts for core infrastructure.
Introduce interface-only service APIs and feature models for auth, device, settings, notifications, connectivity, and telemetry to scaffold implementation without backend-specific naming. Made-with: Cursor
This commit is contained in:
10
sdk/src/main/kotlin/org/db3/airmq/sdk/auth/AuthService.kt
Normal file
10
sdk/src/main/kotlin/org/db3/airmq/sdk/auth/AuthService.kt
Normal file
@@ -0,0 +1,10 @@
|
||||
package org.db3.airmq.sdk.auth
|
||||
|
||||
import org.db3.airmq.sdk.auth.model.Auth
|
||||
|
||||
interface AuthService {
|
||||
suspend fun getCurrentSession(): Auth?
|
||||
suspend fun isAuthenticated(): Boolean
|
||||
suspend fun signIn(provider: String, token: String? = null): Result<Auth>
|
||||
suspend fun signOut(): Result<Unit>
|
||||
}
|
||||
8
sdk/src/main/kotlin/org/db3/airmq/sdk/auth/model/Auth.kt
Normal file
8
sdk/src/main/kotlin/org/db3/airmq/sdk/auth/model/Auth.kt
Normal file
@@ -0,0 +1,8 @@
|
||||
package org.db3.airmq.sdk.auth.model
|
||||
|
||||
data class Auth(
|
||||
val userId: String,
|
||||
val email: String?,
|
||||
val displayName: String?,
|
||||
val isAuthenticated: Boolean
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.db3.airmq.sdk.connectivity
|
||||
|
||||
import org.db3.airmq.sdk.connectivity.model.Connectivity
|
||||
|
||||
interface ConnectivityService {
|
||||
suspend fun getConnectivity(): Connectivity
|
||||
suspend fun isInternetAvailable(): Boolean
|
||||
suspend fun scanNetworks(): List<String>
|
||||
suspend fun connect(ssid: String, password: String): Result<Unit>
|
||||
suspend fun disconnect(ssid: String): Result<Unit>
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package org.db3.airmq.sdk.connectivity.model
|
||||
|
||||
data class Connectivity(
|
||||
val isWifiEnabled: Boolean,
|
||||
val isConnected: Boolean,
|
||||
val connectedSsid: String?
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.db3.airmq.sdk.device
|
||||
|
||||
import org.db3.airmq.sdk.device.model.Device
|
||||
|
||||
interface DeviceService {
|
||||
suspend fun fetchDevices(): List<Device>
|
||||
suspend fun fetchDevice(deviceId: String): Device?
|
||||
suspend fun saveDevice(device: Device): Result<Device>
|
||||
suspend fun deleteDevice(deviceId: String): Result<Unit>
|
||||
suspend fun updateDeviceLocation(deviceId: String, latitude: Double, longitude: Double): Result<Unit>
|
||||
}
|
||||
10
sdk/src/main/kotlin/org/db3/airmq/sdk/device/model/Device.kt
Normal file
10
sdk/src/main/kotlin/org/db3/airmq/sdk/device/model/Device.kt
Normal file
@@ -0,0 +1,10 @@
|
||||
package org.db3.airmq.sdk.device.model
|
||||
|
||||
data class Device(
|
||||
val id: String,
|
||||
val name: String,
|
||||
val model: String?,
|
||||
val city: String?,
|
||||
val isOnline: Boolean,
|
||||
val lastSeenEpochMs: Long?
|
||||
)
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.db3.airmq.sdk.notifications
|
||||
|
||||
import org.db3.airmq.sdk.notifications.model.Notification
|
||||
|
||||
interface NotificationService {
|
||||
suspend fun fetchNotificationSettings(): Notification
|
||||
suspend fun updateNotificationSettings(settings: Notification): Result<Notification>
|
||||
suspend fun subscribeToTopic(topic: String): Result<Unit>
|
||||
suspend fun unsubscribeFromTopic(topic: String): Result<Unit>
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.db3.airmq.sdk.notifications.model
|
||||
|
||||
data class Notification(
|
||||
val deviceStatusEnabled: Boolean,
|
||||
val subscribedTopics: List<String>
|
||||
)
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.db3.airmq.sdk.settings
|
||||
|
||||
import org.db3.airmq.sdk.settings.model.Settings
|
||||
|
||||
interface SettingsService {
|
||||
suspend fun fetchSettings(): Settings
|
||||
suspend fun updateSettings(settings: Settings): Result<Settings>
|
||||
suspend fun setAdvancedEnabled(enabled: Boolean): Result<Unit>
|
||||
suspend fun setOfflineDevicesVisible(visible: Boolean): Result<Unit>
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.db3.airmq.sdk.settings.model
|
||||
|
||||
data class Settings(
|
||||
val city: String?,
|
||||
val showOfflineDevices: Boolean,
|
||||
val advancedEnabled: Boolean,
|
||||
val deviceStatusNotificationsEnabled: Boolean
|
||||
)
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.db3.airmq.sdk.telemetry
|
||||
|
||||
import org.db3.airmq.sdk.telemetry.model.Telemetry
|
||||
|
||||
interface TelemetryService {
|
||||
suspend fun fetchLatest(deviceId: String, metric: String): Telemetry?
|
||||
suspend fun fetchHistory(
|
||||
deviceId: String,
|
||||
metric: String,
|
||||
fromEpochMs: Long,
|
||||
toEpochMs: Long
|
||||
): List<Telemetry>
|
||||
|
||||
suspend fun fetchLatestForDevices(deviceIds: List<String>, metric: String): List<Telemetry>
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.db3.airmq.sdk.telemetry.model
|
||||
|
||||
data class Telemetry(
|
||||
val deviceId: String,
|
||||
val metric: String,
|
||||
val value: Double,
|
||||
val timestampEpochMs: Long
|
||||
)
|
||||
Reference in New Issue
Block a user