//native
/**
* List invoice adjustments
* Retrieve invoice adjustments. You can filter the list by providing additional parameters e.g. contract_id, contract_type etc.
**Token scopes**: `invoice-adjustments:read`
*/
export async function main(
auth: RT.Deel,
contract_id?: string | undefined,
contract_types?: string | undefined,
types?: string | undefined,
statuses?: string | undefined,
invoice_id?: string | undefined,
reporter_id?: string | undefined,
date_from?: string | undefined,
date_to?: string | undefined,
limit?: string | undefined,
offset?: string | undefined
) {
const url = new URL(`https://api.letsdeel.com/rest/v2/invoice-adjustments`)
for (const [k, v] of [
['contract_id', contract_id],
['contract_types', contract_types],
['types', types],
['statuses', statuses],
['invoice_id', invoice_id],
['reporter_id', reporter_id],
['date_from', date_from],
['date_to', date_to],
['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