//native
/**
* Retrieve invoices
* Retrieve a list of paid invoices for your workforce.
**Token scopes**: `accounting:read`
*/
export async function main(
auth: RT.Deel,
issued_from_date?: string | undefined,
issued_to_date?: string | undefined,
entities?: string | undefined,
limit?: string | undefined,
offset?: string | undefined
) {
const url = new URL(`https://api.letsdeel.com/rest/v2/invoices`)
for (const [k, v] of [
['issued_from_date', issued_from_date],
['issued_to_date', issued_to_date],
['entities', entities],
['limit', limit],
['offset', offset]
]) {
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