io.github.jimmydbe.GenresClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of theGamesDbClient Show documentation
Show all versions of theGamesDbClient Show documentation
Java wrapper for the Games DB API.
package io.github.jimmydbe;
import io.github.jimmydbe.entities.BaseGenreResponse;
import io.github.jimmydbe.entities.BaseResponse;
import io.github.jimmydbe.entities.Genre;
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 GenresClient extends Client {
protected GenresClient(String apiKey) {
super(apiKey);
}
protected List getAllGenres() throws ParsingException, GamesDbException {
final HttpResponse> response = Unirest.get(TheGamesDbClient.BASE_URL + "/v1/Genres")
.queryString("apikey", getApiKey())
.asObject(new GenericType>() {
});
checkForErrors(response);
return response.getBody()
.getData()
.getGenres()
.values()
.stream()
.collect(Collectors.toList());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy