( apiBase: string, headers: Record<string, string>, params: Record<string, unknown>, signal?: AbortSignal )
| 405 | } |
| 406 | |
| 407 | async function handleGetEnvelope( |
| 408 | apiBase: string, |
| 409 | headers: Record<string, string>, |
| 410 | params: Record<string, unknown>, |
| 411 | signal?: AbortSignal |
| 412 | ) { |
| 413 | const { envelopeId } = params |
| 414 | if (!envelopeId) { |
| 415 | return NextResponse.json({ success: false, error: 'envelopeId is required' }, { status: 400 }) |
| 416 | } |
| 417 | |
| 418 | const response = await fetchDocusign( |
| 419 | `${apiBase}/envelopes/${(envelopeId as string).trim()}?include=recipients,documents`, |
| 420 | { headers }, |
| 421 | signal |
| 422 | ) |
| 423 | const data = await readDocusignJson(response, 'DocuSign envelope response') |
| 424 | |
| 425 | if (!response.ok) { |
| 426 | return NextResponse.json( |
| 427 | { success: false, error: docusignError(data, 'Failed to get envelope') }, |
| 428 | { status: response.status } |
| 429 | ) |
| 430 | } |
| 431 | |
| 432 | return NextResponse.json(data) |
| 433 | } |
| 434 | |
| 435 | async function handleListEnvelopes( |
| 436 | apiBase: string, |
no test coverage detected