Package com.github.m0nk3y2k4.thetvdb
Class TheTVDBApiFactory
- java.lang.Object
-
- com.github.m0nk3y2k4.thetvdb.TheTVDBApiFactory
-
public final class TheTVDBApiFactory extends Object
Factory used to create new API instances
Provides methods to create newTheTVDBApi
instances with a given set of initialization parameters. Also offers factory methods for creating additional objects that are commonly used in the context of working with the API.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static TheTVDBApi
createApi(String apiKey)
Creates a new TheTVDBApi instance.static TheTVDBApi
createApi(String apiKey, Proxy proxy)
Creates a new TheTVDBApi instance.static TheTVDBApi
createApi(String apiKey, String userKey, String userName)
Creates a new TheTVDBApi instance.static TheTVDBApi
createApi(String apiKey, String userKey, String userName, Proxy proxy)
Creates a new TheTVDBApi instance.static Proxy
createProxy(String protocol, String host, int port)
Creates a new proxy object based on the given parameters.static Proxy
createProxy(String protocol, String host, String path, int port)
Creates a new proxy object based on the given parameters.static QueryParameters
createQueryParameters()
Creates a new query parameter objects to be used with some of the API calls.static QueryParameters
createQueryParameters(Map<String,String> parameters)
Creates a new query parameter objects to be used with some of the API calls.
-
-
-
Method Detail
-
createApi
public static TheTVDBApi createApi(@Nonnull String apiKey)
Creates a new TheTVDBApi instance. The givenapiKey
must be a valid TheTVDB.com API Key which will be used for remote service authentication. To authenticate and generate a new session token use theTheTVDBApi.init()
orTheTVDBApi.login()
methods right after creating a new instance of this API.
NOTE: Objects created with this constructor can not be used for calls to the remote API's /users routes. These calls require extended authentication using an additionaluserKey
anduserName
.- Parameters:
apiKey
- Valid TheTVDB.com API-Key- Returns:
- A new TheTVDBApi instance using the given API key for authentication
- See Also:
createApi(apiKey, userName, userKey)
-
createApi
public static TheTVDBApi createApi(@Nonnull String apiKey, @Nonnull Proxy proxy)
Creates a new TheTVDBApi instance. The givenapiKey
must be a valid TheTVDB.com API Key which will be used for remote service authentication. To authenticate and generate a new session token use theTheTVDBApi.init()
orTheTVDBApi.login()
methods right after creating a new instance of this API. All communication to the remote API will be forwarded to the givenproxy
.
NOTE: Objects created with this constructor can not be used for calls to the remote API's /users routes. These calls require extended authentication using an additionaluserKey
anduserName
.- Parameters:
apiKey
- Valid TheTVDB.com API-Keyproxy
- The proxy service to be used for remote API communication- Returns:
- A new TheTVDBApi instance using the given API key for authentication
- See Also:
createApi(apiKey, userName, userKey, proxy)
-
createApi
public static TheTVDBApi createApi(@Nonnull String apiKey, @Nonnull String userKey, @Nonnull String userName)
Creates a new TheTVDBApi instance. The givenapiKey
must be a valid TheTVDB.com API Key. TheuserKey
anduserName
must refer to a registered TheTVDB.com user account. The given parameters will be used for the initial remote service authentication. To authenticate and generate a new session token use theTheTVDBApi.init()
orTheTVDBApi.login()
methods right after creating a new instance of this API.- Parameters:
apiKey
- Valid TheTVDB.com API-KeyuserKey
- Valid TheTVDB.com user key (also referred to as "Unique ID")userName
- Registered TheTVDB.com user name- Returns:
- A new TheTVDBApi instance using the given API key, user key and user name for authentication
-
createApi
public static TheTVDBApi createApi(@Nonnull String apiKey, @Nonnull String userKey, @Nonnull String userName, @Nonnull Proxy proxy)
Creates a new TheTVDBApi instance. The givenapiKey
must be a valid TheTVDB.com API Key. TheuserKey
anduserName
must refer to a registered TheTVDB.com user account. The given parameters will be used for the initial remote service authentication. To authenticate and generate a new session token use theTheTVDBApi.init()
orTheTVDBApi.login()
methods right after creating a new instance of this API. All communication to the remote API will be forwarded to the givenproxy
.- Parameters:
apiKey
- Valid TheTVDB.com API-KeyuserKey
- Valid TheTVDB.com user key (also referred to as "Unique ID")userName
- Registered TheTVDB.com user nameproxy
- The proxy service to be used for remote API communication- Returns:
- A new TheTVDBApi instance using the given API key, user key and user name for authentication
-
createQueryParameters
public static QueryParameters createQueryParameters()
Creates a new query parameter objects to be used with some of the API calls. The returned object is empty and does not contain any preset query parameters. Those parameters have to be added manually by using theQueryParameters#addParameter(key, value)
method.- Returns:
- A new, empty query parameter object
-
createQueryParameters
public static QueryParameters createQueryParameters(@Nonnull Map<String,String> parameters)
Creates a new query parameter objects to be used with some of the API calls. The returned object is contain a preset collection of query parameters based on the given map of key/value pairs. Additional parameters may be added manually to this object by using theQueryParameters#addParameter(key, value)
method.- Parameters:
parameters
- Map containing key/value pairs of query parameters to be initially added to the object returned by this method. Might be empty but notnull
.- Returns:
- A new query parameter object with a preset collection of individual parameters
-
createProxy
public static Proxy createProxy(@Nonnull String protocol, @Nonnull String host, int port)
Creates a new proxy object based on the given parameters. A proxy may be provided when creating a new TheTVDBApi instance in order to forward all communication towards this proxy instead of directly communicating with the remote TheTVDB.com API. The returned proxy object represents a URI in the following format:"protocol://host:port"
.- Parameters:
protocol
- The protocol used by the proxyhost
- The host name of the proxyport
- The port number to be used for communication- Returns:
- New immutable proxy object based on the given parameters
- See Also:
createProxy(protocol, host, path, port)
-
createProxy
public static Proxy createProxy(@Nonnull String protocol, @Nonnull String host, @Nonnull String path, int port)
Creates a new proxy object based on the given parameters. A proxy may be provided when creating a new TheTVDBApi instance in order to forward all communication towards this proxy instead of directly communicating with the remote TheTVDB.com API. The returned proxy object represents a URI in the following format:"protocol://host:port/path"
.- Parameters:
protocol
- The protocol used by the proxyhost
- The host name of the proxypath
- The path component with a leading '/'. Will be appended to the authority component.port
- The port number to be used for communication- Returns:
- New immutable proxy object based on the given parameters
- See Also:
createProxy(protocol, host, port)
-
-