export type GetApiTransactionsArgs = {page?: number | undefined, per_page?: number | undefined, id?: string | undefined, transaction_id?: string | undefined, invoice_id?: number | undefined, order_id?: string | undefined, status?: ('paid' | 'pending' | 'COMPLETED') | undefined, created_at_from?: string | undefined, created_at_to?: string | undefined, sort?: ('id' | 'transaction_id' | 'amount' | 'invoice_id' | 'order_id' | 'status' | 'created_at') | undefined, order?: ('asc' | 'desc') | undefined}; export type GetApiTransactionsOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * List order transactions (datagrid parity) * * GET /transactions */ export const getApiTransactions = async (args: GetApiTransactionsArgs, options?: GetApiTransactionsOptions) => { const {baseUrl = "http://localhost:8000/api/admin", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.page != null) query.append("page", String(args.page)) if (args.per_page != null) query.append("per_page", String(args.per_page)) if (args.id != null) query.append("id", String(args.id)) if (args.transaction_id != null) query.append("transaction_id", String(args.transaction_id)) if (args.invoice_id != null) query.append("invoice_id", String(args.invoice_id)) if (args.order_id != null) query.append("order_id", String(args.order_id)) if (args.status != null) query.append("status", String(args.status)) if (args.created_at_from != null) query.append("created_at_from", String(args.created_at_from)) if (args.created_at_to != null) query.append("created_at_to", String(args.created_at_to)) if (args.sort != null) query.append("sort", String(args.sort)) if (args.order != null) query.append("order", String(args.order)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/transactions${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 (await res.json()) as unknown };