From 44c31fa0d5615297ec823f6c6cf2277f3199074a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Sun, 24 Mar 2024 20:05:29 +0100 Subject: [PATCH] Handle case when message details response body is null --- .../wulkanowy/sdk/scrapper/repository/MessagesRepository.kt | 2 +- .../io/github/wulkanowy/sdk/scrapper/service/MessagesService.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/repository/MessagesRepository.kt b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/repository/MessagesRepository.kt index bdf50d03..4ba24ce3 100644 --- a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/repository/MessagesRepository.kt +++ b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/repository/MessagesRepository.kt @@ -88,7 +88,7 @@ internal class MessagesRepository( } suspend fun getMessageDetails(globalKey: String, markAsRead: Boolean): MessageDetails { - val details = api.getMessageDetails(globalKey) + val details = api.getMessageDetails(globalKey) ?: error("Message not exist") if (markAsRead) { runCatching { loginModule() diff --git a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/service/MessagesService.kt b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/service/MessagesService.kt index d6a15e52..2393886c 100644 --- a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/service/MessagesService.kt +++ b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/service/MessagesService.kt @@ -75,7 +75,7 @@ internal interface MessagesService { ): List @GET("api/WiadomoscSzczegoly") - suspend fun getMessageDetails(@Query("apiGlobalKey") globalKey: String): MessageDetails + suspend fun getMessageDetails(@Query("apiGlobalKey") globalKey: String): MessageDetails? @PUT("api/WiadomoscSzczegoly") suspend fun markMessageAsRead(@Body body: Map)