export type CreateApiApiV3WorkspacesIdRecipesArgs = {id: number, body: {recipe_id?: number | undefined}}; export type CreateApiApiV3WorkspacesIdRecipesOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Enable recipe in a workspace * * POST /api/v3/workspaces/{id}/recipes */ export const createApiApiV3WorkspacesIdRecipes = async (args: CreateApiApiV3WorkspacesIdRecipesArgs, options?: CreateApiApiV3WorkspacesIdRecipesOptions) => { const {baseUrl = "https://embedded.improvado.io", fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v3/workspaces/${encodeURIComponent(String(args.id))}/recipes${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 };