//native
/**
* Download gross to net report
* Download global payroll reports detailing gross-to-net calculations.
**Token scopes**: `global-payroll:read`
*/
export async function main(auth: RT.Deel, id: string, currency?: string | undefined) {
const url = new URL(`https://api.letsdeel.com/rest/v2/gp/reports/${id}/gross_to_net/csv`)
for (const [k, v] of [['currency', currency]]) {
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.text()
}
Submitted by hugo697 235 days ago