Package dev.reuss.tmdb
Class TmdbClientBuilder
java.lang.Object
dev.reuss.tmdb.TmdbClientBuilder
Builder for creating
TmdbClient instances.
The builder configures authentication, the TMDB API base URL and default request settings such as language, region and timeouts.
At minimum, an access token or TmdbAuth instance must be provided
before calling build().
TmdbClient tmdb = TmdbClient.builder()
.accessToken("your-access-token")
.defaultLanguage(Languages.DE_DE)
.build();
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaccessToken(String accessToken) Sets the TMDB bearer access token.Sets the TMDB authentication configuration.Sets the TMDB API base URL.build()Builds a newTmdbClient.connectTimeout(Duration connectTimeout) Sets the HTTP connection timeout.defaultLanguage(Language defaultLanguage) Sets the default language for localized TMDB requests.defaultRegion(Region defaultRegion) Sets the default region for regional TMDB requests.metricsRecorder(TmdbMetricsRecorder metricsRecorder) Sets the metrics recorder used to observe TMDB HTTP requests.requestTimeout(Duration requestTimeout) Sets the overall HTTP request timeout.
-
Constructor Details
-
TmdbClientBuilder
public TmdbClientBuilder()
-
-
Method Details
-
accessToken
Sets the TMDB bearer access token.- Parameters:
accessToken- the TMDB bearer access token- Returns:
- this builder
- Throws:
IllegalArgumentException- if the access token isnull, blank or empty
-
auth
Sets the TMDB authentication configuration.- Parameters:
auth- the TMDB authentication configuration- Returns:
- this builder
- Throws:
NullPointerException- ifauthisnull
-
baseUrl
Sets the TMDB API base URL.The default value is
https://api.themoviedb.org/3. This is mainly useful for testing or custom deployments.- Parameters:
baseUrl- the TMDB API base URL- Returns:
- this builder
-
defaultLanguage
Sets the default language for localized TMDB requests.The default value is
Languages.EN_US.- Parameters:
defaultLanguage- the default language- Returns:
- this builder
-
defaultRegion
Sets the default region for regional TMDB requests.The default region is optional and may be
null. Not every TMDB request requires or supports a region.- Parameters:
defaultRegion- the default region, ornull- Returns:
- this builder
-
connectTimeout
Sets the HTTP connection timeout.The default value is 5 seconds.
- Parameters:
connectTimeout- the connection timeout- Returns:
- this builder
-
requestTimeout
Sets the overall HTTP request timeout.The default value is 10 seconds.
- Parameters:
requestTimeout- the request timeout- Returns:
- this builder
-
metricsRecorder
Sets the metrics recorder used to observe TMDB HTTP requests.The default recorder is a no-op implementation.
- Parameters:
metricsRecorder- the metrics recorder- Returns:
- this builder
- Throws:
NullPointerException- ifmetricsRecorderisnull
-
build
Builds a newTmdbClient.- Returns:
- a new TMDB client instance
- Throws:
NullPointerException- if required configuration values are missingIllegalArgumentException- if configuration values are invalid
-