export type GetApiBankReconciliationsArgs = {account_name?: string | undefined, balance: unknown, id?: number | undefined, to_date?: string | undefined, organization_id: number, filters?: Record | undefined, 'sort[asc]'?: ('id' | 'from_date' | 'to_date' | 'account_name' | 'balance' | 'status') | undefined, 'sort[desc]'?: ('id' | 'from_date' | 'to_date' | 'account_name' | 'balance' | 'status') | undefined, page?: number | undefined, per_page?: number | undefined}; export type GetApiBankReconciliationsOptions = {baseUrl?: string | undefined, passport?: string | undefined, fetch?: typeof fetch | undefined}; /** * List all bank reconciliations * * GET /bank-reconciliations */ export const getApiBankReconciliations = async (args: GetApiBankReconciliationsArgs, options?: GetApiBankReconciliationsOptions) => { const {baseUrl = "http://localhost/app4legal/api/v2/money", fetch: fetchFn = fetch, passport} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.account_name != null) query.append("account_name", String(args.account_name)) if (args.balance != null) query.append("balance", String(args.balance)) if (args.id != null) query.append("id", String(args.id)) if (args.to_date != null) query.append("to_date", String(args.to_date)) if (args.organization_id != null) query.append("organization_id", String(args.organization_id)) if (args.filters != null) query.append("filters", JSON.stringify(args.filters)) if (args['sort[asc]'] != null) query.append("sort[asc]", String(args['sort[asc]'])) if (args['sort[desc]'] != null) query.append("sort[desc]", String(args['sort[desc]'])) if (args.page != null) query.append("page", String(args.page)) if (args.per_page != null) query.append("per_page", String(args.per_page)) if (passport !== undefined) headers.set('authorization', `Bearer ${passport}`) const url = `${baseUrl.replace(/\/+$/, '')}/bank-reconciliations${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 };