//native
type Xero = {
token: string
}
/**
* Get lock history
* Provides a history of locking of accounting books. Locking may be an indicator of good accounting practices that could reduce the risk of changes to accounting records in prior periods.
*/
export async function main(auth: Xero, endDate: string | undefined, xero_tenant_id: string) {
const url = new URL(`https://api.xero.com/finance.xro/1.0/AccountingActivities/LockHistory`)
for (const [k, v] of [['endDate', endDate]]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
Accept: 'application/json',
'xero-tenant-id': xero_tenant_id,
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 515 days ago