Overseerr constructor
Overseerr({})
Create a new Overseerr API connection manager to connection to your instance.
This default factory/constructor will create the Dio
HTTP client for you given the parameters.
Required Parameters:
host
: String that contains the protocol (http:// or https://), the host itself, and the base URL (if applicable)apiKey
: The API key fetched from Overseerr's web interface
Optional Parameters:
headers
: Map that contains additional headers that should be attached to all requestsfollowRedirects
: If the HTTP client should follow URL redirectsmaxRedirects
: The maximum amount of redirects the client should follow (does nothing iffollowRedirects
is false)
Implementation
factory Overseerr({
required String host,
required String apiKey,
Map<String, dynamic>? headers,
bool followRedirects = true,
int maxRedirects = 5,
}) {
// Build the HTTP client
Dio _dio = Dio(
BaseOptions(
baseUrl: host.endsWith('/') ? '${host}api/v1/' : '$host/api/v1/',
headers: {
'X-Api-Key': apiKey,
if (headers != null) ...headers,
},
followRedirects: followRedirects,
maxRedirects: maxRedirects,
),
);
return Overseerr._internal(
httpClient: _dio,
requests: OverseerrCommandHandler_Requests(_dio),
status: OverseerrCommandHandler_Status(_dio),
users: OverseerrCommandHandler_Users(_dio),
);
}