export type GetApiStagesArgs = {id?: number | undefined, name?: string | undefined, 'pipeline.id'?: number | undefined, 'pipeline.name'?: string | undefined, order_by?: string | undefined}; export type GetApiStagesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * List stages * * GET /stages */ export const getApiStages = async (args: GetApiStagesArgs, options?: GetApiStagesOptions) => { const {baseUrl = "https://api.salesflare.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.id != null) query.append("id", String(args.id)) if (args.name != null) query.append("name", String(args.name)) if (args['pipeline.id'] != null) query.append("pipeline.id", String(args['pipeline.id'])) if (args['pipeline.name'] != null) query.append("pipeline.name", String(args['pipeline.name'])) if (args.order_by != null) query.append("order_by", String(args.order_by)) const url = `${baseUrl.replace(/\/+$/, '')}/stages${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };