export type ExpenseType = 'COMPANY' | 'PERSONAL' | 'TRAVEL_AND_ENTERTAINMENT'; export type SplitTag = {tag_id?: string | undefined, dictionary_id?: string | undefined}; export type SplitTransaction = {amount: number, expense_type?: ExpenseType | undefined, user_id?: string | undefined, expense_category_id?: string | undefined, tax_rate_id?: string | undefined, tags?: Array | undefined}; export type CreateTransactionSplit = {split_transactions: Array}; export type CreateApiBusinessV2TransactionsTransactionIdSplitArgs = {transactionId: string, body: CreateTransactionSplit}; export type CreateApiBusinessV2TransactionsTransactionIdSplitOptions = {baseUrl?: string | undefined, standardAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create Transaction Split * * POST /business/v2/transactions/{transactionId}/split */ export const createApiBusinessV2TransactionsTransactionIdSplit = async (args: CreateApiBusinessV2TransactionsTransactionIdSplitArgs, options?: CreateApiBusinessV2TransactionsTransactionIdSplitOptions) => { const {baseUrl = "https://api.soldo.com", fetch: fetchFn = fetch, standardAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (standardAuth !== undefined) headers.set('authorization', `Bearer ${standardAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/business/v2/transactions/${encodeURIComponent(String(args.transactionId))}/split${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 };