fix(#201): fix platforms endpoint response shape mismatch
GET /api/messaging/platforms returns a JSON object with a platforms array inside, but the app expected a bare array. Wraps the response in a new MessagingPlatformResponse model. - Adds MessagingPlatformResponse.kt wrapper model - Updates HermesApiService.kt return type + adds profile query param - Updates ChannelsViewModel.kt to unwrap .platforms - Updates E2eIntegrationTest.kt mock to match new response shape
This commit is contained in:
1 parent
a89b932a0e
commit
35c608b2bf
4 files changed
+19
-4
No files matched your search
@@ -0,0 +1,7 @@
|
|||||||
|
package com.m57.hermescontrol.data.model
|
||||||
|
|
||||||
|
data class MessagingPlatformResponse(
|
||||||
|
val env_path: String,
|
||||||
|
val gateway_start_command: String,
|
||||||
|
val platforms: List<MessagingPlatform>,
|
||||||
|
)
|
||||||
@@ -16,7 +16,7 @@ import com.m57.hermescontrol.data.model.KanbanTask
|
|||||||
import com.m57.hermescontrol.data.model.LogResponse
|
import com.m57.hermescontrol.data.model.LogResponse
|
||||||
import com.m57.hermescontrol.data.model.McpServerToggleRequest
|
import com.m57.hermescontrol.data.model.McpServerToggleRequest
|
||||||
import com.m57.hermescontrol.data.model.McpServersResponse
|
import com.m57.hermescontrol.data.model.McpServersResponse
|
||||||
import com.m57.hermescontrol.data.model.MessagingPlatform
|
import com.m57.hermescontrol.data.model.MessagingPlatformResponse
|
||||||
import com.m57.hermescontrol.data.model.MessagingPlatformUpdate
|
import com.m57.hermescontrol.data.model.MessagingPlatformUpdate
|
||||||
import com.m57.hermescontrol.data.model.ModelOptionsResponse
|
import com.m57.hermescontrol.data.model.ModelOptionsResponse
|
||||||
import com.m57.hermescontrol.data.model.PairingApproveRequest
|
import com.m57.hermescontrol.data.model.PairingApproveRequest
|
||||||
@@ -253,7 +253,7 @@ interface HermesApiService {
|
|||||||
): Response<Unit>
|
): Response<Unit>
|
||||||
|
|
||||||
@GET("api/messaging/platforms")
|
@GET("api/messaging/platforms")
|
||||||
suspend fun getMessagingPlatforms(): Response<List<MessagingPlatform>>
|
suspend fun getMessagingPlatforms(@Query("profile") profile: String? = null): Response<MessagingPlatformResponse>
|
||||||
|
|
||||||
@PUT("api/messaging/platforms/{platform_id}")
|
@PUT("api/messaging/platforms/{platform_id}")
|
||||||
suspend fun configurePlatform(
|
suspend fun configurePlatform(
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class ChannelsViewModel : ViewModel() {
|
|||||||
}
|
}
|
||||||
when (result) {
|
when (result) {
|
||||||
is NetworkResult.Success -> {
|
is NetworkResult.Success -> {
|
||||||
_uiState.update { it.copy(isLoading = false, platforms = result.data.orEmpty()) }
|
_uiState.update { it.copy(isLoading = false, platforms = result.data?.platforms.orEmpty()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
is NetworkResult.Failure -> {
|
is NetworkResult.Failure -> {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import com.m57.hermescontrol.data.model.KanbanColumn
|
|||||||
import com.m57.hermescontrol.data.model.KanbanTask
|
import com.m57.hermescontrol.data.model.KanbanTask
|
||||||
import com.m57.hermescontrol.data.model.LogResponse
|
import com.m57.hermescontrol.data.model.LogResponse
|
||||||
import com.m57.hermescontrol.data.model.MessagingPlatform
|
import com.m57.hermescontrol.data.model.MessagingPlatform
|
||||||
|
import com.m57.hermescontrol.data.model.MessagingPlatformResponse
|
||||||
import com.m57.hermescontrol.data.model.ModelOptionsResponse
|
import com.m57.hermescontrol.data.model.ModelOptionsResponse
|
||||||
import com.m57.hermescontrol.data.model.ModelProvider
|
import com.m57.hermescontrol.data.model.ModelProvider
|
||||||
import com.m57.hermescontrol.data.model.PluginInfo
|
import com.m57.hermescontrol.data.model.PluginInfo
|
||||||
@@ -895,7 +896,14 @@ class E2eIntegrationTest {
|
|||||||
fun testChannelsConfiguration_success() =
|
fun testChannelsConfiguration_success() =
|
||||||
runTest {
|
runTest {
|
||||||
val platform = MessagingPlatform("telegram", "Telegram", false, false, emptyList())
|
val platform = MessagingPlatform("telegram", "Telegram", false, false, emptyList())
|
||||||
coEvery { mockApiService.getMessagingPlatforms() } returns Response.success(listOf(platform))
|
coEvery { mockApiService.getMessagingPlatforms() } returns
|
||||||
|
Response.success(
|
||||||
|
MessagingPlatformResponse(
|
||||||
|
env_path = "/tmp/.env",
|
||||||
|
gateway_start_command = "hermes gateway start",
|
||||||
|
platforms = listOf(platform),
|
||||||
|
),
|
||||||
|
)
|
||||||
coEvery { mockApiService.configurePlatform("telegram", any()) } returns Response.success(Unit)
|
coEvery { mockApiService.configurePlatform("telegram", any()) } returns Response.success(Unit)
|
||||||
|
|
||||||
val viewModel = ChannelsViewModel()
|
val viewModel = ChannelsViewModel()
|
||||||
|
|||||||
Reference in new issue
Block a user