From 43d06e448fcd4f0cf8b46d9de329b7b1364a172a Mon Sep 17 00:00:00 2001 From: kristenhaerum Date: Thu, 13 Jun 2024 09:28:35 +0200 Subject: [PATCH] Remove SokosGetRequest class and refactor associated methods #deploy-skattekort-service The SokosGetRequest class has been deleted and its usage in various methods has been directly replaced with the required parameters: 'ident' and 'inntektsaar'. This change streamlines the process of requesting a SkatteKort, removing the need to create a SokosGetRequest object first. It also improves the readability and manageability of the code. --- .../consumer/SokosSkattekortConsumer.java | 7 +++---- .../consumer/command/SokosGetCommand.java | 2 +- .../provider/SkattekortController.java | 9 +++++---- .../service/SkattekortService.java | 5 ++--- .../skattekortservice/v1/SokosGetRequest.java | 16 ---------------- 5 files changed, 11 insertions(+), 28 deletions(-) delete mode 100644 libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/skattekortservice/v1/SokosGetRequest.java diff --git a/apps/skattekort-service/src/main/java/no/nav/skattekortservice/consumer/SokosSkattekortConsumer.java b/apps/skattekort-service/src/main/java/no/nav/skattekortservice/consumer/SokosSkattekortConsumer.java index a1055c2bb60..e85354bfc5f 100644 --- a/apps/skattekort-service/src/main/java/no/nav/skattekortservice/consumer/SokosSkattekortConsumer.java +++ b/apps/skattekort-service/src/main/java/no/nav/skattekortservice/consumer/SokosSkattekortConsumer.java @@ -4,7 +4,6 @@ import no.nav.skattekortservice.consumer.command.SokosGetCommand; import no.nav.skattekortservice.consumer.command.SokosPostCommand; import no.nav.skattekortservice.dto.SokosRequest; -import no.nav.testnav.libs.dto.skattekortservice.v1.SokosGetRequest; import no.nav.testnav.libs.reactivesecurity.exchange.TokenExchange; import no.nav.testnav.libs.securitycore.domain.ServerProperties; import org.springframework.stereotype.Service; @@ -33,10 +32,10 @@ public Mono sendSkattekort(SokosRequest request) { .flatMap(token -> new SokosPostCommand(webClient, request, token.getTokenValue()).call()); } - public Mono hentSkattekort(SokosGetRequest request) { + public Mono hentSkattekort(String ident, Integer inntektsaar) { return tokenExchange.exchange(serverProperties) - .flatMap(token -> new SokosGetCommand(webClient, request.getIdent(), - request.getInntektsar(), token.getTokenValue()).call()); + .flatMap(token -> new SokosGetCommand(webClient, ident, + inntektsaar, token.getTokenValue()).call()); } } diff --git a/apps/skattekort-service/src/main/java/no/nav/skattekortservice/consumer/command/SokosGetCommand.java b/apps/skattekort-service/src/main/java/no/nav/skattekortservice/consumer/command/SokosGetCommand.java index 56435b75477..f272d159175 100644 --- a/apps/skattekort-service/src/main/java/no/nav/skattekortservice/consumer/command/SokosGetCommand.java +++ b/apps/skattekort-service/src/main/java/no/nav/skattekortservice/consumer/command/SokosGetCommand.java @@ -19,7 +19,7 @@ public class SokosGetCommand implements Callable> { private final WebClient webClient; private final String ident; - private final String inntektsaar; + private final Integer inntektsaar; private final String token; @Override diff --git a/apps/skattekort-service/src/main/java/no/nav/skattekortservice/provider/SkattekortController.java b/apps/skattekort-service/src/main/java/no/nav/skattekortservice/provider/SkattekortController.java index 5863379bcfe..9a9fa183c20 100644 --- a/apps/skattekort-service/src/main/java/no/nav/skattekortservice/provider/SkattekortController.java +++ b/apps/skattekort-service/src/main/java/no/nav/skattekortservice/provider/SkattekortController.java @@ -3,12 +3,12 @@ import lombok.RequiredArgsConstructor; import no.nav.skattekortservice.service.SkattekortService; import no.nav.testnav.libs.dto.skattekortservice.v1.SkattekortTilArbeidsgiverDTO; -import no.nav.testnav.libs.dto.skattekortservice.v1.SokosGetRequest; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import reactor.core.publisher.Mono; @@ -25,9 +25,10 @@ public Mono sendSkattekort(@RequestBody SkattekortTilArbeidsgiverDTO ska return skattekortService.sendSkattekort(skattekort); } - @GetMapping - public Mono hentSkattekort(@RequestBody SokosGetRequest request) { + @GetMapping(produces = MediaType.ALL_VALUE) + public Mono hentSkattekort(@RequestParam String ident, + @RequestParam Integer inntektsaar) { - return skattekortService.hentSkattekort(request); + return skattekortService.hentSkattekort(ident, inntektsaar); } } diff --git a/apps/skattekort-service/src/main/java/no/nav/skattekortservice/service/SkattekortService.java b/apps/skattekort-service/src/main/java/no/nav/skattekortservice/service/SkattekortService.java index 0b8e9813cf3..c3413ae67b1 100644 --- a/apps/skattekort-service/src/main/java/no/nav/skattekortservice/service/SkattekortService.java +++ b/apps/skattekort-service/src/main/java/no/nav/skattekortservice/service/SkattekortService.java @@ -10,7 +10,6 @@ import no.nav.skattekortservice.dto.SokosRequest; import no.nav.skattekortservice.utility.SkattekortValidator; import no.nav.testnav.libs.dto.skattekortservice.v1.SkattekortTilArbeidsgiverDTO; -import no.nav.testnav.libs.dto.skattekortservice.v1.SokosGetRequest; import org.springframework.stereotype.Service; import reactor.core.publisher.Mono; @@ -71,9 +70,9 @@ private String encodeRequest(String request) { .encodeToString(request.getBytes(StandardCharsets.UTF_8)); } - public Mono hentSkattekort(SokosGetRequest request) { + public Mono hentSkattekort(String ident, Integer inntektsaar) { - return skattekortConsumer.hentSkattekort(request) + return skattekortConsumer.hentSkattekort(ident, inntektsaar) .doOnNext(response -> log.info("Hentet resultat fra Sokos {}", response)); } } diff --git a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/skattekortservice/v1/SokosGetRequest.java b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/skattekortservice/v1/SokosGetRequest.java deleted file mode 100644 index ea771d40ba4..00000000000 --- a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/skattekortservice/v1/SokosGetRequest.java +++ /dev/null @@ -1,16 +0,0 @@ -package no.nav.testnav.libs.dto.skattekortservice.v1; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class SokosGetRequest { - - private String ident; - private String inntektsar; -} \ No newline at end of file