-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Nytt endepunkt for å hente aktive varsler
- Loading branch information
1 parent
92fec65
commit a193641
Showing
8 changed files
with
147 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 0 additions & 78 deletions
78
src/main/kotlin/no/nav/tms/varsel/api/varsel/alleVarsler.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package no.nav.tms.varsel.api.varsel.v2 | ||
|
||
import no.nav.tms.varsel.api.varsel.VarselAuthority | ||
import no.nav.tms.varsel.api.varsel.VarselType | ||
import java.time.ZonedDateTime | ||
|
||
data class Varsel( | ||
@Deprecated("Use varselId") val eventId: String, | ||
@Deprecated("Use tidspunkt") val forstBehandlet: ZonedDateTime, | ||
val isMasked: Boolean, | ||
val spraakkode: String?, | ||
val tekst: String?, | ||
val link: String?, | ||
val eksternVarslingSendt: Boolean, | ||
val eksternVarslingKanaler: List<String>, | ||
val type: VarselType, | ||
val isInaktiverbar: Boolean, | ||
|
||
) { | ||
companion object { | ||
fun fromVarsel(varsel: VarselAuthority.Varsel): Varsel { | ||
val isMasked = varsel.innhold == null | ||
val isInaktivertOppgave = varsel.type == VarselType.oppgave && !varsel.aktiv | ||
|
||
return Varsel( | ||
eventId = varsel.varselId, | ||
forstBehandlet = varsel.opprettet, | ||
isMasked = isMasked, | ||
spraakkode = varsel.innhold?.spraakkode, | ||
tekst = varsel.innhold?.tekst, | ||
link = if (isInaktivertOppgave) null else varsel.innhold?.link, | ||
eksternVarslingSendt = varsel.eksternVarslingSendt, | ||
eksternVarslingKanaler = varsel.eksternVarslingKanaler, | ||
type = if (varsel.type == VarselType.oppgave) VarselType.oppgave else VarselType.beskjed, | ||
isInaktiverbar = varsel.type == VarselType.beskjed && varsel.aktiv && !isMasked, | ||
) | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/kotlin/no/nav/tms/varsel/api/varsel/v2/aktiveVarsler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package no.nav.tms.varsel.api.varsel.v2 | ||
|
||
import no.nav.tms.varsel.api.varsel.VarselAuthority | ||
import no.nav.tms.varsel.api.varsel.VarselType | ||
|
||
|
||
data class AktiveVarslerV2(val beskjeder: List<Varsel>, val oppgaver: List<Varsel>) { | ||
companion object { | ||
fun fromVarsler(varsler: List<VarselAuthority.Varsel>): AktiveVarslerV2 { | ||
val beskjeder = mutableListOf<Varsel>() | ||
val oppgaver = mutableListOf<Varsel>() | ||
|
||
varsler.map { | ||
if (it.type == VarselType.oppgave) { | ||
oppgaver.add(Varsel.fromVarsel(it)) | ||
} else { | ||
beskjeder.add(Varsel.fromVarsel(it)) | ||
} | ||
} | ||
return AktiveVarslerV2(beskjeder = beskjeder, oppgaver = oppgaver) | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/kotlin/no/nav/tms/varsel/api/varsel/v2/alleVarsler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package no.nav.tms.varsel.api.varsel.v2 | ||
|
||
import no.nav.tms.varsel.api.varsel.VarselAuthority | ||
import no.nav.tms.varsel.api.varsel.VarselType | ||
|
||
data class AlleVarsler( | ||
val hasMaskedVarsel: Boolean, | ||
val aktive: AktiveVarslerV2, | ||
val inaktive: List<Varsel>, | ||
) { | ||
companion object { | ||
fun fromVarsler(varsler: List<VarselAuthority.Varsel>): AlleVarsler { | ||
val aktivBeskjeder = mutableListOf<Varsel>() | ||
val aktivOppgaver = mutableListOf<Varsel>() | ||
val inaktivtVarseler = mutableListOf<Varsel>() | ||
var hasMaskedVarsel = false | ||
|
||
varsler.map { | ||
if(it.innhold == null) { | ||
hasMaskedVarsel = true | ||
} | ||
|
||
if (it.aktiv) { | ||
if (it.type == VarselType.oppgave) { | ||
aktivOppgaver.add(Varsel.fromVarsel(it)) | ||
} else { | ||
aktivBeskjeder.add(Varsel.fromVarsel(it)) | ||
} | ||
} else { | ||
inaktivtVarseler.add(Varsel.fromVarsel(it)) | ||
} | ||
} | ||
return AlleVarsler( | ||
hasMaskedVarsel = hasMaskedVarsel, | ||
aktive = AktiveVarslerV2(aktivBeskjeder, aktivOppgaver), | ||
inaktive = inaktivtVarseler | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/test/kotlin/no/nav/tms/varsel/api/varsel/AlleVarslerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters