export type CreateGoogleSheetDto = {title: string, headers?: Array | undefined, rows: Array}; export type CreateApiV1TasksTaskIdAutomationsAutomationIdGoogleSheetsArgs = {taskId: string, automationId: string, body: CreateGoogleSheetDto}; export type CreateApiV1TasksTaskIdAutomationsAutomationIdGoogleSheetsOptions = {baseUrl?: string | undefined, apikey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a Google Spreadsheet and write evidence rows into it * * POST /v1/tasks/{taskId}/automations/{automationId}/google-sheets */ export const createApiV1TasksTaskIdAutomationsAutomationIdGoogleSheets = async (args: CreateApiV1TasksTaskIdAutomationsAutomationIdGoogleSheetsArgs, options?: CreateApiV1TasksTaskIdAutomationsAutomationIdGoogleSheetsOptions) => { const {baseUrl = "https://api.betayum.com", fetch: fetchFn = fetch, apikey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apikey !== undefined) headers.set("X-API-Key", apikey) const url = `${baseUrl.replace(/\/+$/, '')}/v1/tasks/${encodeURIComponent(String(args.taskId))}/automations/${encodeURIComponent(String(args.automationId))}/google-sheets${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 };