1 package de.juplo.demos.pwreset.adapters.out;
3 import de.juplo.demos.pwreset.domain.ports.out.UsersPort;
4 import lombok.RequiredArgsConstructor;
5 import org.springframework.http.HttpStatus;
6 import org.springframework.http.ResponseEntity;
7 import org.springframework.web.client.RestTemplate;
9 import java.util.Optional;
10 import java.util.UUID;
13 @RequiredArgsConstructor
14 public class UsersServiceGateway implements UsersPort
16 private final String uriTemplate;
17 private final RestTemplate restTemplate;
21 public Optional<UUID> getUserByEmail(String email)
23 ResponseEntity<UserDTO> response =
24 restTemplate.getForEntity(uriTemplate, UserDTO.class, email);
26 HttpStatus status = response.getStatusCode();
27 UserDTO dto = response.getBody();
29 switch (response.getStatusCode())
36 return Optional.empty();
39 throw new RuntimeException(status.toString());
44 public void setPassword(UUID userId, String password)