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

import { playQueueAddToPlayQueue } from "../funcs/playQueueAddToPlayQueue.js";
import { playQueueClearPlayQueue } from "../funcs/playQueueClearPlayQueue.js";
import { playQueueCreatePlayQueue } from "../funcs/playQueueCreatePlayQueue.js";
import { playQueueDeletePlayQueueItem } from "../funcs/playQueueDeletePlayQueueItem.js";
import { playQueueGetPlayQueue } from "../funcs/playQueueGetPlayQueue.js";
import { playQueueMovePlayQueueItem } from "../funcs/playQueueMovePlayQueueItem.js";
import { playQueueResetPlayQueue } from "../funcs/playQueueResetPlayQueue.js";
import { playQueueShuffle } from "../funcs/playQueueShuffle.js";
import { playQueueUnshuffle } from "../funcs/playQueueUnshuffle.js";
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
import * as operations from "./models/operations/index.js";
import { unwrapAsync } from "./types/fp.js";

export class PlayQueue extends ClientSDK {
  /**
   * Create a play queue
   *
   * @remarks
   * Makes a new play queue for a device. The source of the playqueue can either be a URI, or a playlist. The response is a media container with the initial items in the queue. Each item in the queue will be a regular item but with `playQueueItemID` - a unique ID since the queue could have repeated items with the same `ratingKey`.
   * Note: Either `uri` or `playlistID` must be specified
   */
  async createPlayQueue(
    request: operations.CreatePlayQueueRequest,
    options?: RequestOptions,
  ): Promise<operations.CreatePlayQueueResponse> {
    return unwrapAsync(playQueueCreatePlayQueue(
      this,
      request,
      options,
    ));
  }

  /**
   * Retrieve a play queue
   *
   * @remarks
   * Retrieves the play queue, centered at current item. This can be treated as a regular container by play queue-oblivious clients, but they may wish to request a large window onto the queue since they won't know to refresh.
   */
  async getPlayQueue(
    request: operations.GetPlayQueueRequest,
    options?: RequestOptions,
  ): Promise<operations.GetPlayQueueResponse> {
    return unwrapAsync(playQueueGetPlayQueue(
      this,
      request,
      options,
    ));
  }

  /**
   * Add a generator or playlist to a play queue
   *
   * @remarks
   * Adds an item to a play queue (e.g. party mode). Increments the version of the play queue. Takes the following parameters (`uri` and `playlistID` are mutually exclusive). Returns the modified play queue.
   */
  async addToPlayQueue(
    request: operations.AddToPlayQueueRequest,
    options?: RequestOptions,
  ): Promise<operations.AddToPlayQueueResponse> {
    return unwrapAsync(playQueueAddToPlayQueue(
      this,
      request,
      options,
    ));
  }

  /**
   * Clear a play queue
   *
   * @remarks
   * Deletes all items in the play queue, and increases the version of the play queue.
   */
  async clearPlayQueue(
    request: operations.ClearPlayQueueRequest,
    options?: RequestOptions,
  ): Promise<operations.ClearPlayQueueResponse> {
    return unwrapAsync(playQueueClearPlayQueue(
      this,
      request,
      options,
    ));
  }

  /**
   * Reset a play queue
   *
   * @remarks
   * Reset a play queue to the first item being the current item
   */
  async resetPlayQueue(
    request: operations.ResetPlayQueueRequest,
    options?: RequestOptions,
  ): Promise<operations.ResetPlayQueueResponse> {
    return unwrapAsync(playQueueResetPlayQueue(
      this,
      request,
      options,
    ));
  }

  /**
   * Shuffle a play queue
   *
   * @remarks
   * Shuffle a play queue (or reshuffles if already shuffled). The currently selected item is maintained. Note that this is currently only supported for play queues *without* an Up Next area. Returns the modified play queue.
   */
  async shuffle(
    request: operations.ShuffleRequest,
    options?: RequestOptions,
  ): Promise<operations.ShuffleResponse> {
    return unwrapAsync(playQueueShuffle(
      this,
      request,
      options,
    ));
  }

  /**
   * Unshuffle a play queue
   *
   * @remarks
   * Unshuffles a play queue and restores "natural order". Note that this is currently only supported for play queues *without* an Up Next area. Returns the modified play queue.
   */
  async unshuffle(
    request: operations.UnshuffleRequest,
    options?: RequestOptions,
  ): Promise<operations.UnshuffleResponse> {
    return unwrapAsync(playQueueUnshuffle(
      this,
      request,
      options,
    ));
  }

  /**
   * Delete an item from a play queue
   *
   * @remarks
   * Deletes an item in a play queue. Increments the version of the play queue. Returns the modified play queue.
   */
  async deletePlayQueueItem(
    request: operations.DeletePlayQueueItemRequest,
    options?: RequestOptions,
  ): Promise<operations.DeletePlayQueueItemResponse> {
    return unwrapAsync(playQueueDeletePlayQueueItem(
      this,
      request,
      options,
    ));
  }

  /**
   * Move an item in a play queue
   *
   * @remarks
   * Moves an item in a play queue, and increases the version of the play queue. Returns the modified play queue.
   */
  async movePlayQueueItem(
    request: operations.MovePlayQueueItemRequest,
    options?: RequestOptions,
  ): Promise<operations.MovePlayQueueItemResponse> {
    return unwrapAsync(playQueueMovePlayQueueItem(
      this,
      request,
      options,
    ));
  }
}
