Skip to content

Commit

Permalink
VKT(Backend): KOSKI client
Browse files Browse the repository at this point in the history
  • Loading branch information
jrkkp committed Jun 5, 2024
1 parent b3c566a commit 4802f65
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public PublicExamEventDTO getExamEventInfo(@PathVariable final long examEventId)
*/
@GetMapping(path = "/education")
public KoskiResponseDTO getEducation() {
return koskiService.findEducations();
return koskiService.findEducations("1.2.246.562.24.97984579806");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import fi.oph.vkt.service.koski.dto.KoskiResponseDTO;
import fi.oph.vkt.service.koski.dto.RequestBody;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -19,14 +20,16 @@ public class KoskiService {

private final WebClient koskiClient;

public KoskiResponseDTO findEducations() {
public KoskiResponseDTO findEducations(final String oid) {
final ObjectMapper objectMapper = new ObjectMapper();
final RequestBody body = new RequestBody(oid);

try {
final String bodyJson = objectMapper.writeValueAsString(body);
final String response = koskiClient
.post()
.uri("/oid")
.bodyValue("{ \"oid\": \"1.2.246.562.24.97984579806\" }")
.bodyValue(bodyJson)
.exchangeToMono(clientResponse -> {
if (clientResponse.statusCode().isError()) {
return clientResponse.createException().flatMap(Mono::error);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package fi.oph.vkt.service.koski.dto;

import jakarta.validation.constraints.NotNull;
import lombok.Builder;
import lombok.NonNull;

@Builder
public record RequestBody(@NonNull @NotNull String oid) {}

0 comments on commit 4802f65

Please sign in to comment.