//native
type Xero = {
token: string
}
/**
* Reverts a specific timesheet to draft
*
*/
export async function main(
auth: Xero,
TimesheetID: string,
Xero_Tenant_Id: string,
Idempotency_Key: string
) {
const url = new URL(
`https://api.xero.com/payroll.xro/2.0/Timesheets/${TimesheetID}/RevertToDraft`
)
const response = await fetch(url, {
method: 'POST',
headers: {
Accept: 'application/json',
'Xero-Tenant-Id': Xero_Tenant_Id,
'Idempotency-Key': Idempotency_Key,
Authorization: 'Bearer ' + auth.token
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 209 days ago