export type CreateApiPipelinesArgs = {create_activity: boolean, body: {candidate_id: number, job_id: number, rating?: number | undefined}}; export type CreateApiPipelinesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a pipeline * * POST /pipelines */ export const createApiPipelines = async (args: CreateApiPipelinesArgs, options?: CreateApiPipelinesOptions) => { const {baseUrl = "https://api.catsone.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.create_activity != null) query.append("create_activity", String(args.create_activity)) const url = `${baseUrl.replace(/\/+$/, '')}/pipelines${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 };