export type WidgetTypes = 'inline' | 'expanding' | 'mobile-expanding' | 'docked' | 'carousel' | 'sidebar' | 'playlist'; export type UpdateWidgetDto = {type?: WidgetTypes | undefined, name?: string | undefined}; export type PatchApiV1CreatorWidgetsWidgetIdArgs = {widgetId: string, body: UpdateWidgetDto}; export type PatchApiV1CreatorWidgetsWidgetIdOptions = {baseUrl: string, accessToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * PATCH /v1/creator/widgets/{widgetId} */ export const patchApiV1CreatorWidgetsWidgetId = async (args: PatchApiV1CreatorWidgetsWidgetIdArgs, options: PatchApiV1CreatorWidgetsWidgetIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, accessToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (accessToken !== undefined) headers.set('authorization', `Bearer ${accessToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/creator/widgets/${encodeURIComponent(String(args.widgetId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };