0

Print Inquiry PDF

by
Published Apr 8, 2025

Prints an Inquiry as PDF.

Script persona Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Persona = {
3
  apiKey: string;
4
};
5
/**
6
 * Print Inquiry PDF
7
 * Prints an Inquiry as PDF.
8
 */
9
export async function main(
10
  auth: Persona,
11
  inquiry_id: string,
12
  Key_Inflection?: string,
13
  Idempotency_Key?: string,
14
  Persona_Version?: string,
15
) {
16
  const url = new URL(
17
    `https://api.withpersona.com/api/v1/inquiries/${inquiry_id}/print`,
18
  );
19

20
  const headers: Record<string, string> = {
21
    Authorization: `Bearer ${auth.apiKey}`,
22
  };
23
  if (Key_Inflection) {
24
    headers["Key-Inflection"] = Key_Inflection;
25
  }
26
  if (Idempotency_Key) {
27
    headers["Idempotency-Key"] = Idempotency_Key;
28
  }
29
  if (Persona_Version) {
30
    headers["Persona-Version"] = Persona_Version;
31
  }
32

33
  const response = await fetch(url, {
34
    method: "GET",
35
    headers,
36
    body: undefined,
37
  });
38
  if (!response.ok) {
39
    const text = await response.text();
40
    throw new Error(`${response.status} ${text}`);
41
  }
42
  return await response.text();
43
}
44