Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spøkelse POST isf GET #1363

Merged
merged 1 commit into from
May 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@

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

import jakarta.ws.rs.core.UriBuilder;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -52,12 +48,14 @@ public List<SykepengeVedtak> hentGrunnlag(String fnr, LocalDate fom) {

@Override
public List<SykepengeVedtak> hentGrunnlag(String fnr, LocalDate fom, Duration timeout) {
if (fnr == null || fnr.isEmpty()) {
throw new IllegalArgumentException("Ikke angitt fnr");
}
try {
var pathBuilder = UriBuilder.fromUri(restConfig.endpoint()).queryParam("fodselsnummer", fnr);
Optional.ofNullable(fom).ifPresent(f -> pathBuilder.queryParam("fom", f.format(DateTimeFormatter.ISO_LOCAL_DATE)));
var request = RestRequest.newGET(pathBuilder.build(), restConfig).timeout(timeout);
var grunnlag = restKlient.send(request, SykepengeVedtak[].class);
return Arrays.asList(grunnlag);
var request = new GrunnlagRequest(fnr, fom);
var rrequest = RestRequest.newPOSTJson(request, restConfig.endpoint(), restConfig);
var resultat = restKlient.send(rrequest, SykepengeVedtak[].class);
return Arrays.asList(resultat);
} catch (Exception e) {
throw new TekniskException("FP-180126",
String.format("SPokelse %s gir feil, ta opp med team sykepenger.", restConfig.endpoint().toString()), e);
Expand All @@ -78,4 +76,6 @@ public List<SykepengeVedtak> hentGrunnlagFailSoft(String fnr, LocalDate fom) {
return List.of();
}
}

public record GrunnlagRequest(String fodselsnummer, LocalDate fom) { }
}