-
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.
- Loading branch information
1 parent
edfc648
commit 4460ff7
Showing
14 changed files
with
121 additions
and
3 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
8 changes: 8 additions & 0 deletions
8
src/main/java/no/nav/veilarbperson/client/aiabackend/AiaBackendClient.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,8 @@ | ||
package no.nav.veilarbperson.client.aiabackend | ||
|
||
import no.nav.common.health.HealthCheck | ||
import okhttp3.Response | ||
|
||
interface AiaBackendClient : HealthCheck { | ||
fun hentEndringIRegistreringsdata(endringIRegistreringsdataRequestDTO: EndringIRegistreringsdataRequestDTO) : Response | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/no/nav/veilarbperson/client/aiabackend/AiaBackendClientImpl.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,37 @@ | ||
package no.nav.veilarbperson.client.aiabackend | ||
|
||
import lombok.SneakyThrows | ||
import no.nav.common.health.HealthCheckResult | ||
import no.nav.common.health.HealthCheckUtils | ||
import no.nav.common.rest.client.RestClient | ||
import no.nav.common.rest.client.RestUtils | ||
import no.nav.common.utils.UrlUtils.joinPaths | ||
import org.springframework.http.HttpHeaders.ACCEPT | ||
import org.springframework.http.MediaType.APPLICATION_JSON_VALUE | ||
import no.nav.veilarbperson.utils.toJson | ||
import okhttp3.OkHttpClient | ||
import okhttp3.Request | ||
import okhttp3.RequestBody.Companion.toRequestBody | ||
import okhttp3.Response | ||
import org.springframework.http.HttpHeaders | ||
import java.util.function.Supplier | ||
|
||
class AiaBackendClientImpl(private val aiaBackendUrl: String, private val userTokenSupplier: Supplier<String>) : AiaBackendClient { | ||
private val client: OkHttpClient = RestClient.baseClient() | ||
|
||
@SneakyThrows | ||
override fun hentEndringIRegistreringsdata(endringIRegistreringsdataRequestDTO: EndringIRegistreringsdataRequestDTO) : Response { | ||
val request = Request.Builder() | ||
.url(joinPaths(aiaBackendUrl, "/veileder/besvarelse")) | ||
.header(HttpHeaders.AUTHORIZATION, userTokenSupplier.get()) | ||
.header(ACCEPT, APPLICATION_JSON_VALUE) | ||
.post(endringIRegistreringsdataRequestDTO.toJson().toRequestBody(RestUtils.MEDIA_TYPE_JSON)) | ||
.build() | ||
|
||
return client.newCall(request).execute() | ||
} | ||
|
||
override fun checkHealth(): HealthCheckResult { | ||
return HealthCheckUtils.pingUrl(joinPaths(aiaBackendUrl, "/internal/isReady"), client) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/no/nav/veilarbperson/client/aiabackend/EndringIRegistreringsdataRequestDTO.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,5 @@ | ||
package no.nav.veilarbperson.client.aiabackend | ||
|
||
data class EndringIRegistreringsdataRequestDTO( | ||
val foedselsnummer: 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
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
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
3 changes: 1 addition & 2 deletions
3
...larbperson/client/regoppslag/JsonUtils.kt → ...a/no/nav/veilarbperson/utils/JsonUtils.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
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