export type GetApiCoaApiV1BillArgs = {currency?: string | undefined, download?: boolean | undefined, end_date?: string | undefined, entity?: number | undefined, include_deleted?: boolean | undefined, last_modified_at__gte?: string | undefined, last_modified_at__lte?: string | undefined, limit?: number | undefined, offset?: number | undefined, q?: string | undefined, sort?: string | undefined, start_date?: string | undefined, status?: ('1_30' | '31_60' | '61_90' | '91_120' | 'current' | 'open' | 'over_120' | 'paid' | 'partially_paid' | 'past_due' | 'payment_not_found' | 'payment_pending' | 'unpaid' | 'voided') | undefined, vendor?: number | undefined}; export type GetApiCoaApiV1BillOptions = {baseUrl?: string | undefined, knoxApiToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * List Accounting Bills * * GET /coa/api/v1/bill/ */ export const getApiCoaApiV1Bill = async (args: GetApiCoaApiV1BillArgs, options?: GetApiCoaApiV1BillOptions) => { const {baseUrl = "https://api.meetcampfire.com", fetch: fetchFn = fetch, knoxApiToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.currency != null) query.append("currency", String(args.currency)) if (args.download != null) query.append("download", String(args.download)) if (args.end_date != null) query.append("end_date", String(args.end_date)) if (args.entity != null) query.append("entity", String(args.entity)) if (args.include_deleted != null) query.append("include_deleted", String(args.include_deleted)) if (args.last_modified_at__gte != null) query.append("last_modified_at__gte", String(args.last_modified_at__gte)) if (args.last_modified_at__lte != null) query.append("last_modified_at__lte", String(args.last_modified_at__lte)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) if (args.q != null) query.append("q", String(args.q)) if (args.sort != null) query.append("sort", String(args.sort)) if (args.start_date != null) query.append("start_date", String(args.start_date)) if (args.status != null) query.append("status", String(args.status)) if (args.vendor != null) query.append("vendor", String(args.vendor)) if (knoxApiToken !== undefined) headers.set("Authorization", knoxApiToken) const url = `${baseUrl.replace(/\/+$/, '')}/coa/api/v1/bill/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };