export type GetApiInvoiceCustomFieldsArgs = {type?: string | undefined, filters?: Record | undefined, 'sort[asc]'?: ('id' | 'field_order') | undefined, 'sort[desc]'?: ('id' | 'field_order') | undefined, page?: number | undefined, per_page?: number | undefined}; export type GetApiInvoiceCustomFieldsOptions = {baseUrl?: string | undefined, passport?: string | undefined, fetch?: typeof fetch | undefined}; /** * List all invoice custom fields * * GET /invoice-custom-fields */ export const getApiInvoiceCustomFields = async (args: GetApiInvoiceCustomFieldsArgs, options?: GetApiInvoiceCustomFieldsOptions) => { const {baseUrl = "http://localhost/app4legal/api/v2/money", fetch: fetchFn = fetch, passport} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.type != null) query.append("type", String(args.type)) 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(/\/+$/, '')}/invoice-custom-fields${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 };