0

searches fixed asset settings

by
Published Dec 20, 2024

By passing in the appropriate options, you can search for available fixed asset types in the system

Script xero Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Xero = {
3
	token: string
4
}
5
/**
6
 * searches fixed asset settings
7
 * By passing in the appropriate options, you can search for available fixed asset types in the system
8
 */
9
export async function main(auth: Xero, xero_tenant_id: string) {
10
	const url = new URL(`https://api.xero.com/assets.xro/1.0/Settings`)
11

12
	const response = await fetch(url, {
13
		method: 'GET',
14
		headers: {
15
			Accept: 'application/json',
16
			'xero-tenant-id': xero_tenant_id,
17
			Authorization: 'Bearer ' + auth.token
18
		},
19
		body: undefined
20
	})
21
	if (!response.ok) {
22
		const text = await response.text()
23
		throw new Error(`${response.status} ${text}`)
24
	}
25
	return await response.json()
26
}
27