//native
/**
* Invoice line items by contract
* Retrieve invoice line items for a given contract id.
**Token scopes**: `invoice-adjustments:read`
*/
export async function main(
auth: RT.Deel,
contract_id: string,
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/contracts/${contract_id}/invoice-adjustments`
)
for (const [k, v] of [
['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