Skip to content

Commit

Permalink
ryddet i PDL-klienten
Browse files Browse the repository at this point in the history
  • Loading branch information
jankroken-nav committed Oct 30, 2024
1 parent 547a0a0 commit 0dc34d3
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 74 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
package no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.external.pdl

class IdentHistorikk(
private val identer: Set<Ident.FolkeregisterIdent>
private val identer: Set<PdlIdent.FolkeregisterPdlIdent>
) {
fun gjeldende(): Ident.FolkeregisterIdent {
return identer.singleOrNull { it is Ident.FolkeregisterIdent.Gjeldende }
fun gjeldende(): PdlIdent.FolkeregisterPdlIdent {
return identer.singleOrNull { it is PdlIdent.FolkeregisterPdlIdent.Gjeldende }
?: throw IdentHistorikkManglerGjeldendeException()
}

fun historikk(): Set<Ident.FolkeregisterIdent> {
fun historikk(): Set<PdlIdent.FolkeregisterPdlIdent> {
return identer
}

fun identifiseresAv(ident: String): Boolean {
return identer.map { it.ident }.contains(ident)
}

class IdentHistorikkManglerGjeldendeException(msg: String = "Fant ingen gjeldende identer i identhistorikk") :
RuntimeException(msg)
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.external.pdl

internal class PdlException(
pdlError: PdlError?
) : RuntimeException(pdlError?.message ?: "Unknown error from PDL") {
val code: PdlErrorCode? = pdlError?.extensions?.code
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.external.pdl

sealed class Ident {
sealed class PdlIdent {
abstract val ident: String

sealed class FolkeregisterIdent : Ident() {
sealed class FolkeregisterPdlIdent : PdlIdent() {

data class Gjeldende(
override val ident: String
) : FolkeregisterIdent()
) : FolkeregisterPdlIdent()

data class Historisk(
override val ident: String
) : FolkeregisterIdent()
) : FolkeregisterPdlIdent()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ data class HentPersonQueryResponse(
map {
when (it.status) {
Folkeregisteridentifikator.Status.I_BRUK -> {
Ident.FolkeregisterIdent.Gjeldende(it.identifikasjonsnummer)
PdlIdent.FolkeregisterPdlIdent.Gjeldende(it.identifikasjonsnummer)
}

Folkeregisteridentifikator.Status.OPPHOERT -> {
Ident.FolkeregisterIdent.Historisk(it.identifikasjonsnummer)
PdlIdent.FolkeregisterPdlIdent.Historisk(it.identifikasjonsnummer)
}
}
}.toSet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,3 @@ class PdlService(
}
}

internal class PdlException(pdlError: PdlError?) : RuntimeException(pdlError?.message ?: "Unknown error from PDL") {
val code: PdlErrorCode? = pdlError?.extensions?.code
}

This file was deleted.

0 comments on commit 0dc34d3

Please sign in to comment.