Sonarr constructor

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

Create a new Sonarr 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 Sonarr'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 Sonarr({
  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/v3/' : '$host/api/v3/',
      queryParameters: {'apikey': apiKey},
      headers: headers,
      followRedirects: followRedirects,
      maxRedirects: maxRedirects,
    ),
  );
  return Sonarr._internal(
    httpClient: _dio,
    calendar: SonarrCommandHandler_Calendar(_dio),
    command: SonarrCommandHandler_Command(_dio),
    episode: SonarrCommandHandler_Episode(_dio),
    episodeFile: SonarrCommandHandler_EpisodeFile(_dio),
    history: SonarrCommandHandler_History(_dio),
    profile: SonarrCommandHandler_Profile(_dio),
    queue: SonarrCommandHandler_Queue(_dio),
    release: SonarrCommandHandler_Release(_dio),
    rootFolder: SonarrCommandHandler_RootFolder(_dio),
    series: SonarrCommandHandler_Series(_dio),
    seriesLookup: SonarrCommandHandler_SeriesLookup(_dio),
    system: SonarrCommandHandler_System(_dio),
    tag: SonarrCommandHandler_Tag(_dio),
    wanted: SonarrCommandHandler_Wanted(_dio),
  );
}