From 0f4324065265f8590388d1f0b98cca5763cbda7c Mon Sep 17 00:00:00 2001 From: Andreas Sagen Aspaas Date: Tue, 10 Dec 2024 10:46:14 +0100 Subject: [PATCH] fix: fix smtss response --- .../digitalisering/helsenett/SykmelderService.kt | 1 - .../digitalisering/helsenett/client/SmtssClient.kt | 14 ++++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/no/nav/sykdig/digitalisering/helsenett/SykmelderService.kt b/src/main/kotlin/no/nav/sykdig/digitalisering/helsenett/SykmelderService.kt index b89c9b8c..ca9ac024 100644 --- a/src/main/kotlin/no/nav/sykdig/digitalisering/helsenett/SykmelderService.kt +++ b/src/main/kotlin/no/nav/sykdig/digitalisering/helsenett/SykmelderService.kt @@ -5,7 +5,6 @@ import no.nav.sykdig.applog import no.nav.sykdig.digitalisering.exceptions.SykmelderNotFoundException import no.nav.sykdig.digitalisering.helsenett.client.HelsenettClient import no.nav.sykdig.digitalisering.helsenett.client.SmtssClient -import no.nav.sykdig.digitalisering.papirsykmelding.api.RegelClient import no.nav.sykdig.digitalisering.papirsykmelding.api.model.Godkjenning import no.nav.sykdig.digitalisering.papirsykmelding.api.model.Kode import no.nav.sykdig.digitalisering.papirsykmelding.api.model.Sykmelder diff --git a/src/main/kotlin/no/nav/sykdig/digitalisering/helsenett/client/SmtssClient.kt b/src/main/kotlin/no/nav/sykdig/digitalisering/helsenett/client/SmtssClient.kt index 0353ddf4..a0797b1e 100644 --- a/src/main/kotlin/no/nav/sykdig/digitalisering/helsenett/client/SmtssClient.kt +++ b/src/main/kotlin/no/nav/sykdig/digitalisering/helsenett/client/SmtssClient.kt @@ -37,10 +37,12 @@ class SmtssClient( smtssM2mRestTemplate.exchange( "$smtssUrl/api/v1/samhandler/infotrygd", HttpMethod.GET, - HttpEntity(headers), - String::class.java, + HttpEntity(headers), + TSSident::class.java, ) - if (response.statusCode.is2xxSuccessful) return response.body + if (response.statusCode.is2xxSuccessful) { + return response.body?.tssid ?: throw SykmelderNotFoundException("Samhandlerpraksis ikke funnet for samhandlerOrgname ${samhandlerOrgName}") + } log.info( "smtss responded with an error code {} for {}", response.statusCode, @@ -51,4 +53,8 @@ class SmtssClient( -} \ No newline at end of file +} + +data class TSSident( + val tssid: String, +)