//native
/**
* Retrieve Benefits by Country
* Retrieves list of benefits available in a specific country based work visa requirement, work hours, employment type, team, and legal entity.
**Token scopes**: `benefits:read`
*/
export async function main(
auth: RT.Deel,
country_code: string | undefined,
work_visa: string | undefined,
work_hours_per_week: string | undefined,
employment_type: 'Full-time' | 'Part-time' | undefined,
team_id: string | undefined,
legal_entity_id: string | undefined
) {
const url = new URL(`https://api.letsdeel.com/rest/v2/eor/benefits`)
for (const [k, v] of [
['country_code', country_code],
['work_visa', work_visa],
['work_hours_per_week', work_hours_per_week],
['employment_type', employment_type],
['team_id', team_id],
['legal_entity_id', legal_entity_id]
]) {
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