Skip to content

Commit

Permalink
Remove SokosGetRequest class and refactor associated methods #deploy-…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
krharum committed Jun 13, 2024
1 parent 2c0860d commit 43d06e4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -33,10 +32,10 @@ public Mono<String> sendSkattekort(SokosRequest request) {
.flatMap(token -> new SokosPostCommand(webClient, request, token.getTokenValue()).call());
}

public Mono<String> hentSkattekort(SokosGetRequest request) {
public Mono<String> 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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class SokosGetCommand implements Callable<Mono<String>> {

private final WebClient webClient;
private final String ident;
private final String inntektsaar;
private final Integer inntektsaar;
private final String token;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -25,9 +25,10 @@ public Mono<String> sendSkattekort(@RequestBody SkattekortTilArbeidsgiverDTO ska
return skattekortService.sendSkattekort(skattekort);
}

@GetMapping
public Mono<String> hentSkattekort(@RequestBody SokosGetRequest request) {
@GetMapping(produces = MediaType.ALL_VALUE)
public Mono<String> hentSkattekort(@RequestParam String ident,
@RequestParam Integer inntektsaar) {

return skattekortService.hentSkattekort(request);
return skattekortService.hentSkattekort(ident, inntektsaar);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -71,9 +70,9 @@ private String encodeRequest(String request) {
.encodeToString(request.getBytes(StandardCharsets.UTF_8));
}

public Mono<String> hentSkattekort(SokosGetRequest request) {
public Mono<String> hentSkattekort(String ident, Integer inntektsaar) {

return skattekortConsumer.hentSkattekort(request)
return skattekortConsumer.hentSkattekort(ident, inntektsaar)
.doOnNext(response -> log.info("Hentet resultat fra Sokos {}", response));
}
}

This file was deleted.

0 comments on commit 43d06e4

Please sign in to comment.