0
Creates an Aero based on the Library Template with the Id provided.
One script reply has been approved by the moderators Verified
Created by hugo697 51 days ago Viewed 592 times
0
Submitted by hugo697 Bun
Verified 51 days ago
1
//native
2
type Aero_workflow = {
3
	apiKey: string
4
}
5

6
export async function main(
7
	auth: Aero_workflow,
8
	accountid: string,
9
	id: string,
10
	body: {
11
		scheduledStartDate: string
12
		scheduledTotalHours: number
13
		scheduledHours: number
14
		scheduledMinutes: number
15
		teamMemberId?: number
16
		aeroTypeId?: number
17
		priority: string
18
		dueDate?: string
19
		billable?: false | true
20
		fixedFee?: false | true
21
		customerId?: number
22
		aeroGroupId?: number
23
		contactId?: number
24
		hatId?: number
25
	}
26
) {
27
	const url = new URL(
28
		`https://api.aeroworkflow.com/api/${accountid}/v1/AeroTasks/FromLibraryTemplate/${id}`
29
	)
30

31
	const response = await fetch(url, {
32
		method: 'POST',
33
		headers: {
34
			'Content-Type': 'application/json',
35
			apikey: auth.apiKey
36
		},
37
		body: JSON.stringify(body)
38
	})
39

40
	if (!response.ok) {
41
		const text = await response.text()
42
		throw new Error(`${response.status} ${text}`)
43
	}
44

45
	return await response.json()
46
}
47