export type FieldAssignments = Array<{field_id: string, field_value_id: string}>; export type CashMatchTransferAdjustment = {account_id: string, fields?: FieldAssignments | undefined}; export type MatchBankTransactionsTransferRequest = {transaction_id: string, destination_transaction_id: string, fees_account_id?: string | undefined, reconciliation_adjustment?: CashMatchTransferAdjustment | undefined}; export type CreateApiBankTransactionsReconcileTransferArgs = {body: MatchBankTransactionsTransferRequest}; export type CreateApiBankTransactionsReconcileTransferOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Matches two bank transactions as a transfer * * POST /bank-transactions/reconcile/transfer */ export const createApiBankTransactionsReconcileTransfer = async (args: CreateApiBankTransactionsReconcileTransferArgs, options?: CreateApiBankTransactionsReconcileTransferOptions) => { const {baseUrl = "https://api.rillet.com", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/bank-transactions/reconcile/transfer${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 undefined };