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

import { libraryPlaylistsAddPlaylistItems } from "../funcs/libraryPlaylistsAddPlaylistItems.js";
import { libraryPlaylistsClearPlaylistItems } from "../funcs/libraryPlaylistsClearPlaylistItems.js";
import { libraryPlaylistsCreatePlaylist } from "../funcs/libraryPlaylistsCreatePlaylist.js";
import { libraryPlaylistsDeletePlaylist } from "../funcs/libraryPlaylistsDeletePlaylist.js";
import { libraryPlaylistsDeletePlaylistItem } from "../funcs/libraryPlaylistsDeletePlaylistItem.js";
import { libraryPlaylistsGetPlaylistGenerator } from "../funcs/libraryPlaylistsGetPlaylistGenerator.js";
import { libraryPlaylistsGetPlaylistGeneratorItems } from "../funcs/libraryPlaylistsGetPlaylistGeneratorItems.js";
import { libraryPlaylistsGetPlaylistGenerators } from "../funcs/libraryPlaylistsGetPlaylistGenerators.js";
import { libraryPlaylistsModifyPlaylistGenerator } from "../funcs/libraryPlaylistsModifyPlaylistGenerator.js";
import { libraryPlaylistsMovePlaylistItem } from "../funcs/libraryPlaylistsMovePlaylistItem.js";
import { libraryPlaylistsRefreshPlaylist } from "../funcs/libraryPlaylistsRefreshPlaylist.js";
import { libraryPlaylistsUpdatePlaylist } from "../funcs/libraryPlaylistsUpdatePlaylist.js";
import { libraryPlaylistsUploadPlaylist } from "../funcs/libraryPlaylistsUploadPlaylist.js";
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
import * as operations from "./models/operations/index.js";
import { unwrapAsync } from "./types/fp.js";

export class LibraryPlaylists extends ClientSDK {
  /**
   * Create a Playlist
   *
   * @remarks
   * Create a new playlist. By default the playlist is blank.
   */
  async createPlaylist(
    request: operations.CreatePlaylistRequest,
    options?: RequestOptions,
  ): Promise<operations.CreatePlaylistResponse> {
    return unwrapAsync(libraryPlaylistsCreatePlaylist(
      this,
      request,
      options,
    ));
  }

  /**
   * Upload
   *
   * @remarks
   * Imports m3u playlists by passing a path on the server to scan for m3u-formatted playlist files, or a path to a single playlist file.
   */
  async uploadPlaylist(
    request: operations.UploadPlaylistRequest,
    options?: RequestOptions,
  ): Promise<operations.UploadPlaylistResponse> {
    return unwrapAsync(libraryPlaylistsUploadPlaylist(
      this,
      request,
      options,
    ));
  }

  /**
   * Delete a Playlist
   *
   * @remarks
   * Deletes a playlist by provided id
   */
  async deletePlaylist(
    request: operations.DeletePlaylistRequest,
    options?: RequestOptions,
  ): Promise<operations.DeletePlaylistResponse> {
    return unwrapAsync(libraryPlaylistsDeletePlaylist(
      this,
      request,
      options,
    ));
  }

  /**
   * Editing a Playlist
   *
   * @remarks
   * Edits a playlist in the same manner as [editing metadata](#tag/Provider/operation/metadataPutItem)
   */
  async updatePlaylist(
    request: operations.UpdatePlaylistRequest,
    options?: RequestOptions,
  ): Promise<operations.UpdatePlaylistResponse> {
    return unwrapAsync(libraryPlaylistsUpdatePlaylist(
      this,
      request,
      options,
    ));
  }

  /**
   * Get a playlist's generators
   *
   * @remarks
   * Get all the generators in a playlist
   */
  async getPlaylistGenerators(
    request: operations.GetPlaylistGeneratorsRequest,
    options?: RequestOptions,
  ): Promise<operations.GetPlaylistGeneratorsResponse> {
    return unwrapAsync(libraryPlaylistsGetPlaylistGenerators(
      this,
      request,
      options,
    ));
  }

  /**
   * Clearing a playlist
   *
   * @remarks
   * Clears a playlist, only works with dumb playlists. Returns the playlist.
   */
  async clearPlaylistItems(
    request: operations.ClearPlaylistItemsRequest,
    options?: RequestOptions,
  ): Promise<operations.ClearPlaylistItemsResponse> {
    return unwrapAsync(libraryPlaylistsClearPlaylistItems(
      this,
      request,
      options,
    ));
  }

  /**
   * Adding to  a Playlist
   *
   * @remarks
   * Adds a generator to a playlist, same parameters as the POST above. With a dumb playlist, this adds the specified items to the playlist. With a smart playlist, passing a new `uri` parameter replaces the rules for the playlist. Returns the playlist.
   */
  async addPlaylistItems(
    request: operations.AddPlaylistItemsRequest,
    options?: RequestOptions,
  ): Promise<operations.AddPlaylistItemsResponse> {
    return unwrapAsync(libraryPlaylistsAddPlaylistItems(
      this,
      request,
      options,
    ));
  }

  /**
   * Delete a Generator
   *
   * @remarks
   * Deletes an item from a playlist. Only works with dumb playlists.
   */
  async deletePlaylistItem(
    request: operations.DeletePlaylistItemRequest,
    options?: RequestOptions,
  ): Promise<operations.DeletePlaylistItemResponse> {
    return unwrapAsync(libraryPlaylistsDeletePlaylistItem(
      this,
      request,
      options,
    ));
  }

  /**
   * Get a playlist generator
   *
   * @remarks
   * Get a playlist's generator.  Only used for optimized versions
   */
  async getPlaylistGenerator(
    request: operations.GetPlaylistGeneratorRequest,
    options?: RequestOptions,
  ): Promise<operations.GetPlaylistGeneratorResponse> {
    return unwrapAsync(libraryPlaylistsGetPlaylistGenerator(
      this,
      request,
      options,
    ));
  }

  /**
   * Modify a Generator
   *
   * @remarks
   * Modify a playlist generator.  Only used for optimizer
   */
  async modifyPlaylistGenerator(
    request: operations.ModifyPlaylistGeneratorRequest,
    options?: RequestOptions,
  ): Promise<operations.ModifyPlaylistGeneratorResponse> {
    return unwrapAsync(libraryPlaylistsModifyPlaylistGenerator(
      this,
      request,
      options,
    ));
  }

  /**
   * Get a playlist generator's items
   *
   * @remarks
   * Get a playlist generator's items
   */
  async getPlaylistGeneratorItems(
    request: operations.GetPlaylistGeneratorItemsRequest,
    options?: RequestOptions,
  ): Promise<operations.GetPlaylistGeneratorItemsResponse> {
    return unwrapAsync(libraryPlaylistsGetPlaylistGeneratorItems(
      this,
      request,
      options,
    ));
  }

  /**
   * Moving items in a playlist
   *
   * @remarks
   * Moves an item in a playlist. Only works with dumb playlists.
   */
  async movePlaylistItem(
    request: operations.MovePlaylistItemRequest,
    options?: RequestOptions,
  ): Promise<operations.MovePlaylistItemResponse> {
    return unwrapAsync(libraryPlaylistsMovePlaylistItem(
      this,
      request,
      options,
    ));
  }

  /**
   * Reprocess a generator
   *
   * @remarks
   * Make a generator reprocess (refresh)
   */
  async refreshPlaylist(
    request: operations.RefreshPlaylistRequest,
    options?: RequestOptions,
  ): Promise<operations.RefreshPlaylistResponse> {
    return unwrapAsync(libraryPlaylistsRefreshPlaylist(
      this,
      request,
      options,
    ));
  }
}
