//native
/**
* Preview a contract agreement
* Retrieve an IC and EOR contract agreement content in HTML. If no template is specified, the default or currently assigned template will be used. This endpoint does not support Global Payroll contract type.
**Token scopes**: `contracts:read`
*/
export async function main(auth: RT.Deel, contract_id: string, templateId?: string | undefined) {
const url = new URL(`https://api.letsdeel.com/rest/v2/contracts/${contract_id}/preview`)
for (const [k, v] of [['templateId', templateId]]) {
if (v !== undefined && v !== '') {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: 'Bearer ' + auth.apiKey
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.text()
}
Submitted by hugo697 235 days ago