export type GetApiInvoicesInvoiceHeaderIdPaymentsArgs = {invoice_header_id: number, payment_method?: number | undefined, payment_total?: string | undefined, payment_voucher_id?: number | undefined, filters?: Record | undefined, 'sort[asc]'?: ('payment_method' | 'payment_total') | undefined, 'sort[desc]'?: ('payment_method' | 'payment_total') | undefined, page?: number | undefined, per_page?: number | undefined}; export type GetApiInvoicesInvoiceHeaderIdPaymentsOptions = {baseUrl?: string | undefined, passport?: string | undefined, fetch?: typeof fetch | undefined}; /** * List invoice payments * * GET /invoices/{invoice_header_id}/payments */ export const getApiInvoicesInvoiceHeaderIdPayments = async (args: GetApiInvoicesInvoiceHeaderIdPaymentsArgs, options?: GetApiInvoicesInvoiceHeaderIdPaymentsOptions) => { const {baseUrl = "http://localhost/app4legal/api/v2/money", fetch: fetchFn = fetch, passport} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.payment_method != null) query.append("payment_method", String(args.payment_method)) if (args.payment_total != null) query.append("payment_total", String(args.payment_total)) if (args.payment_voucher_id != null) query.append("payment_voucher_id", String(args.payment_voucher_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(/\/+$/, '')}/invoices/${encodeURIComponent(String(args.invoice_header_id))}/payments${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 };