export type CreateApiFinanceAccountsAccountIdTransactionsArgs = {account_id: number, body: {amount: string, direction: 'income' | 'expense', description?: string | undefined, category_id?: number | undefined, client_id?: number | undefined, tags?: Array | undefined, related_document?: ({id: number, type: 'order' | 'sale'}) | undefined, custom_created_at?: string | undefined}}; export type CreateApiFinanceAccountsAccountIdTransactionsOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create Transaction * * POST /finance/accounts/{account_id}/transactions */ export const createApiFinanceAccountsAccountIdTransactions = async (args: CreateApiFinanceAccountsAccountIdTransactionsArgs, options?: CreateApiFinanceAccountsAccountIdTransactionsOptions) => { const {baseUrl = "https://api.roapp.io/v2", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/finance/accounts/${encodeURIComponent(String(args.account_id))}/transactions${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };