import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import modelos.Titulo;
import modelos.TituloOmdb;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Scanner;
public class PrincipalBuscaAPi {
public static void main(String[] args) throws IOException, InterruptedException {
Scanner sc = new Scanner(System.in);
String apiKey = "+++++++++++++";
//
//
System.out.println("Digite o Titulo a consultar: ");
String buscar = sc.nextLine();
String endereco = "http://www.omdbapi.com/?s="+buscar+"&apikey="+apiKey;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://www.omdbapi.com/?t="+buscar+"&apikey="+apiKey)).build();
HttpResponse<String> response = client
.send(request, HttpResponse.BodyHandlers.ofString());
String json = response.body();
System.out.println(json);
Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE).create();
TituloOmdb meuTituloOmdb = gson.fromJson(json, TituloOmdb.class);
System.out.println(meuTituloOmdb);
Titulo meuTitulo = new Titulo(meuTituloOmdb);
System.out.println("----------___________________________________");
System.out.println(meuTitulo);