//native
async function apiBase(auth: RT.AdobeAcrobatSign): Promise<string> {
if (auth.base_uri) return auth.base_uri.replace(/\/+$/, "")
const r = await fetch("https://api.adobesign.com/api/rest/v6/baseUris", {
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
},
})
if (!r.ok) throw new Error(`${r.status} ${await r.text()}`)
const { apiAccessPoint } = (await r.json()) as { apiAccessPoint: string }
return apiAccessPoint.replace(/\/+$/, "")
}
/**
* List Users
* List the users in the Acrobat Sign account.
*/
export async function main(
auth: RT.AdobeAcrobatSign,
cursor: string | undefined,
page_size: number | undefined
) {
const base = await apiBase(auth)
const url = new URL(`${base}/api/rest/v6/users`)
for (const [k, v] of [
["cursor", cursor],
["pageSize", page_size],
] as const) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, String(v))
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 5 days ago