//native
/**
* Check Visa Requirement
* Returns the necessity of a work visa for a specific country given the employee's nationalities.
**Token scopes**: `immigration:read`
*/
export async function main(
auth: RT.Deel,
country_code: string,
employee_nationalities: string | undefined
) {
const url = new URL(
`https://api.letsdeel.com/rest/v2/immigration/visa-requirement/${country_code}`
)
for (const [k, v] of [['employee_nationalities', employee_nationalities]]) {
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