Edits history of script submission #14204 for ' List Reports (bamboo_hr)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * List Reports
     * Use this resource to retrieve a list of available reports.
     */
    export async function main(
    	auth: RT.BambooHr,
    	page?: string | undefined,
    	page_size?: string | undefined
    ) {
    	const url = new URL(`https://${auth.companyDomain}.bamboohr.com/api/v1/custom-reports`)
    	for (const [k, v] of [
    		['page', page],
    		['page_size', page_size]
    	]) {
    		if (v !== undefined && v !== '') {
    			url.searchParams.append(k, v)
    		}
    	}
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			Authorization: 'Basic ' + btoa(`${auth.apiKey}:x`)
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 235 days ago