/**
 * @copyright 2026 NHCarrigan
 * @license Naomi's Public License
 * @author Naomi Carrigan
 */

import { Injectable, inject } from '@angular/core';
import { Observable } from 'rxjs';
import { ApiService } from './api.service';
import { Music, CreateMusicDto, UpdateMusicDto } from '@library/shared-types';

@Injectable({
  providedIn: 'root'
})
export class MusicService {
  private api = inject(ApiService);


  getAllMusic(): Observable<Music[]> {
    return this.api.get<Music[]>('/music');
  }

  getMusicById(id: string): Observable<Music | null> {
    return this.api.get<Music | null>(`/music/${id}`);
  }

  createMusic(music: CreateMusicDto): Observable<Music> {
    return this.api.post<Music>('/music', music);
  }

  updateMusic(id: string, music: UpdateMusicDto): Observable<Music> {
    return this.api.put<Music>(`/music/${id}`, music);
  }

  deleteMusic(id: string): Observable<{ success: boolean }> {
    return this.api.delete<{ success: boolean }>(`/music/${id}`);
  }
}