Edits history of script submission #15581 for ' Retrieve a Paginated List of Shift Rates (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Retrieve a Paginated List of Shift Rates
     * Retrieve a paginated list of shift rates, including details such as rate name, type, value, and timestamps. Pagination parameters can be used to control the size and position of the result set.
     **Token scopes**: `time-tracking:read`
     */
    export async function main(auth: RT.Deel, limit?: string | undefined, offset?: string | undefined) {
    	const url = new URL(`https://api.letsdeel.com/rest/v2/time_tracking/shift_rates`)
    	for (const [k, v] of [
    		['limit', limit],
    		['offset', offset]
    	]) {
    		if (v !== undefined && v !== '') {
    			url.searchParams.append(k, v)
    		}
    	}
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			Authorization: 'Bearer ' + auth.apiKey
    		},
    		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