export type HandlersRunCustomIntegrationRequestInput = {data?: ({[key: string]: unknown} | null) | undefined, timeoutSeconds?: (number | null) | undefined, yaml?: string | undefined}; export type CreateApiApiCustomIntegrationsRunArgs = {Authorization?: string | undefined, 'Credimi-Api-Key'?: string | undefined, body: HandlersRunCustomIntegrationRequestInput}; export type CreateApiApiCustomIntegrationsRunOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Run a custom integration * * POST /api/custom-integrations/run */ export const createApiApiCustomIntegrationsRun = async (args: CreateApiApiCustomIntegrationsRunArgs, options?: CreateApiApiCustomIntegrationsRunOptions) => { const {baseUrl = "https://credimi.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (args['Credimi-Api-Key'] != null) headers.set("Credimi-Api-Key", String(args['Credimi-Api-Key'])) const url = `${baseUrl.replace(/\/+$/, '')}/api/custom-integrations/run${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 };