//native
/**
* Fetch EOR Contract form
* Returns a formulary for creating EOR Contracts
**Token scopes**: `forms:read`
*/
export async function main(
auth: RT.Deel,
country_code: string,
state?: string | undefined,
start_date?: string | undefined,
work_hours_per_week?: string | undefined,
contract_duration_in_days?: string | undefined
) {
const url = new URL(`https://api.letsdeel.com/rest/v2/forms/eor/create-contract/${country_code}`)
for (const [k, v] of [
['state', state],
['start_date', start_date],
['work_hours_per_week', work_hours_per_week],
['contract_duration_in_days', contract_duration_in_days]
]) {
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