//native
/**
* Retrieve lookup information for currencies, countries, entity types, etc
* Retrieve lookup information such as currencies, countries, entity types, or SIC numbers. Use the `type` query parameter to specify which data to retrieve.
**Token scopes**: `legal-entity:read`
*/
export async function main(
auth: RT.Deel,
documents: 'sicNumbers' | 'entityTypes' | 'countries' | undefined
) {
const url = new URL(`https://api.letsdeel.com/rest/v2/lookups`)
for (const [k, v] of [['documents', documents]]) {
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