-
Notifications
You must be signed in to change notification settings - Fork 2
/
AMeldingInntektClient.kt
42 lines (36 loc) · 1.56 KB
/
AMeldingInntektClient.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package no.nav.familie.ef.sak.amelding.ekstern
import no.nav.familie.http.client.AbstractRestClient
import no.nav.familie.kontrakter.felles.PersonIdent
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.beans.factory.annotation.Value
import org.springframework.http.HttpHeaders
import org.springframework.http.MediaType
import org.springframework.stereotype.Component
import org.springframework.web.client.RestOperations
import org.springframework.web.util.UriComponentsBuilder
import java.net.URI
import java.time.YearMonth
@Component
class AMeldingInntektClient(
@Value("\${FAMILIE_EF_PROXY_URL}") private val uri: URI,
@Qualifier("azure") restOperations: RestOperations,
) : AbstractRestClient(restOperations, "inntekt") {
private fun lagInntektUri(fom: YearMonth, tom: YearMonth) =
UriComponentsBuilder.fromUri(uri).pathSegment("api/inntekt")
.queryParam("fom", fom)
.queryParam("tom", tom)
.build().toUri()
private val genererUrlUri = UriComponentsBuilder.fromUri(uri).pathSegment("api/ainntekt/generer-url").build().toUri()
fun hentInntekt(personIdent: String, fom: YearMonth, tom: YearMonth): HentInntektListeResponse {
return postForEntity(lagInntektUri(fom, tom), PersonIdent(personIdent))
}
fun genererAInntektUrl(personIdent: String): String {
return postForEntity(
genererUrlUri,
PersonIdent(personIdent),
HttpHeaders().apply {
accept = listOf(MediaType.TEXT_PLAIN)
},
)
}
}