export type GetApiFinanceRefundsArgs = {page?: number | undefined, branch_ids?: Array | undefined, client_ids?: Array | undefined, related_document_type?: ('order' | 'sale') | undefined, created_at?: Array | undefined, sort?: ('id' | '-id') | undefined}; export type GetApiFinanceRefundsOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get Refunds * * GET /finance/refunds */ export const getApiFinanceRefunds = async (args: GetApiFinanceRefundsArgs, options?: GetApiFinanceRefundsOptions) => { const {baseUrl = "https://api.roapp.io/v2", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.page != null) query.append("page", String(args.page)) for (const item of args.branch_ids ?? []) query.append("branch_ids", String(item)) for (const item of args.client_ids ?? []) query.append("client_ids", String(item)) if (args.related_document_type != null) query.append("related_document_type", String(args.related_document_type)) for (const item of args.created_at ?? []) query.append("created_at", String(item)) if (args.sort != null) query.append("sort", String(args.sort)) if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/finance/refunds${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 };