//native
/**
* List of legal entities
* Retrieve a list of legal entities in your account.
**Token scopes**: `organizations:read`, `accounting:read`
*/
export async function main(
auth: RT.Deel,
limit?: string | undefined,
sort_order?: 'ASC' | 'DESC' | undefined,
cursor?: string | undefined,
include_archived?: string | undefined,
legal_entity_id?: string | undefined,
global_payroll?: string | undefined,
_type?: string | undefined,
country?: string | undefined,
include_payroll_settings?: string | undefined
) {
const url = new URL(`https://api.letsdeel.com/rest/v2/legal-entities`)
for (const [k, v] of [
['limit', limit],
['sort_order', sort_order],
['cursor', cursor],
['include_archived', include_archived],
['legal_entity_id', legal_entity_id],
['global_payroll', global_payroll],
['type', _type],
['country', country],
['include_payroll_settings', include_payroll_settings]
]) {
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