import { apiRequest } from '@/shared/api/httpClient';
import type { ApiListResponse } from '@/shared/types/api';
import type {
  AudioFileDto,
  AudioFileMutationDto,
} from '@/shared/types/audioFiles';

const AUDIO_FILES_PATH = '/audio_files';

export function listAudioFiles(): Promise<ApiListResponse<AudioFileDto>> {
  return apiRequest<ApiListResponse<AudioFileDto>>(AUDIO_FILES_PATH);
}

export function createAudioFile(
  request: AudioFileMutationDto,
): Promise<AudioFileDto> {
  return apiRequest<AudioFileDto>(AUDIO_FILES_PATH, {
    method: 'POST',
    body: { data: request },
  });
}

export function deleteAudioFile(id: string): Promise<boolean> {
  return apiRequest<boolean>(`${AUDIO_FILES_PATH}/${id}`, {
    method: 'DELETE',
  });
}
