Skip to content

Commit 9cb59d6

Browse files
committed
Infotrygd POST
1 parent 4bef505 commit 9cb59d6

File tree

4 files changed

+65
-3
lines changed

4 files changed

+65
-3
lines changed

felles/util/src/main/java/no/nav/vedtak/konfig/Tid.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,12 @@ public class Tid {
1111
private Tid() {
1212
// hidden
1313
}
14-
}
14+
15+
public static LocalDate fomEllerBegynnelse(LocalDate fom) {
16+
return fom != null ? fom : TIDENES_BEGYNNELSE;
17+
}
18+
19+
public static LocalDate tomEllerEndetid(LocalDate tom) {
20+
return tom != null ? tom : TIDENES_ENDE;
21+
}
22+
}

integrasjon/infotrygd-grunnlag-klient/src/main/java/no/nav/vedtak/felles/integrasjon/infotrygd/grunnlag/AbstractInfotrygdGrunnlag.java

+25-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
import java.time.LocalDate;
44
import java.time.format.DateTimeFormatter;
5+
import java.util.Arrays;
56
import java.util.Collections;
67
import java.util.List;
78
import java.util.Optional;
89

9-
import jakarta.ws.rs.core.UriBuilder;
10-
1110
import org.slf4j.Logger;
1211
import org.slf4j.LoggerFactory;
1312

13+
import jakarta.ws.rs.core.UriBuilder;
1414
import no.nav.vedtak.exception.TekniskException;
1515
import no.nav.vedtak.felles.integrasjon.infotrygd.grunnlag.v1.respons.Grunnlag;
1616
import no.nav.vedtak.felles.integrasjon.rest.RestClient;
@@ -59,6 +59,29 @@ public List<Grunnlag> hentGrunnlagFailSoft(String fnr, LocalDate fom, LocalDate
5959
}
6060
}
6161

62+
@Override
63+
public List<Grunnlag> hentGrunnlag(GrunnlagRequest request) {
64+
try {
65+
var rrequest = RestRequest.newPOSTJson(request, restConfig.endpoint(), restConfig);
66+
var resultat = restClient.send(rrequest, Grunnlag[].class);
67+
return Arrays.asList(resultat);
68+
} catch (Exception e) {
69+
throw new TekniskException("FP-180125",
70+
String.format("Tjeneste %s gir feil, meld til #infotrygd_replikering hvis dette skjer gjennom lengre tidsperiode.",
71+
restConfig.endpoint()), e);
72+
}
73+
}
74+
75+
@Override
76+
public List<Grunnlag> hentGrunnlagFailSoft(GrunnlagRequest request) {
77+
try {
78+
return hentGrunnlag(request);
79+
} catch (Exception e) {
80+
LOG.warn("Feil ved oppslag mot {}, returnerer ingen grunnlag", restConfig.endpoint(), e);
81+
return Collections.emptyList();
82+
}
83+
}
84+
6285
private static String konverter(LocalDate dato) {
6386
var brukDato = Optional.ofNullable(dato).orElseGet(LocalDate::now);
6487
return brukDato.format(DateTimeFormatter.ISO_LOCAL_DATE);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package no.nav.vedtak.felles.integrasjon.infotrygd.grunnlag;
2+
3+
import java.time.LocalDate;
4+
import java.util.List;
5+
import java.util.Objects;
6+
7+
public record GrunnlagRequest(List<String> fnr, LocalDate fom, LocalDate tom) {
8+
9+
public GrunnlagRequest {
10+
if (fnr == null || fnr.isEmpty()) {
11+
throw new IllegalArgumentException("Ikke angitt fnr");
12+
}
13+
Objects.requireNonNull(fom);
14+
Objects.requireNonNull(tom);
15+
}
16+
17+
public GrunnlagRequest(String fnr, LocalDate fom, LocalDate tom) {
18+
this(List.of(fnr), fom, tom);
19+
}
20+
21+
}

integrasjon/infotrygd-grunnlag-klient/src/main/java/no/nav/vedtak/felles/integrasjon/infotrygd/grunnlag/InfotrygdGrunnlag.java

+10
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,18 @@
77

88
public interface InfotrygdGrunnlag {
99

10+
/*
11+
* Klassisk GET
12+
*/
1013
List<Grunnlag> hentGrunnlag(String fnr, LocalDate fom, LocalDate tom);
1114

1215
List<Grunnlag> hentGrunnlagFailSoft(String fnr, LocalDate fom, LocalDate tom);
1316

17+
/*
18+
* POST
19+
*/
20+
List<Grunnlag> hentGrunnlag(GrunnlagRequest request);
21+
22+
List<Grunnlag> hentGrunnlagFailSoft(GrunnlagRequest request);
23+
1424
}

0 commit comments

Comments
 (0)