package org.sillyjirafe.uoapi;

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.List;

public class Caller {
    public static List<element> CallApi(Api api, int page) throws Exception
    {
        HttpClient client = HttpClient.newHttpClient();

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create(api.getURL(page)))
            .GET()
            .build();        	

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

        return api.Parse(response.body());
    }
}
