/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
public class Country {
private int confirmed_diff;
private float fatality_rate;
}
public class CountryDto {
private List<CountryDataDto> data;
}
public class CountryDataDto {
private CountryRegionDto region;
private int confirmed_diff;
private float fatality_rate;
}
public class CountryRegionDto {
}
public class CountryService {
public List<Country> getCoutries()
{
RestTemplate restTemplate; = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.set("x-rapidapi-host","covid-19-statistics.p.rapidapi.com");
headers.set("x-rapidapi-key","cdd95c2ed2msh46d1517fc73ea3dp1d7e84jsn0ec3a82ea7ae");
HttpEntity entity = new HttpEntity(headers);
ResponseEntity<CountryDto> response = restTemplate.exchange("https://c...content-available-to-author-only...i.com/reports", HttpMethod.GET,entity, CountryDto.class);
CountryDto country = response.getBody();
List<Country> countries = new LinkedList<>();
countries.add(Country.builder()
.name(country.getData().get(0).getRegion().getName())
.confirmed_diff(country.getData().get(0).getConfirmed_diff())
.date(country.getData().get(0).getDate())
.fatality_rate(country.getData().get(0).getFatality_rate())
.build());
return countries;
}
}
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
// your code goes here
}
}