0

Send Agreement Reminder

by
Published 4 days ago

Send a reminder to one or more current participants of an agreement to complete their action.

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
 * Send Agreement Reminder
18
 * Send a reminder to one or more current participants of an agreement to complete their action.
19
 */
20
export async function main(
21
  auth: RT.AdobeAcrobatSign,
22
  agreement_id: string,
23
  reminder: {
24
    recipientParticipantIds?: string[]
25
    note?: string
26
    status?: "ACTIVE" | "CANCELLED" | "COMPLETE"
27
    firstReminderDelay?: number
28
    frequency?: string
29
    [key: string]: unknown
30
  }
31
) {
32
  const base = await apiBase(auth)
33
  const url = new URL(
34
    `${base}/api/rest/v6/agreements/${agreement_id}/reminders`
35
  )
36

37
  const response = await fetch(url, {
38
    method: "POST",
39
    headers: {
40
      Authorization: `Bearer ${auth.token}`,
41
      "Content-Type": "application/json",
42
      Accept: "application/json",
43
    },
44
    body: JSON.stringify(reminder),
45
  })
46

47
  if (!response.ok) {
48
    throw new Error(`${response.status} ${await response.text()}`)
49
  }
50

51
  return await response.json()
52
}
53