0% found this document useful (0 votes)
52 views1 page

Test-Nesto Java

Uploaded by

nepoznate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views1 page

Test-Nesto Java

Uploaded by

nepoznate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

private static Exchange callWebServiceForExchangerates(Environment env) {

String resourceUrl = "https://v6.exchangerate-


api.com/v6/e81ea992de96d763ece9180e/latest/";
String defaultCurrency = "BAM";
//String resourceUrl = env.getProperty("application.exchangeresourceurl");

RestTemplate template = new RestTemplate();


/* org.springframework.http.HttpHeaders headers = new
org.springframework.http.HttpHeaders();
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
Exchange quote = template.getForObject(resourceUrl, Exchange.class);
log.warn(quote.toString()); */

/*LocalDate localDate = LocalDate.of(2021, 8, 31);


LocalTime localTime = LocalTime.of(12, 30, 0);
LocalDateTime localDateTime = LocalDateTime.of(localDate, localTime);
ZonedDateTime zonedDateTime = ZonedDateTime.of(localDate, localTime,
ZoneId.systemDefault());*/

ResponseEntity<Exchange> quote2 =
template.getForEntity(resourceUrl+defaultCurrency, Exchange.class);
if (quote2 != null && quote2.hasBody()) {
if (quote2.getBody() != null && quote2.getBody().getCurrencyRates() !=
null && !quote2.getBody().getCurrencyRates().isEmpty()) {
var currencies = quote2.getBody().getCurrencyRates().keySet();
log.warn("Currencies fetched are: " + currencies.toString());
log.warn(quote2.getBody().toString());
}
}
return quote2.getBody();

You might also like