//native
/**
* List of contracts
* Retrieve a list of contracts.
**Token scopes**: `contracts:read`
*/
export async function main(
auth: RT.Deel,
after_cursor?: string | undefined,
limit?: string | undefined,
order_direction?: 'asc' | 'desc' | undefined,
types?: string | undefined,
statuses?: string | undefined,
team_id?: string | undefined,
external_id?: string | undefined,
countries?: string | undefined,
currencies?: string | undefined,
search?: string | undefined,
sort_by?: 'contract_title' | 'worker_name' | undefined,
expand?: 'cost_centers' | undefined
) {
const url = new URL(`https://api.letsdeel.com/rest/v2/contracts`)
for (const [k, v] of [
['after_cursor', after_cursor],
['limit', limit],
['order_direction', order_direction],
['types', types],
['statuses', statuses],
['team_id', team_id],
['external_id', external_id],
['countries', countries],
['currencies', currencies],
['search', search],
['sort_by', sort_by],
['expand', expand]
]) {
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