Skip to content

Commit

Permalink
Infotrygd POST (#1347)
Browse files Browse the repository at this point in the history
* Infotrygd POST

* Fjerne appservicehandler
  • Loading branch information
jolarsen authored Mar 1, 2024
1 parent 4bef505 commit e0510e5
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 17 deletions.

This file was deleted.

10 changes: 9 additions & 1 deletion felles/util/src/main/java/no/nav/vedtak/konfig/Tid.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@ public class Tid {
private Tid() {
// hidden
}
}

public static LocalDate fomEllerBegynnelse(LocalDate fom) {
return fom != null ? fom : TIDENES_BEGYNNELSE;
}

public static LocalDate tomEllerEndetid(LocalDate tom) {
return tom != null ? tom : TIDENES_ENDE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

import jakarta.ws.rs.core.UriBuilder;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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

@Override
public List<Grunnlag> hentGrunnlag(GrunnlagRequest request) {
try {
var rrequest = RestRequest.newPOSTJson(request, restConfig.endpoint(), restConfig);
var resultat = restClient.send(rrequest, Grunnlag[].class);
return Arrays.asList(resultat);
} catch (Exception e) {
throw new TekniskException("FP-180125",
String.format("Tjeneste %s gir feil, meld til #infotrygd_replikering hvis dette skjer gjennom lengre tidsperiode.",
restConfig.endpoint()), e);
}
}

@Override
public List<Grunnlag> hentGrunnlagFailSoft(GrunnlagRequest request) {
try {
return hentGrunnlag(request);
} catch (Exception e) {
LOG.warn("Feil ved oppslag mot {}, returnerer ingen grunnlag", restConfig.endpoint(), e);
return Collections.emptyList();
}
}

private static String konverter(LocalDate dato) {
var brukDato = Optional.ofNullable(dato).orElseGet(LocalDate::now);
return brukDato.format(DateTimeFormatter.ISO_LOCAL_DATE);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package no.nav.vedtak.felles.integrasjon.infotrygd.grunnlag;

import java.time.LocalDate;
import java.util.List;
import java.util.Objects;

public record GrunnlagRequest(List<String> fnr, LocalDate fom, LocalDate tom) {

public GrunnlagRequest {
if (fnr == null || fnr.isEmpty()) {
throw new IllegalArgumentException("Ikke angitt fnr");
}
Objects.requireNonNull(fom);
Objects.requireNonNull(tom);
}

public GrunnlagRequest(String fnr, LocalDate fom, LocalDate tom) {
this(List.of(fnr), fom, tom);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@

public interface InfotrygdGrunnlag {

/*
* Klassisk GET
*/
List<Grunnlag> hentGrunnlag(String fnr, LocalDate fom, LocalDate tom);

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

/*
* POST
*/
List<Grunnlag> hentGrunnlag(GrunnlagRequest request);

List<Grunnlag> hentGrunnlagFailSoft(GrunnlagRequest request);

}

0 comments on commit e0510e5

Please sign in to comment.