export type ResthookEvent = 'resume.parse.succeeded' | 'resume.parse.failed' | 'resume.parse.completed' | 'invoice.parse.succeeded' | 'invoice.parse.failed' | 'invoice.parse.completed' | 'invoice.validate.completed' | 'document.parse.succeeded' | 'document.parse.failed' | 'document.parse.completed' | 'document.validate.completed' | 'document.classify.succeeded' | 'document.classify.failed' | 'document.classify.completed' | 'document.rejected' | 'annotation.validated' | 'submission.completed'; export type CreateApiV3ResthookResultsResendArgs = {body: {document: string, event: ResthookEvent}}; export type CreateApiV3ResthookResultsResendOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Re-trigger webhooks for a document * * POST /v3/resthook_results/resend */ export const createApiV3ResthookResultsResend = async (args: CreateApiV3ResthookResultsResendArgs, options?: CreateApiV3ResthookResultsResendOptions) => { const {baseUrl = "https://api.affinda.com", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ApiKeyAuth !== undefined) headers.set('authorization', `Bearer ${ApiKeyAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v3/resthook_results/resend${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 };