//native
type Xero = {
token: string
}
/**
* Retrieves sales quotes
*
*/
export async function main(
auth: Xero,
DateFrom: string | undefined,
DateTo: string | undefined,
ExpiryDateFrom: string | undefined,
ExpiryDateTo: string | undefined,
ContactID: string | undefined,
Status: string | undefined,
page: string | undefined,
order: string | undefined,
QuoteNumber: string | undefined,
xero_tenant_id: string,
If_Modified_Since: string
) {
const url = new URL(`https://api.xero.com/api.xro/2.0/Quotes`)
for (const [k, v] of [
['DateFrom', DateFrom],
['DateTo', DateTo],
['ExpiryDateFrom', ExpiryDateFrom],
['ExpiryDateTo', ExpiryDateTo],
['ContactID', ContactID],
['Status', Status],
['page', page],
['order', order],
['QuoteNumber', QuoteNumber]
]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
Accept: 'application/json',
'xero-tenant-id': xero_tenant_id,
'If-Modified-Since': If_Modified_Since,
Authorization: 'Bearer ' + auth.token
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 515 days ago