Package dev.reuss.tmdb.core.http
Class JavaNetTmdbHttpClient
java.lang.Object
dev.reuss.tmdb.core.http.JavaNetTmdbHttpClient
- All Implemented Interfaces:
TmdbHttpClient
TmdbHttpClient implementation based on Java's built-in
HttpClient.
This client applies the configured TMDB authentication, builds absolute
request URIs from TmdbRequest instances, sends HTTP GET requests and
maps successful JSON responses to the requested Java type.
Non-successful HTTP responses are translated into SDK-specific runtime
exceptions such as TmdbUnauthorizedException,
TmdbNotFoundException, TmdbRateLimitException or
TmdbServerException.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new HTTP client using the given TMDB client configuration. -
Method Summary
Modifier and TypeMethodDescription<T> Tget(TmdbRequest request, Class<T> responseType) Sends a GET request to TMDB and maps the JSON response body to the given type.
-
Constructor Details
-
JavaNetTmdbHttpClient
Creates a new HTTP client using the given TMDB client configuration.- Parameters:
config- the TMDB client configuration- Throws:
NullPointerException- ifconfigisnull
-
-
Method Details
-
get
Sends a GET request to TMDB and maps the JSON response body to the given type.- Specified by:
getin interfaceTmdbHttpClient- Type Parameters:
T- the expected response type- Parameters:
request- the TMDB request to sendresponseType- the expected response type- Returns:
- the mapped response body
- Throws:
NullPointerException- ifrequestorresponseTypeisnullTmdbUnauthorizedException- if TMDB returns HTTP 401TmdbNotFoundException- if TMDB returns HTTP 404TmdbRateLimitException- if TMDB returns HTTP 429TmdbServerException- if TMDB returns an HTTP 5xx responseTmdbMappingException- if the response body cannot be mappedTmdbException- for network errors, interruptions or other non-successful responses
-