//native
/**
* Retrieve payment receipts
* Retrieve a list of payments made to Deel, including worker details, payment status, and payment methods.
**Token scopes**: `accounting:read`
*/
export async function main(
auth: RT.Deel,
date_from?: string | undefined,
date_to?: string | undefined,
currencies?: string | undefined,
entities?: string | undefined,
statuses?: string | undefined
) {
const url = new URL(`https://api.letsdeel.com/rest/v2/payments`)
for (const [k, v] of [
['date_from', date_from],
['date_to', date_to],
['currencies', currencies],
['entities', entities],
['statuses', statuses]
]) {
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