export type GetApiFinanceAccountsIdTransactionsArgs = {id: number, page?: number | undefined, direction?: ('income' | 'expense') | undefined, category_id?: number | undefined, created_by_id?: number | undefined, created_at?: Array | undefined, sort?: ('created_at' | '-created_at') | undefined}; export type GetApiFinanceAccountsIdTransactionsOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get Account Transactions * * GET /finance/accounts/{id}/transactions */ export const getApiFinanceAccountsIdTransactions = async (args: GetApiFinanceAccountsIdTransactionsArgs, options?: GetApiFinanceAccountsIdTransactionsOptions) => { 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)) if (args.direction != null) query.append("direction", String(args.direction)) if (args.category_id != null) query.append("category_id", String(args.category_id)) if (args.created_by_id != null) query.append("created_by_id", String(args.created_by_id)) 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/accounts/${encodeURIComponent(String(args.id))}/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 undefined };