//native
/**
* Fetch Start Date for EOR Contracts
* Returns the earliest allowed start date for a new EOR contract quote based on employment parameters.
**Token scopes**: `contracts:read`
*/
export async function main(
auth: RT.Deel,
employment_country: string | undefined,
team_id: string | undefined,
employee_nationality?: string | undefined,
work_visa?: string | undefined,
legal_entity_id?: string | undefined,
employment_state?: string | undefined,
special_job_id?: string | undefined
) {
const url = new URL(`https://api.letsdeel.com/rest/v2/eor/start-date`)
for (const [k, v] of [
['employment_country', employment_country],
['employee_nationality', employee_nationality],
['work_visa', work_visa],
['team_id', team_id],
['legal_entity_id', legal_entity_id],
['employment_state', employment_state],
['special_job_id', special_job_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