export type MetadataRefreshMode = 'None' | 'ValidationOnly' | 'Default' | 'FullRefresh'; export type CreateApiItemsItemIdRefreshArgs = {itemId: string, metadataRefreshMode?: MetadataRefreshMode | undefined, imageRefreshMode?: MetadataRefreshMode | undefined, replaceAllMetadata?: boolean | undefined, replaceAllImages?: boolean | undefined}; export type CreateApiItemsItemIdRefreshOptions = {baseUrl?: string | undefined, CustomAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; /** * Refreshes metadata for an item. * * POST /Items/{itemId}/Refresh */ export const createApiItemsItemIdRefresh = async (args: CreateApiItemsItemIdRefreshArgs, options?: CreateApiItemsItemIdRefreshOptions) => { const {baseUrl = "http://localhost", fetch: fetchFn = fetch, CustomAuthentication} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.metadataRefreshMode != null) query.append("metadataRefreshMode", String(args.metadataRefreshMode)) if (args.imageRefreshMode != null) query.append("imageRefreshMode", String(args.imageRefreshMode)) if (args.replaceAllMetadata != null) query.append("replaceAllMetadata", String(args.replaceAllMetadata)) if (args.replaceAllImages != null) query.append("replaceAllImages", String(args.replaceAllImages)) if (CustomAuthentication !== undefined) headers.set("X-Emby-Authorization", CustomAuthentication) const url = `${baseUrl.replace(/\/+$/, '')}/Items/${encodeURIComponent(String(args.itemId))}/Refresh${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 };