export type GetApiFinanceCashflowCategoriesArgs = {direction?: ('income' | 'expense') | undefined, sort?: ('id' | '-id' | 'title' | '-title') | undefined}; export type GetApiFinanceCashflowCategoriesOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get Cashflow Categories * * GET /finance/cashflow-categories */ export const getApiFinanceCashflowCategories = async (args: GetApiFinanceCashflowCategoriesArgs, options?: GetApiFinanceCashflowCategoriesOptions) => { const {baseUrl = "https://api.roapp.io/v2", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.direction != null) query.append("direction", String(args.direction)) if (args.sort != null) query.append("sort", String(args.sort)) if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/finance/cashflow-categories${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 };