//native
type Xero = {
token: string
}
/**
* Creates statutory sick leave records
*
*/
export async function main(
auth: Xero,
Xero_Tenant_Id: string,
Idempotency_Key: string,
body: {
statutoryLeaveID?: string
employeeID: string
leaveTypeID: string
startDate: string
endDate: string
type?: string
status?: string
workPattern: string[]
isPregnancyRelated: false | true
sufficientNotice: false | true
isEntitled?: false | true
entitlementWeeksRequested?: number
entitlementWeeksQualified?: number
entitlementWeeksRemaining?: number
overlapsWithOtherLeave?: false | true
entitlementFailureReasons?:
| 'UnableToCalculateAwe'
| 'AweLowerThanLel'
| 'NotQualifiedInPreviousPiw'
| 'ExceededMaximumEntitlementWeeksOfSsp'
| 'ExceededMaximumDurationOfPiw'
| 'SufficientNoticeNotGiven'[]
}
) {
const url = new URL(`https://api.xero.com/payroll.xro/2.0/StatutoryLeaves/Sick`)
const response = await fetch(url, {
method: 'POST',
headers: {
Accept: 'application/json',
'Xero-Tenant-Id': Xero_Tenant_Id,
'Idempotency-Key': Idempotency_Key,
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.token
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 515 days ago