export type CreateApiV1DocumentsArgs = {body: {doc_name: string, doc_date: string, category: string, doc_type: string, doc_size: number, driver_id?: number | undefined, ref_no?: string | undefined, notes?: string | undefined, dispatch_id?: number | undefined, doc_time?: string | undefined}}; export type CreateApiV1DocumentsOptions = {baseUrl?: string | undefined, sec0?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a new document * * POST /v1/documents */ export const createApiV1Documents = async (args: CreateApiV1DocumentsArgs, options?: CreateApiV1DocumentsOptions) => { const {baseUrl = "https://api.gomotive.com", fetch: fetchFn = fetch, sec0} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (sec0 !== undefined) headers.set("x-api-key", sec0) const url = `${baseUrl.replace(/\/+$/, '')}/v1/documents${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 (await res.json()) as unknown };