-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Første utkast til API for bestilling av brev
Inkludert integrasjon mot brev-sanity-proxy
- Loading branch information
1 parent
d130690
commit fc81dea
Showing
18 changed files
with
209 additions
and
32 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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
app/src/main/kotlin/no/nav/aap/brev/api/BestillBrevRequest.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,11 @@ | ||
package no.nav.aap.brev.api | ||
|
||
import no.nav.aap.brev.domene.BehandlingReferanse | ||
import no.nav.aap.brev.domene.Brevtype | ||
import no.nav.aap.brev.domene.Språk | ||
|
||
data class BestillBrevRequest( | ||
val behandlingReferanse: BehandlingReferanse, | ||
val brevtype: Brevtype, | ||
val language: Språk, | ||
) |
6 changes: 6 additions & 0 deletions
6
app/src/main/kotlin/no/nav/aap/brev/api/BestillBrevResponse.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,6 @@ | ||
package no.nav.aap.brev.api | ||
|
||
import no.nav.aap.brev.domene.BrevbestillingReferanse | ||
|
||
|
||
data class BestillBrevResponse(val brevbestillingReferanse: BrevbestillingReferanse) |
2 changes: 1 addition & 1 deletion
2
...in/kotlin/no/nav/aap/brev/ErrorRespons.kt → ...otlin/no/nav/aap/brev/api/ErrorRespons.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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package no.nav.aap.brev | ||
package no.nav.aap.brev.api | ||
|
||
data class ErrorRespons(val message: String?) |
4 changes: 4 additions & 0 deletions
4
app/src/main/kotlin/no/nav/aap/brev/domene/BehandlingReferanse.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,4 @@ | ||
package no.nav.aap.brev.domene | ||
|
||
@JvmInline | ||
value class BehandlingReferanse(val referanse: String) |
6 changes: 6 additions & 0 deletions
6
app/src/main/kotlin/no/nav/aap/brev/domene/BrevbestillingReferanse.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,6 @@ | ||
package no.nav.aap.brev.domene | ||
|
||
import java.util.UUID | ||
|
||
@JvmInline | ||
value class BrevbestillingReferanse(val referanse: UUID) |
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,3 @@ | ||
package no.nav.aap.brev.domene | ||
|
||
data class Brevinnhold(val innhold: String) |
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,6 @@ | ||
package no.nav.aap.brev.domene | ||
|
||
enum class Brevtype { | ||
INNVILGELSE, | ||
AVSLAG, | ||
} |
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,5 @@ | ||
package no.nav.aap.brev.domene | ||
|
||
enum class Språk { | ||
EN, NB, NN | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/kotlin/no/nav/aap/brev/innhold/BrevinnholdGateway.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,9 @@ | ||
package no.nav.aap.brev.innhold | ||
|
||
import no.nav.aap.brev.domene.Brevinnhold | ||
import no.nav.aap.brev.domene.Brevtype | ||
import no.nav.aap.brev.domene.Språk | ||
|
||
interface BrevinnholdGateway { | ||
fun hentBrev(brevtype: Brevtype, språk: Språk): Brevinnhold | ||
} |
21 changes: 21 additions & 0 deletions
21
app/src/main/kotlin/no/nav/aap/brev/innhold/BrevinnholdService.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,21 @@ | ||
package no.nav.aap.brev.innhold | ||
|
||
import no.nav.aap.brev.domene.BehandlingReferanse | ||
import no.nav.aap.brev.domene.Brevtype | ||
import no.nav.aap.brev.domene.Språk | ||
import org.slf4j.LoggerFactory | ||
|
||
class BrevinnholdService(private val brevinnholdGateway: BrevinnholdGateway) { | ||
|
||
private val log = LoggerFactory.getLogger(BrevinnholdService::class.java) | ||
|
||
fun behandleBrevbestilling( | ||
behandlingReferanse: BehandlingReferanse, | ||
brevtype: Brevtype, | ||
språk: Språk, | ||
) { | ||
log.info("Henter brevinnhold for behandlingReferanse=$behandlingReferanse brevtype=$brevtype språk=$språk") | ||
val brevinnhold = brevinnholdGateway.hentBrev(brevtype, språk) | ||
log.info("Hentet brevinnhold: ${brevinnhold.innhold}") | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
app/src/main/kotlin/no/nav/aap/brev/innhold/SanityBrevinnholdGateway.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,39 @@ | ||
package no.nav.aap.brev.innhold | ||
|
||
import no.nav.aap.brev.domene.Brevinnhold | ||
import no.nav.aap.brev.domene.Brevtype | ||
import no.nav.aap.brev.domene.Språk | ||
import no.nav.aap.komponenter.config.requiredConfigForKey | ||
import no.nav.aap.komponenter.httpklient.httpclient.ClientConfig | ||
import no.nav.aap.komponenter.httpklient.httpclient.Header | ||
import no.nav.aap.komponenter.httpklient.httpclient.RestClient | ||
import no.nav.aap.komponenter.httpklient.httpclient.request.GetRequest | ||
import no.nav.aap.komponenter.httpklient.httpclient.tokenprovider.azurecc.ClientCredentialsTokenProvider | ||
import no.nav.aap.komponenter.httpklient.json.DefaultJsonMapper | ||
import java.net.URI | ||
|
||
class SanityBrevinnholdGateway : BrevinnholdGateway { | ||
|
||
private val baseUri = URI.create(requiredConfigForKey("integrasjon.brev_sanity_proxy.url")) | ||
val config = ClientConfig(scope = requiredConfigForKey("integrasjon.brev_sanity_proxy.scope")) | ||
private val client = RestClient.withDefaultResponseHandler( | ||
config = config, | ||
tokenProvider = ClientCredentialsTokenProvider | ||
) | ||
|
||
override fun hentBrev( | ||
brevtype: Brevtype, | ||
språk: Språk | ||
): Brevinnhold { | ||
val uri = baseUri.resolve("/api/brev?brevtype=$brevtype&language=$språk") | ||
val httpRequest = GetRequest( | ||
additionalHeaders = listOf( | ||
Header("Accept", "application/json") | ||
) | ||
) | ||
|
||
return requireNotNull(client.get(uri = uri, request = httpRequest, mapper = { body, _ -> | ||
DefaultJsonMapper.fromJson(body) | ||
})) | ||
} | ||
} |
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
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