export type PostApiFunnels = {name?: string | undefined, forward_url_params?: boolean | undefined, funnel_node_attributes: {content_page_id?: string | undefined, Integer?: string | undefined, form?: ('node_page' | 'node_link') | undefined, redirection_url?: string | undefined}}; export type CreateApiApiFunnelsArgs = {body: PostApiFunnels}; export type CreateApiApiFunnelsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Create funnel * * POST /api/funnels */ export const createApiApiFunnels = async (args: CreateApiApiFunnelsArgs, options: CreateApiApiFunnelsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/funnels${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 };