//native
type Pandadoc = {
apiKey: string
}
export async function main(
auth: Pandadoc,
parent_uuid: string | undefined,
count: string | undefined,
page: string | undefined
) {
const url = new URL(`https://api.pandadoc.com/public/v1/templates/folders`)
for (const [k, v] of [
['parent_uuid', parent_uuid],
['count', count],
['page', page]
]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: `API-Key ${auth.apiKey}`
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 581 days ago