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

import { playlistGetPlaylist } from "../funcs/playlistGetPlaylist.js";
import { playlistGetPlaylistItems } from "../funcs/playlistGetPlaylistItems.js";
import { playlistListPlaylists } from "../funcs/playlistListPlaylists.js";
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
import * as operations from "./models/operations/index.js";
import { unwrapAsync } from "./types/fp.js";

export class Playlist extends ClientSDK {
  /**
   * List playlists
   *
   * @remarks
   * Gets a list of playlists and playlist folders for a user. General filters are permitted, such as `sort=lastViewedAt:desc`. A flat playlist list can be retrieved using `type=15` to limit the collection to just playlists.
   */
  async listPlaylists(
    request: operations.ListPlaylistsRequest,
    options?: RequestOptions,
  ): Promise<operations.ListPlaylistsResponse> {
    return unwrapAsync(playlistListPlaylists(
      this,
      request,
      options,
    ));
  }

  /**
   * Retrieve Playlist
   *
   * @remarks
   * Gets detailed metadata for a playlist. A playlist for many purposes (rating, editing metadata, tagging), can be treated like a regular metadata item:
   * Smart playlist details contain the `content` attribute. This is the content URI for the generator. This can then be parsed by a client to provide smart playlist editing.
   */
  async getPlaylist(
    request: operations.GetPlaylistRequest,
    options?: RequestOptions,
  ): Promise<operations.GetPlaylistResponse> {
    return unwrapAsync(playlistGetPlaylist(
      this,
      request,
      options,
    ));
  }

  /**
   * Retrieve Playlist Contents
   *
   * @remarks
   * Gets the contents of a playlist. Should be paged by clients via standard mechanisms. By default leaves are returned (e.g. episodes, movies). In order to return other types you can use the `type` parameter. For example, you could use this to display a list of recently added albums vis a smart playlist. Note that for dumb playlists, items have a `playlistItemID` attribute which is used for deleting or moving items.
   */
  async getPlaylistItems(
    request: operations.GetPlaylistItemsRequest,
    options?: RequestOptions,
  ): Promise<operations.GetPlaylistItemsResponse> {
    return unwrapAsync(playlistGetPlaylistItems(
      this,
      request,
      options,
    ));
  }
}
