All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.jimmydbe.PublishersClient Maven / Gradle / Ivy

There is a newer version: 1.2
Show newest version
package io.github.jimmydbe;

import io.github.jimmydbe.entities.BasePublisherResponse;
import io.github.jimmydbe.entities.BaseResponse;
import io.github.jimmydbe.entities.Publisher;
import io.github.jimmydbe.exceptions.GamesDbException;
import io.github.jimmydbe.exceptions.ParsingException;
import kong.unirest.GenericType;
import kong.unirest.HttpResponse;
import kong.unirest.Unirest;

import java.util.List;
import java.util.stream.Collectors;

class PublishersClient extends Client {

    protected PublishersClient(String apiKey) {
        super(apiKey);
    }

    protected List getAllPublishers() throws ParsingException, GamesDbException {
        final HttpResponse> response = Unirest.get(TheGamesDbClient.BASE_URL + "/v1/Publishers")
                .queryString("apikey", getApiKey())
                .asObject(new GenericType>() {
                });

        checkForErrors(response);

        return response.getBody()
                .getData()
                .getPublishers()
                .values()
                .stream()
                .collect(Collectors.toList());
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy