Overseerr constructor

Overseerr({
  1. required String host,
  2. required String apiKey,
  3. Map<String, dynamic>? headers,
  4. bool followRedirects = true,
  5. int maxRedirects = 5,
})

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 requests
  • followRedirects: If the HTTP client should follow URL redirects
  • maxRedirects: The maximum amount of redirects the client should follow (does nothing if followRedirects 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),
  );
}