export type RecFileReqDto = {workflowName: string, stageName: string, recordId: number, isFileField: boolean, fieldName: string}; export type CreateApiApiPublicRecordfileArgs = {body: RecFileReqDto}; export type CreateApiApiPublicRecordfileOptions = {baseUrl: string, ApiKey?: string | undefined, UserKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * To get file from the specific field of the given record id * * POST /api/Public/recordfile */ export const createApiApiPublicRecordfile = async (args: CreateApiApiPublicRecordfileArgs, options: CreateApiApiPublicRecordfileOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKey, UserKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ApiKey !== undefined) headers.set("X-Api-Key", ApiKey) if (UserKey !== undefined) headers.set("X-User-Key", UserKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/Public/recordfile${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 };