-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for fetching pension decisions #deploy-test-dolly-backend
Introduced `PensjonHentVedtakCommand` to fetch pension decisions and integrated it into `PensjonforvalterClient` and `PensjonforvalterConsumer`. Also added a new method in `TransaksjonMappingRepository` and `TransaksjonMappingService` for deleting records by ident, environment, and system.
- Loading branch information
Showing
6 changed files
with
126 additions
and
24 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
58 changes: 58 additions & 0 deletions
58
.../main/java/no/nav/dolly/bestilling/pensjonforvalter/command/PensjonHentVedtakCommand.java
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,58 @@ | ||
package no.nav.dolly.bestilling.pensjonforvalter.command; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonVedtakResponse; | ||
import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; | ||
import no.nav.testnav.libs.securitycore.config.UserConstant; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.Mono; | ||
import reactor.util.retry.Retry; | ||
|
||
import java.time.Duration; | ||
import java.util.concurrent.Callable; | ||
|
||
import static no.nav.dolly.domain.CommonKeysAndUtils.CONSUMER; | ||
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CALL_ID; | ||
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CONSUMER_ID; | ||
import static no.nav.dolly.util.CallIdUtil.generateCallId; | ||
import static no.nav.dolly.util.TokenXUtil.getUserJwt; | ||
import static org.springframework.http.HttpHeaders.AUTHORIZATION; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class PensjonHentVedtakCommand implements Callable<Flux<PensjonVedtakResponse>> { | ||
|
||
private static final String VEDTAK_URL = "/api/v2/vedtak"; | ||
|
||
private final WebClient webClient; | ||
private final String ident; | ||
private final String miljoe; | ||
private final String token; | ||
|
||
@Override | ||
public Flux<PensjonVedtakResponse> call() { | ||
|
||
var callId = generateCallId(); | ||
log.info("Pensjon hente vedtak for ident {}, miljoe {}, callId {}", ident, miljoe, callId); | ||
|
||
return webClient | ||
.get() | ||
.uri(uriBuilder -> uriBuilder | ||
.path(VEDTAK_URL) | ||
.queryParam("miljo", miljoe) | ||
.build()) | ||
.header(AUTHORIZATION, "Bearer " + token) | ||
.header(UserConstant.USER_HEADER_JWT, getUserJwt()) | ||
.header(HEADER_NAV_CALL_ID, callId) | ||
.header(HEADER_NAV_CONSUMER_ID, CONSUMER) | ||
.header("fnr", ident) | ||
.retrieve() | ||
.bodyToFlux(PensjonVedtakResponse.class) | ||
.retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) | ||
.filter(WebClientFilter::is5xxException)) | ||
.doOnError(WebClientFilter::logErrorMessage) | ||
.onErrorResume(Exception.class, error -> Mono.empty()); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
.../src/main/java/no/nav/dolly/bestilling/pensjonforvalter/domain/PensjonVedtakResponse.java
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,20 @@ | ||
package no.nav.dolly.bestilling.pensjonforvalter.domain; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class PensjonVedtakResponse { | ||
|
||
public enum SakType {AP, UT} | ||
|
||
private String sakId; | ||
private SakType sakType; | ||
private String vedtakStatus; | ||
private String sisteOppdatering; | ||
} |
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