//native
type Pandadoc = {
apiKey: string
}
export async function main(auth: Pandadoc, email: string | undefined) {
const url = new URL(`https://api.pandadoc.com/public/v1/contacts`)
for (const [k, v] of [['email', email]]) {
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