Edits history of script submission #10438 for ' Retrieves tax records for a specific employee using a unique employee ID (xero)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Xero = {
    	token: string
    }
    /**
     * Retrieves tax records for a specific employee using a unique employee ID
     *
     */
    export async function main(auth: Xero, EmployeeID: string, Xero_Tenant_Id: string) {
    	const url = new URL(`https://api.xero.com/payroll.xro/2.0/Employees/${EmployeeID}/Tax`)
    
    	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