export type CreateApiCallsArgs = {body: Array<{date: string, end_date?: string | undefined, subject?: string | undefined, description?: string | undefined, minutes?: string | undefined, notes?: string | undefined, phone_type?: string | undefined, phone_number_hash?: string | undefined, participants: Array}>}; export type CreateApiCallsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a call * * POST /calls */ export const createApiCalls = async (args: CreateApiCallsArgs, options?: CreateApiCallsOptions) => { const {baseUrl = "https://api.salesflare.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") const url = `${baseUrl.replace(/\/+$/, '')}/calls${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 res.blob() };