export type CreateApiPlaylistsPlaylistIdItemsArgs = {playlistId: string, ids?: (Array | null) | undefined, userId?: (string | null) | undefined}; export type CreateApiPlaylistsPlaylistIdItemsOptions = {baseUrl?: string | undefined, CustomAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; /** * Adds items to a playlist. * * POST /Playlists/{playlistId}/Items */ export const createApiPlaylistsPlaylistIdItems = async (args: CreateApiPlaylistsPlaylistIdItemsArgs, options?: CreateApiPlaylistsPlaylistIdItemsOptions) => { const {baseUrl = "http://localhost", fetch: fetchFn = fetch, CustomAuthentication} = options ?? {} const query = new URLSearchParams() const headers = new Headers() for (const item of args.ids ?? []) query.append("ids", String(item)) if (args.userId != null) query.append("userId", String(args.userId)) if (CustomAuthentication !== undefined) headers.set("X-Emby-Authorization", CustomAuthentication) const url = `${baseUrl.replace(/\/+$/, '')}/Playlists/${encodeURIComponent(String(args.playlistId))}/Items${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };