export type CreateApiInvoicesScanStatementArgs = {body: BodyInit}; export type CreateApiInvoicesScanStatementOptions = {baseUrl: string, ApiKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Match a bank statement against unpaid invoices * * POST /invoices/scan-statement * * Also accepts auth: FirebaseIdToken */ export const createApiInvoicesScanStatement = async (args: CreateApiInvoicesScanStatementArgs, options: CreateApiInvoicesScanStatementOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (ApiKeyHeader !== undefined) headers.set("X-API-Key", ApiKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/invoices/scan-statement${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };