Created
November 24, 2022 15:42
-
-
Save eliasnogueira/91edf0a6030b0d6292827d0f7b7f1112 to your computer and use it in GitHub Desktop.
[JavaAdvent] Method that connects to the Restriction API and return the appropriate result
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
private void checkForRestriction(String cpf) throws SimulationException { | |
RestTemplate template = new RestTemplateBuilder().errorHandler(new RestTemplateErrorHandler()).build(); | |
String restrictionsEndpoint = String.format("%s:%s%s", env.getProperty("restrictions.host"), | |
env.getProperty("restrictions.port"), env.getProperty("restrictions.path")); | |
var response = template.getForObject(restrictionsEndpoint, MessageDto.class, cpf); | |
if (response != null) throw new ResponseStatusException(HttpStatus.FORBIDDEN, response.message()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment