/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import { providerAddProvider } from "../funcs/providerAddProvider.js";
import { providerDeleteMediaProvider } from "../funcs/providerDeleteMediaProvider.js";
import { providerListProviders } from "../funcs/providerListProviders.js";
import { providerRefreshProviders } from "../funcs/providerRefreshProviders.js";
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
import * as operations from "./models/operations/index.js";
import { unwrapAsync } from "./types/fp.js";

export class Provider extends ClientSDK {
  /**
   * Get the list of available media providers
   *
   * @remarks
   * Get the list of all available media providers for this PMS.  This will generally include the library provider and possibly EPG if DVR is set up.
   */
  async listProviders(
    options?: RequestOptions,
  ): Promise<operations.ListProvidersResponse> {
    return unwrapAsync(providerListProviders(
      this,
      options,
    ));
  }

  /**
   * Add a media provider
   *
   * @remarks
   * This endpoint registers a media provider with the server. Once registered, the media server acts as a reverse proxy to the provider, allowing both local and remote providers to work.
   */
  async addProvider(
    request: operations.AddProviderRequest,
    options?: RequestOptions,
  ): Promise<operations.AddProviderResponse> {
    return unwrapAsync(providerAddProvider(
      this,
      request,
      options,
    ));
  }

  /**
   * Refresh media providers
   *
   * @remarks
   * Refresh all known media providers. This is useful in case a provider has updated features.
   */
  async refreshProviders(
    options?: RequestOptions,
  ): Promise<operations.RefreshProvidersResponse> {
    return unwrapAsync(providerRefreshProviders(
      this,
      options,
    ));
  }

  /**
   * Delete a media provider
   *
   * @remarks
   * Deletes a media provider with the given id
   */
  async deleteMediaProvider(
    request: operations.DeleteMediaProviderRequest,
    options?: RequestOptions,
  ): Promise<operations.DeleteMediaProviderResponse> {
    return unwrapAsync(providerDeleteMediaProvider(
      this,
      request,
      options,
    ));
  }
}
