( apiBase: string, headers: Record<string, string>, params: Record<string, unknown>, signal?: AbortSignal )
| 468 | } |
| 469 | |
| 470 | async function handleVoidEnvelope( |
| 471 | apiBase: string, |
| 472 | headers: Record<string, string>, |
| 473 | params: Record<string, unknown>, |
| 474 | signal?: AbortSignal |
| 475 | ) { |
| 476 | const { envelopeId, voidedReason } = params |
| 477 | if (!envelopeId) { |
| 478 | return NextResponse.json({ success: false, error: 'envelopeId is required' }, { status: 400 }) |
| 479 | } |
| 480 | if (!voidedReason) { |
| 481 | return NextResponse.json({ success: false, error: 'voidedReason is required' }, { status: 400 }) |
| 482 | } |
| 483 | |
| 484 | const response = await fetchDocusign( |
| 485 | `${apiBase}/envelopes/${(envelopeId as string).trim()}`, |
| 486 | { |
| 487 | method: 'PUT', |
| 488 | headers, |
| 489 | body: JSON.stringify({ status: 'voided', voidedReason }), |
| 490 | }, |
| 491 | signal |
| 492 | ) |
| 493 | |
| 494 | const data = await readDocusignJson(response, 'DocuSign void envelope response') |
| 495 | if (!response.ok) { |
| 496 | return NextResponse.json( |
| 497 | { success: false, error: docusignError(data, 'Failed to void envelope') }, |
| 498 | { status: response.status } |
| 499 | ) |
| 500 | } |
| 501 | |
| 502 | return NextResponse.json({ envelopeId, status: 'voided' }) |
| 503 | } |
| 504 | |
| 505 | async function handleDownloadDocument( |
| 506 | apiBase: string, |
no test coverage detected