creates a project for the specified contact

Allows you to update a specific projects.

Script xero Verified

by hugo697 ยท 12/20/2024

The script

Submitted by hugo697 Bun
Verified 515 days ago
1
//native
2
type Xero = {
3
	token: string
4
}
5
/**
6
 * creates a project for the specified contact
7
 * Allows you to update a specific projects.
8
 */
9
export async function main(
10
	auth: Xero,
11
	projectId: string,
12
	Xero_Tenant_Id: string,
13
	Idempotency_Key: string,
14
	body: { status: 'INPROGRESS' | 'CLOSED' }
15
) {
16
	const url = new URL(`https://api.xero.com/projects.xro/2.0/Projects/${projectId}`)
17

18
	const response = await fetch(url, {
19
		method: 'PATCH',
20
		headers: {
21
			Accept: 'application/json',
22
			'Xero-Tenant-Id': Xero_Tenant_Id,
23
			'Idempotency-Key': Idempotency_Key,
24
			'Content-Type': 'application/json',
25
			Authorization: 'Bearer ' + auth.token
26
		},
27
		body: JSON.stringify(body)
28
	})
29
	if (!response.ok) {
30
		const text = await response.text()
31
		throw new Error(`${response.status} ${text}`)
32
	}
33
	return await response.text()
34
}
35