-
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.
- Loading branch information
Showing
13 changed files
with
281 additions
and
51 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
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
56 changes: 56 additions & 0 deletions
56
...ckend/src/main/java/no/nav/dolly/bestilling/sigrunstub/command/SigurunstubPutCommand.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,56 @@ | ||
package no.nav.dolly.bestilling.sigrunstub.command; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import no.nav.dolly.bestilling.sigrunstub.dto.PensjonsgivendeForFolketrygden; | ||
import no.nav.dolly.bestilling.sigrunstub.dto.SigrunstubResponse; | ||
import no.nav.dolly.util.RequestHeaderUtil; | ||
import no.nav.dolly.util.WebClientFilter; | ||
import no.nav.testnav.libs.securitycore.config.UserConstant; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import reactor.core.publisher.Mono; | ||
import reactor.util.retry.Retry; | ||
|
||
import java.time.Duration; | ||
import java.util.List; | ||
import java.util.concurrent.Callable; | ||
|
||
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.TokenXUtil.getUserJwt; | ||
import static org.springframework.http.HttpHeaders.ACCEPT; | ||
import static org.springframework.http.HttpHeaders.AUTHORIZATION; | ||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; | ||
|
||
@RequiredArgsConstructor | ||
public class SigurunstubPutCommand implements Callable<Mono<SigrunstubResponse>> { | ||
|
||
private static final String CONSUMER = "Dolly"; | ||
private static final String SIGRUN_STUB_OPPRETT_GRUNNLAG = "/api/v1/pensjonsgivendeInntektforfolketrygden"; | ||
|
||
private final WebClient webClient; | ||
private final List<PensjonsgivendeForFolketrygden> request; | ||
private final String token; | ||
|
||
@Override | ||
public Mono<SigrunstubResponse> call() { | ||
|
||
return webClient.post().uri(uriBuilder -> uriBuilder | ||
.path(SIGRUN_STUB_OPPRETT_GRUNNLAG) | ||
.build()) | ||
.header(ACCEPT, APPLICATION_JSON_VALUE) | ||
.header(HEADER_NAV_CALL_ID, RequestHeaderUtil.getNavCallId()) | ||
.header(HEADER_NAV_CONSUMER_ID, CONSUMER) | ||
.header(AUTHORIZATION, "Bearer " + token) | ||
.header(UserConstant.USER_HEADER_JWT, getUserJwt()) | ||
.bodyValue(request) | ||
.retrieve() | ||
.bodyToMono(SigrunstubResponse.class) | ||
.doOnError(WebClientFilter::logErrorMessage) | ||
.onErrorResume(error -> Mono.just(SigrunstubResponse.builder() | ||
.errorStatus(WebClientFilter.getStatus(error)) | ||
.melding(WebClientFilter.getMessage(error)) | ||
.build())) | ||
.retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) | ||
.filter(WebClientFilter::is5xxException)); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
.../src/main/java/no/nav/dolly/bestilling/sigrunstub/dto/PensjonsgivendeForFolketrygden.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,23 @@ | ||
package no.nav.dolly.bestilling.sigrunstub.dto; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class PensjonsgivendeForFolketrygden { | ||
|
||
private String inntektsaar; | ||
@Schema(description = "Liste av map som beskrevet i /api/v1/pensjonsgivendeinntektforfolketrygden/kodeverk") | ||
private List<Map<String, Object>> pensjonsgivendeInntekt; | ||
private String personidentifikator; | ||
private String testdataEier; | ||
} |
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
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
23 changes: 23 additions & 0 deletions
23
.../main/java/no/nav/dolly/domain/resultset/sigrunstub/RsPensjonsgivendeForFolketrygden.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,23 @@ | ||
package no.nav.dolly.domain.resultset.sigrunstub; | ||
|
||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class RsPensjonsgivendeForFolketrygden { | ||
|
||
private String inntektsaar; | ||
@Schema(description = "Liste av map som beskrevet i /api/v1/pensjonsgivendeinntektforfolketrygden/kodeverk") | ||
private List<Map<String, Object>> pensjonsgivendeInntekt; | ||
private String testdataEier; | ||
} |
Oops, something went wrong.