0

List Mega Signs

by
Published 4 days ago

List the MegaSign (bulk send) parent agreements visible to the user.

Script adobe_acrobat_sign Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 5 days ago
1
//native
2

3
async function apiBase(auth: RT.AdobeAcrobatSign): Promise<string> {
4
  if (auth.base_uri) return auth.base_uri.replace(/\/+$/, "")
5
  const r = await fetch("https://api.adobesign.com/api/rest/v6/baseUris", {
6
    headers: {
7
      Authorization: `Bearer ${auth.token}`,
8
      Accept: "application/json",
9
    },
10
  })
11
  if (!r.ok) throw new Error(`${r.status} ${await r.text()}`)
12
  const { apiAccessPoint } = (await r.json()) as { apiAccessPoint: string }
13
  return apiAccessPoint.replace(/\/+$/, "")
14
}
15

16
/**
17
 * List Mega Signs
18
 * List the MegaSign (bulk send) parent agreements visible to the user.
19
 */
20
export async function main(
21
  auth: RT.AdobeAcrobatSign,
22
  cursor: string | undefined,
23
  page_size: number | undefined
24
) {
25
  const base = await apiBase(auth)
26
  const url = new URL(`${base}/api/rest/v6/megaSigns`)
27
  for (const [k, v] of [
28
    ["cursor", cursor],
29
    ["pageSize", page_size],
30
  ] as const) {
31
    if (v !== undefined && v !== "") {
32
      url.searchParams.append(k, String(v))
33
    }
34
  }
35

36
  const response = await fetch(url, {
37
    method: "GET",
38
    headers: {
39
      Authorization: `Bearer ${auth.token}`,
40
      Accept: "application/json",
41
    },
42
  })
43

44
  if (!response.ok) {
45
    throw new Error(`${response.status} ${await response.text()}`)
46
  }
47

48
  return await response.json()
49
}
50