/**
 * Playlists API Service
 * Action 6.1.1.4: Create playlists API service
 * Service layer for playlist-related API operations
 * Wraps existing playlist API functions into a unified service object
 */

import {
  createPlaylist,
  getPlaylist,
  updatePlaylist,
  deletePlaylist,
  listPlaylists,
  addCollaborator,
  removeCollaborator,
  updateCollaboratorPermission,
  searchPlaylists,
  createShareLink,
  reorderPlaylistTracks,
  removeTrackFromPlaylist,
  getPlaylistRecommendations,
  getCollaborators,
  addTrackToPlaylist,
  followPlaylist,
  unfollowPlaylist,
  getPlaylistFollowStatus,
  type PlaylistCollaborator,
  type AddCollaboratorRequest,
  type UpdateCollaboratorPermissionRequest,
  type SearchPlaylistsParams,
  type PlaylistShareLink,
  type ReorderTracksRequest,
  type PlaylistRecommendation,
  type GetRecommendationsParams,
  type FollowPlaylistResponse,
} from '@/features/playlists/services/playlistService';
import type {
  Playlist,
  CreatePlaylistRequest,
  UpdatePlaylistRequest,
  PlaylistListResponse,
} from '@/features/playlists/types';

/**
 * Playlists API Service Object
 * Action 6.1.1.4: Exports unified playlistsApi object with all playlist operations
 */
export const playlistsApi = {
  /**
   * Create a new playlist
   */
  create: createPlaylist,

  /**
   * Get a playlist by ID
   */
  get: getPlaylist,

  /**
   * Update a playlist
   */
  update: updatePlaylist,

  /**
   * Delete a playlist
   */
  delete: deletePlaylist,

  /**
   * List playlists with pagination and filters
   */
  list: listPlaylists,

  /**
   * Search playlists
   */
  search: searchPlaylists,

  /**
   * Add a track to a playlist
   */
  addTrack: addTrackToPlaylist,

  /**
   * Remove a track from a playlist
   */
  removeTrack: removeTrackFromPlaylist,

  /**
   * Reorder tracks in a playlist
   */
  reorderTracks: reorderPlaylistTracks,

  /**
   * Add a collaborator to a playlist
   */
  addCollaborator,

  /**
   * Remove a collaborator from a playlist
   */
  removeCollaborator,

  /**
   * Update collaborator permissions
   */
  updateCollaboratorPermission,

  /**
   * Get collaborators of a playlist
   */
  getCollaborators,

  /**
   * Create a share link for a playlist
   */
  createShareLink,

  /**
   * Follow a playlist
   */
  follow: followPlaylist,

  /**
   * Unfollow a playlist
   */
  unfollow: unfollowPlaylist,

  /**
   * Get playlist follow status
   */
  getFollowStatus: getPlaylistFollowStatus,

  /**
   * Get playlist recommendations
   */
  getRecommendations: getPlaylistRecommendations,
};

// Re-export types for convenience
export type {
  Playlist,
  CreatePlaylistRequest,
  UpdatePlaylistRequest,
  PlaylistListResponse,
  PlaylistCollaborator,
  AddCollaboratorRequest,
  UpdateCollaboratorPermissionRequest,
  SearchPlaylistsParams,
  PlaylistShareLink,
  ReorderTracksRequest,
  PlaylistRecommendation,
  GetRecommendationsParams,
  FollowPlaylistResponse,
};
