Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Install ktlint
uses: nbadal/action-ktlint-setup@v1
with:
ktlint_version: '1.0.0'
ktlint_version: '1.3.1'
- name: Ktlint
run: ktlint src/**/*.kt
shell: bash
Expand Down
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ import com.expediagroup.graphql.plugin.gradle.tasks.GraphQLGenerateClientTask
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer

val ktor_version = "2.3.12"
val ktor_version = "3.0.1"
val kotlin_version = "2.0.21"
val kotlinx_datetime_version = "0.6.1"
val kompendium_version = "3.14.4"
val kompendium_version = "4.0.1"
val logback_version = "1.5.12"
val logstash_version = "8.0"
val prometeus_version = "1.6.3"
val nav_common_version = "3.2024.10.25_13.44-9db48a0dbe67"
val tjenestespec_version = "1.2021.02.22-10.45-4201aaea72fb"
val modia_common_utils_version = "1.2023.07.20-13.43-64707e48b53b"
val modia_common_utils_version = "1.2024.10.30-08.17-f565fe211cd4"
val junit_version = "5.11.3"
val graphql_kotlin_version = "8.2.1"

plugins {
application
kotlin("jvm") version "2.0.21"
id("org.jetbrains.kotlin.plugin.serialization") version "2.0.21"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("com.gradleup.shadow") version "8.3.4"
id("com.expediagroup.graphql") version "8.2.1"
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/no/nav/Consumers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ interface Consumers {
val sfClient: SFClient
}

class ConsumersImpl(env: Env) : Consumers {
class ConsumersImpl(
env: Env,
) : Consumers {
override val oboTokenClient: OnBehalfOfTokenClient =
AzureAdTokenClientBuilder
.builder()
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/no/nav/Services.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ interface Services {
val utbetalingerService: UtbetalingerService
}

class ServicesImpl(consumers: Consumers) : Services {
class ServicesImpl(
consumers: Consumers,
) : Services {
override val oppfolgingService =
OppfolgingService(
consumers.oppfolgingClient,
Expand Down
11 changes: 7 additions & 4 deletions src/main/kotlin/no/nav/api/debug/DebugRoutes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package no.nav.api.debug

import io.bkbn.kompendium.core.metadata.PostInfo
import io.bkbn.kompendium.core.plugin.NotarizedRoute
import io.bkbn.kompendium.oas.payload.MediaType
import io.ktor.http.*
import io.ktor.server.application.*
import io.ktor.server.request.*
Expand Down Expand Up @@ -62,10 +63,12 @@ private object Api {
examples(
Pair(
"example",
TokenExchangeRequest(
cluster = "dev-fss",
namespace = "teamname",
application = "app-api",
MediaType.Example(
TokenExchangeRequest(
cluster = "dev-fss",
namespace = "teamname",
application = "app-api",
),
),
),
)
Expand Down
5 changes: 2 additions & 3 deletions src/main/kotlin/no/nav/api/dialog/saf/SafClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class SafClient(
suspend fun hentBrukersSaker(
fnr: String,
token: String,
): GraphQLClientResponse<HentBrukerssaker.Result> {
return externalServiceCall {
): GraphQLClientResponse<HentBrukerssaker.Result> =
externalServiceCall {
graphqlClient.execute(
request =
HentBrukerssaker(
Expand All @@ -46,5 +46,4 @@ class SafClient(
},
)
}
}
}
5 changes: 2 additions & 3 deletions src/main/kotlin/no/nav/api/dialog/saf/SafService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ class SafService(
suspend fun hentBrukersSaker(
fnr: String,
token: String,
): List<Sak> {
return safClient
): List<Sak> =
safClient
.hentBrukersSaker(fnr, token)
.data
?.saker
?.filterNotNull()
?: emptyList()
}
}
38 changes: 21 additions & 17 deletions src/main/kotlin/no/nav/api/dialog/sf/SFClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,25 @@ class SFClient(
}

@Serializable
data class HenvendelseDTO(val kjedeId: String)
data class HenvendelseDTO(
val kjedeId: String,
)

suspend fun sendSporsmal(
request: SfMeldingRequest,
ident: String,
token: String,
): HenvendelseDTO =
externalServiceCall {
client.post("$sfUrl/henvendelse/ny/melding") {
headers {
append("Nav-Ident", ident)
}
header("Authorization", "Bearer ${oboTokenProvider.exchangeOnBehalfOfToken(token)}")
contentType(ContentType.Application.Json)
setBody(request)
}.body()
client
.post("$sfUrl/henvendelse/ny/melding") {
headers {
append("Nav-Ident", ident)
}
header("Authorization", "Bearer ${oboTokenProvider.exchangeOnBehalfOfToken(token)}")
contentType(ContentType.Application.Json)
setBody(request)
}.body()
}

suspend fun sendInfomelding(
Expand All @@ -52,14 +55,15 @@ class SFClient(
token: String,
): HenvendelseDTO =
externalServiceCall {
client.post("$sfUrl/henvendelse/ny/melding") {
headers {
append("Nav-Ident", ident)
}
header("Authorization", "Bearer ${oboTokenProvider.exchangeOnBehalfOfToken(token)}")
contentType(ContentType.Application.Json)
setBody(request)
}.body()
client
.post("$sfUrl/henvendelse/ny/melding") {
headers {
append("Nav-Ident", ident)
}
header("Authorization", "Bearer ${oboTokenProvider.exchangeOnBehalfOfToken(token)}")
contentType(ContentType.Application.Json)
setBody(request)
}.body()
}

suspend fun journalforMelding(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ object TemagruppeTemaMapping {
"HJE" to Temagruppe.HJLPM.name,
)

fun hentTemagruppeForTema(tema: String): String {
return if (TEMA_TEMAGRUPPE_MAPPING[tema] == null) TEMA_UTEN_TEMAGRUPPE.name else TEMA_TEMAGRUPPE_MAPPING[tema]!!
}
fun hentTemagruppeForTema(tema: String): String =
if (TEMA_TEMAGRUPPE_MAPPING[tema] == null) TEMA_UTEN_TEMAGRUPPE.name else TEMA_TEMAGRUPPE_MAPPING[tema]!!
}
22 changes: 12 additions & 10 deletions src/main/kotlin/no/nav/api/digdir/DigdirClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,21 @@ class DigdirClient(
token: String,
): KrrData =
externalServiceCall {
client.get("$digdirKrrProxyUrl/rest/v1/person") {
headers {
append("Nav-Personident", fnr)
append("Nav-Call-Id", getCallId())
}
header("Authorization", "Bearer ${oboTokenProvider.exchangeOnBehalfOfToken(token)}")
}.body()
client
.get("$digdirKrrProxyUrl/rest/v1/person") {
headers {
append("Nav-Personident", fnr)
append("Nav-Call-Id", getCallId())
}
header("Authorization", "Bearer ${oboTokenProvider.exchangeOnBehalfOfToken(token)}")
}.body()
}

suspend fun ping() =
externalServiceCall {
client.get("$digdirKrrProxyUrl/rest/ping") {
header("Authorization", "Bearer ${tokenclient.createMachineToMachineToken()}")
}.status
client
.get("$digdirKrrProxyUrl/rest/ping") {
header("Authorization", "Bearer ${tokenclient.createMachineToMachineToken()}")
}.status
}
}
4 changes: 3 additions & 1 deletion src/main/kotlin/no/nav/api/digdir/DigdirService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import no.nav.personoversikt.common.utils.SelftestGenerator
import kotlin.concurrent.fixedRateTimer
import kotlin.time.Duration.Companion.minutes

class DigdirService(private val digdirClient: DigdirClient) {
class DigdirService(
private val digdirClient: DigdirClient,
) {
private val reporter = SelftestGenerator.Reporter(name = "DigdirService", critical = false)

init {
Expand Down
19 changes: 10 additions & 9 deletions src/main/kotlin/no/nav/api/kontonummer/KontonummerRegister.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ class KontonummerRegister(
token: String,
): Kontonummer =
externalServiceCall {
client.post("$kontonummerRegisterUrl/rest/v1/hent-aktiv-konto") {
headers {
append("Nav-Ident", ident)
append("Nav-Call-Id", getCallId())
}
header("Authorization", "Bearer ${oboTokenProvider.exchangeOnBehalfOfToken(token)}")
contentType(ContentType.Application.Json)
setBody(HentAktivKontoDTO(fnr))
}.body()
client
.post("$kontonummerRegisterUrl/rest/v1/hent-aktiv-konto") {
headers {
append("Nav-Ident", ident)
append("Nav-Call-Id", getCallId())
}
header("Authorization", "Bearer ${oboTokenProvider.exchangeOnBehalfOfToken(token)}")
contentType(ContentType.Application.Json)
setBody(HentAktivKontoDTO(fnr))
}.body()
}
}
3 changes: 1 addition & 2 deletions src/main/kotlin/no/nav/api/oppfolging/Nom.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class Nom(
name = "nom",
callIdExtractor = { getCallId() },
),
)
.build()
).build()

val client: NomClient =
if (isNotProd()) {
Expand Down
15 changes: 10 additions & 5 deletions src/main/kotlin/no/nav/api/oppfolging/OppfolgingClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ class OppfolgingClient(
private val oboTokenProvider: BoundedOnBehalfOfTokenClient,
) {
@Serializable
class Status(val erUnderOppfolging: Boolean?)
class Status(
val erUnderOppfolging: Boolean?,
)

@Serializable
class VeilederIdent(val veilederIdent: String?)
class VeilederIdent(
val veilederIdent: String?,
)

private val client =
HttpClient(OkHttp) {
Expand Down Expand Up @@ -44,9 +48,10 @@ class OppfolgingClient(
token: String,
): Status =
externalServiceCall {
client.get("$oppfolgingUrl/v2/oppfolging?fnr=$fnr") {
header("Authorization", "Bearer ${oboTokenProvider.exchangeOnBehalfOfToken(token)}")
}.body()
client
.get("$oppfolgingUrl/v2/oppfolging?fnr=$fnr") {
header("Authorization", "Bearer ${oboTokenProvider.exchangeOnBehalfOfToken(token)}")
}.body()
}

suspend fun hentOppfolgingVeileder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class OppfolgingService(
): Veileder? =
externalServiceCall {
val veileder = oppfolgingClient.hentOppfolgingVeileder(fnr, token)
veileder?.veilederIdent
veileder
?.veilederIdent
?.let { nom.finnNavn(NavIdent(it)) }
?.let {
Veileder(
Expand Down
15 changes: 6 additions & 9 deletions src/main/kotlin/no/nav/api/pdl/PdlClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,19 @@ class PdlClient(
suspend fun hentPersonalia(
fnr: String,
token: String,
): GraphQLClientResponse<HentPersonalia.Result> {
return externalServiceCall {
): GraphQLClientResponse<HentPersonalia.Result> =
externalServiceCall {
graphqlClient.execute(
request = HentPersonalia(HentPersonalia.Variables(fnr)),
requestCustomizer = requestConfig(token),
)
}
}

suspend fun hentAktorid(
fnr: String,
token: String,
): GraphQLClientResponse<HentAktorid.Result> {
return externalServiceCall {
): GraphQLClientResponse<HentAktorid.Result> =
externalServiceCall {
graphqlClient.execute(
request =
HentAktorid(
Expand All @@ -60,17 +59,15 @@ class PdlClient(
requestCustomizer = requestConfig(token),
)
}
}

suspend fun hentNavn(
fnr: String,
token: String,
): GraphQLClientResponse<HentNavn.Result> {
return externalServiceCall {
): GraphQLClientResponse<HentNavn.Result> =
externalServiceCall {
graphqlClient.execute(
request = HentNavn(HentNavn.Variables(fnr)),
requestCustomizer = requestConfig(token),
)
}
}
}
Loading