All files / Rindu/utils/spotifyCalls editPlaylistDetails.ts

11.11% Statements 1/9
0% Branches 0/2
0% Functions 0/1
14.28% Lines 1/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  19x                                            
import type { ServerApiContext } from "types/serverContext";
import { callSpotifyApi } from "utils/spotifyCalls";
 
export async function editPlaylistDetails(
  playlistId: string | undefined | null,
  name: string,
  description?: string,
  context?: ServerApiContext
): Promise<boolean | null> {
  Iif (!playlistId) return null;
 
  const body: { name: string; description?: string } = { name };
  Iif (description) body.description = description;
 
  const res = await callSpotifyApi({
    endpoint: `/playlists/${playlistId}`,
    method: "PUT",
    body: JSON.stringify(body),
    context,
  });
 
  return res.ok;
}