export type JsonPointer = {matchingIndex?: number | undefined, matchingProperty?: string | undefined}; export type JsonApiErrorSource = {parameter?: string | undefined, pointer?: JsonPointer | undefined}; export type JsonApiError = {code?: string | undefined, detail?: string | undefined, id?: string | undefined, source?: JsonApiErrorSource | undefined, status?: string | undefined, title?: string | undefined}; export type TransactionJobStatusJson = {completedAt?: string | undefined, creator?: number | undefined, errors?: Array | undefined, id?: string | undefined, jobType?: string | undefined, parameters?: Record | undefined, percentComplete?: number | undefined, startedAt?: string | undefined, status?: string | undefined}; export type CreateApiTransactionJobsArgs = {'Addepar-Firm': string, isHighPrio?: boolean | undefined, body: TransactionJobStatusJson}; export type CreateApiTransactionJobsOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create Transaction Job * * POST /transaction_jobs */ export const createApiTransactionJobs = async (args: CreateApiTransactionJobsArgs, options?: CreateApiTransactionJobsOptions) => { const {baseUrl = "https://examplefirm.addepar.com/api/v1", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/vnd.api+json") headers.set('accept', "application/vnd.api+json") if (args['Addepar-Firm'] != null) headers.set("Addepar-Firm", String(args['Addepar-Firm'])) if (args.isHighPrio != null) query.append("isHighPrio", String(args.isHighPrio)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/transaction_jobs${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 (await res.json()) as unknown };