export type CreateApiTransactionsTransactionIdCancelArgs = {transaction_id: string, 'Company-Id'?: string | undefined, Mid?: string | undefined, body: {custom_data?: string | undefined}}; export type CreateApiTransactionsTransactionIdCancelOptions = {baseUrl?: string | undefined, token?: string | undefined, fetch?: typeof fetch | undefined}; /** * Cancel a Direct Debit * * POST /transactions/{transaction_id}/cancel */ export const createApiTransactionsTransactionIdCancel = async (args: CreateApiTransactionsTransactionIdCancelArgs, options?: CreateApiTransactionsTransactionIdCancelOptions) => { const {baseUrl = "https://test-api.acquired.com/v1", fetch: fetchFn = fetch, token} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['Company-Id'] != null) headers.set("Company-Id", String(args['Company-Id'])) if (args.Mid != null) headers.set("Mid", String(args.Mid)) if (token !== undefined) headers.set('authorization', `Bearer ${token}`) const url = `${baseUrl.replace(/\/+$/, '')}/transactions/${encodeURIComponent(String(args.transaction_id))}/cancel${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 };