export type UpdateApiAppProjectsProjectKpisArgs = {project: number, body: {conversion_filter: string, target_leads?: (number | null) | undefined, target_cpl?: (number | null) | undefined}}; export type UpdateApiAppProjectsProjectKpisOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Create or update the KPI for one conversion filter * * PUT /app/projects/{project}/kpis */ export const updateApiAppProjectsProjectKpis = async (args: UpdateApiAppProjectsProjectKpisArgs, options: UpdateApiAppProjectsProjectKpisOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/app/projects/${encodeURIComponent(String(args.project))}/kpis${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };