//native
/**
* List of people
* Retrieve a list of People in your organization.
**Token scopes**: `people:read`
*/
export async function main(
auth: RT.Deel,
offset?: string | undefined,
limit?: string | undefined,
search?: string | undefined,
sort_by?:
| 'id'
| 'first_name'
| 'last_name'
| 'full_name'
| 'email'
| 'country'
| 'birth_date'
| 'hiring_type'
| 'start_date'
| 'team'
| 'job_title'
| 'hiring_status'
| 'completion_date'
| 'direct_manager'
| 'direct_reports_count'
| undefined,
sort_order?: 'asc' | 'desc' | undefined,
hiring_statuses?: string | undefined
) {
const url = new URL(`https://api.letsdeel.com/rest/v2/people`)
for (const [k, v] of [
['offset', offset],
['limit', limit],
['search', search],
['sort_by', sort_by],
['sort_order', sort_order],
['hiring_statuses', hiring_statuses]
]) {
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